From 7a32c18b2fb3f220f099218871ba29115ef31ee9 Mon Sep 17 00:00:00 2001 From: Ross Brattain Date: Sun, 21 May 2017 21:07:50 -0700 Subject: add network info to topology we need to know which network each port is connected to so we can find VLAN or VXLAN ID. To do this we implement a new method for Contexts, Context.get_network(). This method is similar to Context.get_server(), it searches for a given network name in all the contexts. From this we generate a context_cfg["networks"] dict that stores all the network info for the nodes in the scenario. Then when we generate the topology for VNFD, we can lookup a given network by the vld_id and get the network_type, segmentation_id, etc. Then if we need to for example generated traffic on a given VLAN or VXLAN, we have this info available. Define default nd_route_tbl for ACL VNF we need default empty nd_route_tbl for IPv6 route. Change-Id: I9f9cfbd6acabeb4ae4675ca7354390efa57b29e7 Signed-off-by: Ross Brattain Signed-off-by: Edward MacGillivray --- tests/unit/benchmark/contexts/test_standalone.py | 45 ++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'tests/unit/benchmark/contexts/test_standalone.py') diff --git a/tests/unit/benchmark/contexts/test_standalone.py b/tests/unit/benchmark/contexts/test_standalone.py index 687ef7305..a6fd776e8 100644 --- a/tests/unit/benchmark/contexts/test_standalone.py +++ b/tests/unit/benchmark/contexts/test_standalone.py @@ -129,3 +129,48 @@ class StandaloneContextTestCase(unittest.TestCase): curr_path = os.path.dirname(os.path.abspath(__file__)) file_path = os.path.join(curr_path, filename) return file_path + + def test__get_network(self): + network1 = { + 'name': 'net_1', + 'vld_id': 'vld111', + 'segmentation_id': 'seg54', + 'network_type': 'type_a', + 'physical_network': 'phys', + } + network2 = { + 'name': 'net_2', + 'vld_id': 'vld999', + } + self.test_context.networks = { + 'a': network1, + 'b': network2, + } + + attr_name = None + self.assertIsNone(self.test_context._get_network(attr_name)) + + attr_name = {} + self.assertIsNone(self.test_context._get_network(attr_name)) + + attr_name = {'vld_id': 'vld777'} + self.assertIsNone(self.test_context._get_network(attr_name)) + + attr_name = 'vld777' + self.assertIsNone(self.test_context._get_network(attr_name)) + + attr_name = {'vld_id': 'vld999'} + expected = { + "name": 'net_2', + "vld_id": 'vld999', + "segmentation_id": None, + "network_type": None, + "physical_network": None, + } + result = self.test_context._get_network(attr_name) + self.assertDictEqual(result, expected) + + attr_name = 'a' + expected = network1 + result = self.test_context._get_network(attr_name) + self.assertDictEqual(result, expected) -- cgit 1.2.3-korg