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 test_change_network_link_dest_tp(self): """ Test: Change L2 link attributes """ logger.info("SdnTopStoreTest: Change network link dest-tp") # Create initial state self.link1 = self.new_l2net.link.add() self.link1.link_id = "Link1" self.link1.source.source_node = self.src_node.node_id self.link1.source.source_tp = self.tp1.tp_id self.link1.destination.dest_node = self.dest_node.node_id self.link1.destination.dest_tp = self.tp2.tp_id self.link1.l2_link_attributes.name = "Link L2 name" self.link1.l2_link_attributes.rate = 10000 self._nwtopdata_store.update_network("L2HostNetwork-1", self.new_l2net) # Verify initial state nw = self._nwtopdata_store.get_network("L2HostNetwork-1") self.assertIsNotNone(nw) self.assertEqual(nw.network_id, "L2HostNetwork-1") self.assertEqual(len(self._nwtopdata_store._networks), 1) self.assertEqual(len(nw.node), NUM_NODES_L2_NW + 2) self.assertEqual(nw.node[NUM_NODES_L2_NW].node_id, "TempNode1") self.assertEqual(len(nw.node[NUM_NODES_L2_NW].termination_point), 1) self.assertEqual(nw.node[NUM_NODES_L2_NW].termination_point[0].tp_id, "TempTp1") self.assertEqual(nw.node[NUM_NODES_L2_NW + 1].node_id, "TempNode2") self.assertEqual( nw.node[NUM_NODES_L2_NW + 1].termination_point[0].tp_id, "TempTp2") self.assertEqual(nw.link[NUM_LINKS].link_id, "Link1") self.assertEqual(len(nw.link), NUM_LINKS + 1) self.assertEqual(nw.link[NUM_LINKS].l2_link_attributes.name, "Link L2 name") self.assertEqual(nw.link[NUM_LINKS].l2_link_attributes.rate, 10000) # Create test state self.test_l2net = RwTl.YangData_IetfNetwork_Network() self.test_l2net.network_id = "L2HostNetwork-1" self.link1 = self.test_l2net.link.add() self.link1.link_id = "Link1" # Changing dest node params self.link1.destination.dest_node = self.src_node.node_id self.link1.destination.dest_tp = self.tp1.tp_id self._nwtopdata_store.update_network("L2HostNetwork-1", self.test_l2net) # Verify test state nw = self._nwtopdata_store.get_network("L2HostNetwork-1") self.assertEqual(nw.network_id, "L2HostNetwork-1") self.assertEqual(nw.link[NUM_LINKS].destination.dest_node, self.src_node.node_id)
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")