def createCablingPlan(self, podId): ''' Finds Pod object by id and create cabling plan It also creates the output folders for pod ''' if podId is not None: try: pod = self.dao.getObjectById(Pod, podId) except (exc.NoResultFound) as e: raise ValueError("Pod[id='%s']: not found" % (podId)) if len(pod.devices) > 0: cablingPlanWriter = CablingPlanWriter(self.conf, pod, self.dao) # create cabling plan in JSON format cablingPlanWriter.writeJSON() # create cabling plan in DOT format cablingPlanWriter.writeDOT() # update status pod.state = 'cablingDone' self.dao.updateObjects([pod]) return True else: raise ValueError("Pod[id='%s', name='%s']: inventory is empty" % (pod.id, pod.name)) else: raise ValueError("Pod id can't be None")
def createCablingPlan(self, podId): ''' Finds Pod object by id and create cabling plan It also creates the output folders for pod ''' if podId is None: raise InvalidRequest("Pod id cannot be None") with self._dao.getReadWriteSession() as session: try: pod = self._dao.getObjectById(session, Pod, podId) except (exc.NoResultFound): raise PodNotFound(podId, exc) if len(pod.devices) > 0: cablingPlanWriter = CablingPlanWriter(self._conf, pod, self._dao) # create cabling plan in JSON format cablingPlanJson = cablingPlanWriter.writeJSON() pod.cablingPlan = CablingPlan(pod.id, cablingPlanJson) # create cabling plan in DOT format cablingPlanWriter.writeDOT() self._dao.updateObjects(session, [pod]) return True else: logger.warning("Pod[id='%s', name='%s']: inventory is empty" % (pod.id, pod.name)) return False
def processTopology(self, podName, reCreateFabric=False): ''' Finds Pod object by name and process topology It also creates the output folders for pod ''' try: pod = self.dao.getUniqueObjectByName(Pod, podName) except (exc.NoResultFound) as e: raise ValueError( "No Pod found with pod name: '%s', exc.NoResultFound: %s" % (podName, e.message)) except (exc.MultipleResultsFound) as e: raise ValueError( "Multiple Pods found with pod name: '%s', exc.MultipleResultsFound: %s" % (podName, e.message)) if pod.inventory is not None: # topology handling is divided into 3 steps: # 1. load inventory # 2. create cabling plan # 3. create configuration files # 1. load inventory json_inventory = open( os.path.join(util.configLocation, pod.inventory)) inventory = json.load(json_inventory) json_inventory.close() self.createSpineIFDs(pod, inventory['spines']) self.createLeafIFDs(pod, inventory['leafs']) # 2. create cabling plan in JSON format cablingPlanWriter = CablingPlanWriter(self.conf, pod, self.dao) cablingPlanJSON = cablingPlanWriter.writeJSON() self.createLinkBetweenIFDs(pod, cablingPlanJSON['links']) # create cabling plan in DOT format cablingPlanWriter.writeDOT() # 3. allocate resource and create configuration files self.allocateResource(pod) self.generateConfig(pod) return True else: raise ValueError("No topology found for pod name: '%s'", (podName))
def processTopology(self, podName, reCreateFabric = False): ''' Finds Pod object by name and process topology It also creates the output folders for pod ''' try: pod = self.dao.getUniqueObjectByName(Pod, podName) except (exc.NoResultFound) as e: raise ValueError("No Pod found with pod name: '%s', exc.NoResultFound: %s" % (podName, e.message)) except (exc.MultipleResultsFound) as e: raise ValueError("Multiple Pods found with pod name: '%s', exc.MultipleResultsFound: %s" % (podName, e.message)) if pod.inventory is not None: # topology handling is divided into 3 steps: # 1. load inventory # 2. create cabling plan # 3. create configuration files # 1. load inventory json_inventory = open(os.path.join(util.configLocation, pod.inventory)) inventory = json.load(json_inventory) json_inventory.close() self.createSpineIFDs(pod, inventory['spines']) self.createLeafIFDs(pod, inventory['leafs']) # 2. create cabling plan in JSON format cablingPlanWriter = CablingPlanWriter(self.conf, pod, self.dao) cablingPlanJSON = cablingPlanWriter.writeJSON() self.createLinkBetweenIFDs(pod, cablingPlanJSON['links']) # create cabling plan in DOT format cablingPlanWriter.writeDOT() # 3. allocate resource and create configuration files self.allocateResource(pod) self.generateConfig(pod); return True else: raise ValueError("No topology found for pod name: '%s'", (podName))