Fix vPE VNF characterization issues. 99/42999/4
authorDeepak S <deepak.s@linux.intel.com>
Fri, 22 Sep 2017 09:54:32 +0000 (02:54 -0700)
committerDeepak S <deepak.s@linux.intel.com>
Mon, 25 Sep 2017 21:13:58 +0000 (14:13 -0700)
Change-Id: Ia934128777d2839f6d2b940857c266fc3e2bd4a1
Signed-off-by: Deepak S <deepak.s@linux.intel.com>
samples/vnf_samples/nsut/vpe/vpe_vnf_topology-3node.yaml
samples/vnf_samples/nsut/vpe/vpe_vnf_topology.yaml
samples/vnf_samples/nsut/vpe/vpe_vnf_topology_ixia.yaml
samples/vnf_samples/nsut/vpe/vpe_vnf_topology_ixload.yaml
samples/vnf_samples/traffic_profiles/ipv4_throughput_vpe.yaml
tests/unit/network_services/vnf_generic/vnf/test_vpe_vnf.py
yardstick/network_services/vnf_generic/vnf/vpe_vnf.py

index 8a1d335..7bd4bff 100644 (file)
@@ -30,7 +30,7 @@ nsd:nsd-catalog:
             VNF model: ../../vnf_descriptors/udp_replay_vnf.yaml       #tg_vpe_upstream.yaml   #VPE VNF
 
         vld:
-        -   id: uplink
+        -   id: uplink_0
             name: tg__0 to vnf__0 link 1
             type: ELAN
             vnfd-connection-point-ref:
@@ -41,7 +41,7 @@ nsd:nsd-catalog:
                 vnfd-connection-point-ref: xe0
                 vnfd-id-ref: vnf__0                  #VNF
 
-        -   id: downlink
+        -   id: downlink_0
             name: vnf__0 to tg__1 link 2
             type: ELAN
             vnfd-connection-point-ref:
index 5ad4502..4ade967 100644 (file)
@@ -27,7 +27,7 @@ nsd:nsd-catalog:
             VNF model: ../../vnf_descriptors/vpe_vnf.yaml    #tg_l3fwd.yaml #tg_trex_tpl.yaml       #TREX
 
         vld:
-        -   id: uplink
+        -   id: uplink_0
             name: tg__0 to vnf__0 link 1
             type: ELAN
             vnfd-connection-point-ref:
@@ -38,7 +38,7 @@ nsd:nsd-catalog:
                 vnfd-connection-point-ref: xe0
                 vnfd-id-ref: vnf__0                  #VNF
 
-        -   id: downlink
+        -   id: downlink_0
             name: vnf__0 to tg__0 link 2
             type: ELAN
             vnfd-connection-point-ref:
index 315a308..d7e11a6 100644 (file)
@@ -27,7 +27,7 @@ nsd:nsd-catalog:
             VNF model: ../../vnf_descriptors/vpe_vnf.yaml
 
         vld:
-        -   id: uplink
+        -   id: uplink_0
             name: tg__0 to vnf__0 link 1
             type: ELAN
             vnfd-connection-point-ref:
@@ -38,7 +38,7 @@ nsd:nsd-catalog:
                 vnfd-connection-point-ref: xe0
                 vnfd-id-ref: vnf__0                  #VNF
 
-        -   id: downlink
+        -   id: downlink_0
             name: vnf__0 to tg__0 link 2
             type: ELAN
             vnfd-connection-point-ref:
index aa1dc0d..3d93f79 100644 (file)
@@ -27,7 +27,7 @@ nsd:nsd-catalog:
             VNF model: ../../vnf_descriptors/vpe_vnf.yaml
 
         vld:
-        -   id: uplink
+        -   id: uplink_0
             name: tg__0 to vnf__0 link 1
             type: ELAN
             vnfd-connection-point-ref:
@@ -38,7 +38,7 @@ nsd:nsd-catalog:
                 vnfd-connection-point-ref: xe0
                 vnfd-id-ref: vnf__0                  #VNF
 
-        -   id: downlink
+        -   id: downlink_0
             name: vnf__0 to tg__0 link 2
             type: ELAN
             vnfd-connection-point-ref:
index f42db93..8bac324 100644 (file)
@@ -131,15 +131,15 @@ uplink_1:
 
         outer_l3v4:
             proto: "tcp"
-            srcip4: "{{get(flow, 'flow.src_ip1', '192.168.0.0-192.168.255.255') }}"
-            dstip4: "{{get(flow, 'flow.dst_ip1', '192.16.0.0-192.16.0.31') }}"
+            srcip4: "{{get(flow, 'flow.src_ip_1', '192.168.0.0-192.168.255.255') }}"
+            dstip4: "{{get(flow, 'flow.dst_ip_1', '192.16.0.0-192.16.0.31') }}"
             count: "{{get(flow, 'flow.count', '1') }}"
             ttl: 32
             dscp: 32
 
         outer_l4:
-            srcport: "{{get(flow, 'flow.src_port1', '0') }}"
-            dstport: "{{get(flow, 'flow.dst_port1', '0') }}"
+            srcport: "{{get(flow, 'flow.src_port_1', '0') }}"
+            dstport: "{{get(flow, 'flow.dst_port_1', '0') }}"
             count: "{{get(flow, 'flow.count', '1') }}"
 downlink_1:
       ipv4:
@@ -155,13 +155,13 @@ downlink_1:
 
         outer_l3v4:
             proto: "tcp"
-            srcip4: "{{get(flow, 'flow.dst_ip1', '192.16.0.0-192.16.0.31') }}"
-            dstip4: "{{get(flow, 'flow.src_ip1', '192.168.0.0-192.168.255.255') }}"
+            srcip4: "{{get(flow, 'flow.dst_ip_1', '192.16.0.0-192.16.0.31') }}"
+            dstip4: "{{get(flow, 'flow.src_ip_1', '192.168.0.0-192.168.255.255') }}"
             count: "{{get(flow, 'flow.count', '1') }}"
             ttl: 32
             dscp: 32
 
         outer_l4:
-            srcport: "{{get(flow, 'flow.dst_port1', '0') }}"
-            dstport: "{{get(flow, 'flow.src_port1', '0') }}"
+            srcport: "{{get(flow, 'flow.dst_port_1', '0') }}"
+            dstport: "{{get(flow, 'flow.src_port_1', '0') }}"
             count: "{{get(flow, 'flow.count', '1') }}"
index 757109d..3813aaa 100644 (file)
@@ -25,6 +25,7 @@ from multiprocessing import Process, Queue
 
 from tests.unit import STL_MOCKS
 from yardstick.network_services.vnf_generic.vnf.base import QueueFileWrapper
+from yardstick.network_services.vnf_generic.vnf.base import VnfdHelper
 
 
 SSH_HELPER = 'yardstick.network_services.vnf_generic.vnf.sample_vnf.VnfSshHelper'
@@ -55,14 +56,117 @@ get_file_abspath = MODULE_PATH.get_path
 
 class TestConfigCreate(unittest.TestCase):
 
+    VNFD_0 = {
+        'short-name': 'VpeVnf',
+        'vdu': [
+            {
+                'routing_table': [
+                    {
+                        'network': '152.16.100.20',
+                        'netmask': '255.255.255.0',
+                        'gateway': '152.16.100.20',
+                        'if': 'xe0'
+                    },
+                    {
+                        'network': '152.16.40.20',
+                        'netmask': '255.255.255.0',
+                        'gateway': '152.16.40.20',
+                        'if': 'xe1'
+                    },
+                ],
+                'description': 'VPE approximation using DPDK',
+                'name': 'vpevnf-baremetal',
+                'nd_route_tbl': [
+                    {
+                        'network': '0064:ff9b:0:0:0:0:9810:6414',
+                        'netmask': '112',
+                        'gateway': '0064:ff9b:0:0:0:0:9810:6414',
+                        'if': 'xe0'
+                    },
+                    {
+                        'network': '0064:ff9b:0:0:0:0:9810:2814',
+                        'netmask': '112',
+                        'gateway': '0064:ff9b:0:0:0:0:9810:2814',
+                        'if': 'xe1'
+                    },
+                ],
+                'id': 'vpevnf-baremetal',
+                'external-interface': [
+                    {
+                        'virtual-interface': {
+                            'dst_mac': '00:00:00:00:00:03',
+                            'vpci': '0000:05:00.0',
+                            'local_ip': '152.16.100.19',
+                            'type': 'PCI-PASSTHROUGH',
+                            'netmask': '255.255.255.0',
+                            'dpdk_port_num': 0,
+                            'bandwidth': '10 Gbps',
+                            'dst_ip': '152.16.100.20',
+                            'local_mac': '00:00:00:00:00:01',
+                            'vld_id': 'uplink_0',
+                            'ifname': 'xe0',
+                        },
+                        'vnfd-connection-point-ref': 'xe0',
+                        'name': 'xe0'
+                    },
+                    {
+                        'virtual-interface': {
+                            'dst_mac': '00:00:00:00:00:04',
+                            'vpci': '0000:05:00.1',
+                            'local_ip': '152.16.40.19',
+                            'type': 'PCI-PASSTHROUGH',
+                            'netmask': '255.255.255.0',
+                            'dpdk_port_num': 1,
+                            'bandwidth': '10 Gbps',
+                            'dst_ip': '152.16.40.20',
+                            'local_mac': '00:00:00:00:00:02',
+                            'vld_id': 'downlink_0',
+                            'ifname': 'xe1',
+                        },
+                        'vnfd-connection-point-ref': 'xe1',
+                        'name': 'xe1'
+                    },
+                ],
+            },
+        ],
+        'description': 'Vpe approximation using DPDK',
+        'mgmt-interface': {
+            'vdu-id': 'vpevnf-baremetal',
+            'host': '1.1.1.1',
+            'password': 'r00t',
+            'user': 'root',
+            'ip': '1.1.1.1'
+        },
+        'benchmark': {
+            'kpi': [
+                'packets_in',
+                'packets_fwd',
+                'packets_dropped',
+            ],
+        },
+        'connection-point': [
+            {
+                'type': 'VPORT',
+                'name': 'xe0',
+            },
+            {
+                'type': 'VPORT',
+                'name': 'xe1',
+            },
+        ],
+        'id': 'VpeApproxVnf', 'name': 'VPEVnfSsh'
+    }
+
     def test___init__(self):
-        config_create = ConfigCreate([0], [1], 2)
-        self.assertEqual(config_create.uplink_ports, [0])
-        self.assertEqual(config_create.downlink_ports, [1])
+        vnfd_helper = VnfdHelper(self.VNFD_0)
+        config_create = ConfigCreate(vnfd_helper, 2)
+        self.assertEqual(config_create.uplink_ports, ['xe0'])
+        self.assertEqual(config_create.downlink_ports, ['xe1'])
         self.assertEqual(config_create.socket, 2)
 
     def test_vpe_initialize(self):
-        config_create = ConfigCreate([0], [1], 2)
+        vnfd_helper = VnfdHelper(self.VNFD_0)
+        config_create = ConfigCreate(vnfd_helper, 2)
         config = configparser.ConfigParser()
         config_create.vpe_initialize(config)
         self.assertEqual(config.get('EAL', 'log_level'), '0')
@@ -72,14 +176,16 @@ class TestConfigCreate(unittest.TestCase):
         self.assertEqual(config.get('MEMPOOL1', 'pool_size'), '2M')
 
     def test_vpe_rxq(self):
-        config_create = ConfigCreate([0], [1, 2], 3)
+        vnfd_helper = VnfdHelper(self.VNFD_0)
+        config_create = ConfigCreate(vnfd_helper, 2)
         config = configparser.ConfigParser()
+        config_create.downlink_ports = ['xe0']
         config_create.vpe_rxq(config)
-        self.assertEqual(config.get('RXQ1.0', 'mempool'), 'MEMPOOL1')
-        self.assertEqual(config.get('RXQ2.0', 'mempool'), 'MEMPOOL1')
+        self.assertEqual(config.get('RXQ0.0', 'mempool'), 'MEMPOOL1')
 
     def test_get_sink_swq(self):
-        config_create = ConfigCreate([0], [1], 2)
+        vnfd_helper = VnfdHelper(self.VNFD_0)
+        config_create = ConfigCreate(vnfd_helper, 2)
         config = configparser.ConfigParser()
         config.add_section('PIPELINE0')
         config.set('PIPELINE0', 'key1', 'value1')
@@ -96,15 +202,26 @@ class TestConfigCreate(unittest.TestCase):
         self.assertEqual(config_create.get_sink_swq(config, 'PIPELINE0', 'key5', 5), 'SWQ0 SINK1')
 
     def test_generate_vpe_script(self):
-        vpe_config_vnf = ConfigCreate([0], [0], 0)
+        vnfd_helper = VnfdHelper(self.VNFD_0)
+        vpe_config_vnf = ConfigCreate(vnfd_helper, 2)
         intf = [
             {
+                "name": 'xe1',
+                "virtual-interface": {
+                    "dst_ip": "1.1.1.1",
+                    "dst_mac": "00:00:00:00:00:00:02",
+                },
+            },
+            {
+                "name": 'xe2',
                 "virtual-interface": {
                     "dst_ip": "1.1.1.1",
                     "dst_mac": "00:00:00:00:00:00:02",
                 },
             },
         ]
+        vpe_config_vnf.downlink_ports = ['xe1']
+        vpe_config_vnf.uplink_ports = ['xe2']
         result = vpe_config_vnf.generate_vpe_script(intf)
         self.assertIsInstance(result, str)
         self.assertNotEqual(result, '')
@@ -132,7 +249,10 @@ class TestConfigCreate(unittest.TestCase):
             },
         ]
 
-        config_create = ConfigCreate(uplink_ports, downlink_ports, 23)
+        vnfd_helper = VnfdHelper(self.VNFD_0)
+        config_create = ConfigCreate(vnfd_helper, 23)
+        config_create.downlink_ports = ['xe1']
+        config_create.uplink_ports = ['xe1']
         curr_path = os.path.dirname(os.path.abspath(__file__))
         vpe_cfg = "samples/vnf_samples/nsut/vpe/vpe_config"
         vnf_cfg = os.path.join(curr_path, "../../../../..", vpe_cfg)
index cd4a008..5f1c4d4 100644 (file)
@@ -50,13 +50,14 @@ class ConfigCreate(object):
         config.set(tm_q, 'cfg', '/tmp/full_tm_profile_10G.cfg')
         return config
 
-    def __init__(self, uplink_ports, downlink_ports, socket):
+    def __init__(self, vnfd_helper, socket):
         super(ConfigCreate, self).__init__()
         self.sw_q = -1
         self.sink_q = -1
         self.n_pipeline = 1
-        self.uplink_ports = uplink_ports
-        self.downlink_ports = downlink_ports
+        self.vnfd_helper = vnfd_helper
+        self.uplink_ports = self.vnfd_helper.port_pairs.uplink_ports
+        self.downlink_ports = self.vnfd_helper.port_pairs.downlink_ports
         self.pipeline_per_port = 9
         self.socket = socket
 
@@ -77,7 +78,7 @@ class ConfigCreate(object):
 
     def vpe_rxq(self, config):
         for port in self.downlink_ports:
-            new_section = 'RXQ{0}.0'.format(port)
+            new_section = 'RXQ{0}.0'.format(self.vnfd_helper.port_num(port))
             config.add_section(new_section)
             config.set(new_section, 'mempool', 'MEMPOOL1')
 
@@ -102,7 +103,8 @@ class ConfigCreate(object):
             for k, v in parser.items(pipeline):
                 if k == "pktq_in":
                     if "RXQ" in v:
-                        value = "RXQ{0}.0".format(self.uplink_ports[index])
+                        port = self.vnfd_helper.port_num(self.uplink_ports[index])
+                        value = "RXQ{0}.0".format(port)
                     else:
                         value = self.get_sink_swq(parser, pipeline, k, index)
 
@@ -110,7 +112,8 @@ class ConfigCreate(object):
 
                 elif k == "pktq_out":
                     if "TXQ" in v:
-                        value = "TXQ{0}.0".format(self.downlink_ports[index])
+                        port = self.vnfd_helper.port_num(self.downlink_ports[index])
+                        value = "TXQ{0}.0".format(port)
                     else:
                         self.sw_q += 1
                         value = self.get_sink_swq(parser, pipeline, k, index)
@@ -131,23 +134,25 @@ class ConfigCreate(object):
             for k, v in parser.items(pipeline):
 
                 if k == "pktq_in":
+                    port = self.vnfd_helper.port_num(self.downlink_ports[index])
                     if "RXQ" not in v:
                         value = self.get_sink_swq(parser, pipeline, k, index)
                     elif "TM" in v:
-                        value = "RXQ{0}.0 TM{1}".format(self.downlink_ports[index], index)
+                        value = "RXQ{0}.0 TM{1}".format(port, index)
                     else:
-                        value = "RXQ{0}.0".format(self.downlink_ports[index])
+                        value = "RXQ{0}.0".format(port)
 
                     parser.set(pipeline, k, value)
 
                 if k == "pktq_out":
+                    port = self.vnfd_helper.port_num(self.uplink_ports[index])
                     if "TXQ" not in v:
                         self.sw_q += 1
                         value = self.get_sink_swq(parser, pipeline, k, index)
                     elif "TM" in v:
-                        value = "TXQ{0}.0 TM{1}".format(self.uplink_ports[index], index)
+                        value = "TXQ{0}.0 TM{1}".format(port, index)
                     else:
-                        value = "TXQ{0}.0".format(self.uplink_ports[index])
+                        value = "TXQ{0}.0".format(port)
 
                     parser.set(pipeline, k, value)
 
@@ -174,14 +179,19 @@ class ConfigCreate(object):
 
     def generate_vpe_script(self, interfaces):
         rules = PipelineRules(pipeline_id=1)
-        for priv_port, pub_port in zip(self.uplink_ports, self.downlink_ports):
-            priv_intf = interfaces[priv_port]["virtual-interface"]
-            pub_intf = interfaces[pub_port]["virtual-interface"]
+        for uplink_port, downlink_port in zip(self.uplink_ports, self.downlink_ports):
 
-            dst_port0_ip = priv_intf["dst_ip"]
-            dst_port1_ip = pub_intf["dst_ip"]
-            dst_port0_mac = priv_intf["dst_mac"]
-            dst_port1_mac = pub_intf["dst_mac"]
+            uplink_intf = \
+                next(intf["virtual-interface"] for intf in interfaces
+                     if intf["name"] == uplink_port)
+            downlink_intf = \
+                next(intf["virtual-interface"] for intf in interfaces
+                     if intf["name"] == downlink_port)
+
+            dst_port0_ip = uplink_intf["dst_ip"]
+            dst_port1_ip = downlink_intf["dst_ip"]
+            dst_port0_mac = uplink_intf["dst_mac"]
+            dst_port1_mac = downlink_intf["dst_mac"]
 
             rules.add_firewall_script(dst_port0_ip)
             rules.next_pipeline()
@@ -226,8 +236,7 @@ class VpeApproxSetupEnvHelper(DpdkVnfSetupEnvHelper):
         }
 
         self._build_vnf_ports()
-        vpe_conf = ConfigCreate(self.vnfd_helper.port_pairs.uplink_ports,
-                                self.vnfd_helper.port_pairs.downlink_ports, self.socket)
+        vpe_conf = ConfigCreate(self.vnfd_helper, self.socket)
         vpe_conf.create_vpe_config(self.scenario_helper.vnf_cfg)
 
         config_basename = posixpath.basename(self.CFG_CONFIG)