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")
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" with open(xml_file, "w") as f: f.write(xml_str) status = subprocess.call("xmllint --format " + xml_file + " > " +