def configure_l2_network(self, dts): nwtop = RwTl.YangData_IetfNetwork() l2top = MyL2Topology(nwtop, self.log) l2top.setup_all() nw_xpath = "C,/nd:network" self.log.info("Configuring l2 network: %s", nwtop) yield from dts.query_create(nw_xpath, rwdts.XactFlag.ADVISE, nwtop)
def setUp(self): """ Initialize Top data store """ self._nwtopdata_store = NwtopDataStore(logger) self.test_nwtop = RwTl.YangData_IetfNetwork() self.l2top = MyL2Topology(self.test_nwtop, logger) self.l2top.setup_all() # Get initial test data self.l2net1 = self.l2top.find_nw("L2HostNetwork-1") # Create initial nw self._nwtopdata_store.create_network("L2HostNetwork-1", self.l2net1) # Get test data self.l2net1 = self.l2top.find_nw("L2HostNetwork-1") assert self.l2net1 is not None self.new_l2net = RwTl.YangData_IetfNetwork_Network() self.new_l2net.network_id = "L2HostNetwork-1" self.src_node = self.new_l2net.node.add() self.src_node.node_id = "TempNode1" self.tp1 = self.src_node.termination_point.add() self.tp1.tp_id = "TempTp1" self.dest_node = self.new_l2net.node.add() self.dest_node.node_id = "TempNode2" self.tp2 = self.dest_node.termination_point.add() self.tp2.tp_id = "TempTp2" logger.info("SdnTopStoreTest: setUp NetworkLinkTest")
def configure_sfc_network(self, dts): nwtop = RwTl.YangData_IetfNetwork() l2top = MyL2Topology(nwtop, self.log) l2top.setup_all() provtop = MyProvTopology(nwtop, l2top, self.log) provtop.setup_all() vmtop = MyVMTopology(nwtop, l2top, provtop, self.log) vmtop.setup_all() sfctop = MySfcTopology(nwtop, l2top, provtop, vmtop, self.log) sfctop.setup_all() nw_xpath = "C,/nd:network" self.log.info("Configuring SFC network: %s", nwtop) yield from dts.query_create(nw_xpath, rwdts.XactFlag.ADVISE, nwtop)
def setUp(self): """ Initialize Top data store """ self._nwtopdata_store = NwtopDataStore(logger) self.test_nwtop = RwTl.YangData_IetfNetwork() self.l2top = MyL2Topology(self.test_nwtop, logger) self.l2top.setup_all() # Get initial test data self.l2net1 = self.l2top.find_nw("L2HostNetwork-1") # Create initial nw self._nwtopdata_store.create_network("L2HostNetwork-1", self.l2net1) # Add test data self.l2net1 = self.l2top.find_nw("L2HostNetwork-1") assert self.l2net1 is not None self.new_l2net = RwTl.YangData_IetfNetwork_Network() self.new_l2net.network_id = "L2HostNetwork-2" logger.info("SdnTopStoreNetworkTest: setUp")
def get_network_list(self, account): """ Returns the discovered network @param account - a SDN account """ nwtop = RwTl.YangData_IetfNetwork() #topology_source = "/net/boson/home1/rchamart/work/topology/l2_top.xml" if not account.sdnsim.has_field( 'topology_source') or account.sdnsim.topology_source is None: return nwtop topology_source = account.sdnsim.topology_source logger.info("Reading topology file: %s", topology_source) if 'json' in topology_source: with open(topology_source, 'r') as f: print("Reading static topology file") op_json = f.read() nwtop.from_json(self._model, op_json) for nw in nwtop.network: nw.server_provided = False logger.debug("...Network id %s", nw.network_id) #nw_xpath = ("D,/nd:network[network-id={}]").format(quoted_key(nw.network_id)) #xact_info.respond_xpath(rwdts.XactRspCode.MORE, # nw_xpath, nw) elif 'xml' in topology_source: tree = etree.parse(topology_source) root = tree.getroot() xmlstr = etree.tostring(root, encoding="unicode") # The top level topology object does not have XML conversion # Hence going one level down #l2nw1 = nwtop.network.add() #l2nw1.from_xml_v2(self._model, xmlstr) nwtop.from_xml_v2(self._model, xmlstr) logger.debug("Returning topology data imported from XML file") return nwtop
def create_default_topology(self): logger.debug('Creating default topology: ') self.topology = RwTl.YangData_IetfNetwork() self.nw = self.topology.network.add() self.nw.network_id = "L2HostTopology-Def1" self.nw.server_provided = 'true' # L2 Network type augmentation self.nw.network_types.l2_network = self.nw.network_types.l2_network.new( ) # L2 Network augmentation self.nw.l2_network_attributes.name = "Rift LAB SFC-Demo Host Network" for cfg_node in NW_NODES: self.create_node(cfg_node) for cfg_link in NW_BIDIR_LINKS: self.create_link(cfg_link['src'][0], cfg_link['src'][1], cfg_link['dest'][0], cfg_link['dest'][1]) self.create_link(cfg_link['src'][1], cfg_link['src'][0], cfg_link['dest'][1], cfg_link['dest'][0]) return self.topology
buffer.append(line) # gather lines else: outf.write(line) if __name__ == "__main__": model = RwYang.Model.create_libyang() model.load_schema_ypbc(RwTl.get_schema()) # create logger logger = logging.getLogger('Provider Network Topology') logger.setLevel(logging.DEBUG) logging.basicConfig(level=logging.DEBUG) logger.info('Creating an instance of Provider Network Topology') nwtop = RwTl.YangData_IetfNetwork() # Setup L2 topology l2top = MyL2Topology(nwtop, logger) l2top.setup_all() # Setup Provider network topology provtop = MyProvTopology(nwtop, l2top, logger) provtop.setup_all() print("Converting to XML") # Convert l2nw network to XML xml_str = nwtop.to_xml_v2(model) tree = etree.XML(xml_str) xml_file = "/tmp/stacked_provtop.xml" xml_formatted_file = "/tmp/stacked_provtop2.xml"