aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDeepak S <deepak.s@linux.intel.com>2017-09-21 22:13:09 -0700
committerRoss Brattain <ross.b.brattain@intel.com>2017-10-17 08:22:17 -0700
commite6c924052f12782de6ee79d3b01a2bae4d505f0f (patch)
treea2083c5088f28343446159413f78b38d5a6933ac
parentc270be42cde9e26018809fef35e401729be77eb1 (diff)
Enable static cgnapt functionality.
Change-Id: Ie770ca69ebdc66589ed6ca5c25bfc9a75afb8938 Signed-off-by: Deepak S <deepak.s@linux.intel.com>
-rw-r--r--samples/vnf_samples/traffic_profiles/ipv4_throughput_cgnapt.yaml4
-rw-r--r--tests/unit/network_services/helpers/test_samplevnf_helper.py2
-rw-r--r--tests/unit/network_services/vnf_generic/vnf/test_cgnapt_vnf.py7
-rw-r--r--tests/unit/network_services/vnf_generic/vnf/test_sample_vnf.py9
-rw-r--r--yardstick/network_services/vnf_generic/vnf/cgnapt_vnf.py54
-rw-r--r--yardstick/network_services/vnf_generic/vnf/sample_vnf.py7
6 files changed, 34 insertions, 49 deletions
diff --git a/samples/vnf_samples/traffic_profiles/ipv4_throughput_cgnapt.yaml b/samples/vnf_samples/traffic_profiles/ipv4_throughput_cgnapt.yaml
index 4aa78e713..61cbd4e4e 100644
--- a/samples/vnf_samples/traffic_profiles/ipv4_throughput_cgnapt.yaml
+++ b/samples/vnf_samples/traffic_profiles/ipv4_throughput_cgnapt.yaml
@@ -94,6 +94,6 @@ downlink_0:
ttl: 32
dscp: 0
outer_l4:
- srcport: "{{get(flow, 'flow.dst_port_0', '1234-4321') }}"
- dstport: "{{get(flow, 'flow.src_port_0', '2001-4001') }}"
+ srcport: "{{get(flow, 'flow.dst_port_0', '1-65535') }}"
+ dstport: "{{get(flow, 'flow.src_port_0', '1-65535') }}"
count: "{{get(flow, 'flow.count', '1') }}"
diff --git a/tests/unit/network_services/helpers/test_samplevnf_helper.py b/tests/unit/network_services/helpers/test_samplevnf_helper.py
index bff3a7722..05acdfaa9 100644
--- a/tests/unit/network_services/helpers/test_samplevnf_helper.py
+++ b/tests/unit/network_services/helpers/test_samplevnf_helper.py
@@ -797,7 +797,7 @@ class TestMultiPortConfig(unittest.TestCase):
def test_generate_arp_route_tbl(self, *_):
topology_file = mock.Mock()
config_tpl = mock.Mock()
- tmp_file = mock.Mock()
+ tmp_file = ""
vnfd_mock = mock.MagicMock()
vnfd_mock.port_num.side_effect = ['32', '1', '987']
vnfd_mock.find_interface.side_effect = [
diff --git a/tests/unit/network_services/vnf_generic/vnf/test_cgnapt_vnf.py b/tests/unit/network_services/vnf_generic/vnf/test_cgnapt_vnf.py
index b0ef1da91..832509ea7 100644
--- a/tests/unit/network_services/vnf_generic/vnf/test_cgnapt_vnf.py
+++ b/tests/unit/network_services/vnf_generic/vnf/test_cgnapt_vnf.py
@@ -72,13 +72,12 @@ link 1 up
self.assertNotIn("This is a header", out)
def test__get_cgnapt_config(self):
- vnfd_helper = mock.Mock()
+ vnfd_helper = mock.MagicMock()
vnfd_helper.port_pairs.uplink_ports = [{"name": 'a'}, {"name": "b"}, {"name": "c"}]
helper = CgnaptApproxSetupEnvHelper(vnfd_helper, mock.Mock(), mock.Mock())
- helper._get_ports_gateway = mock.Mock(side_effect=[3, 5, 2])
- result = helper._get_cgnapt_config([{"name": 'a'}, {}, {"name": "b"}, {}, {"name": "c"}])
- self.assertEqual(result, [3, 5, 2])
+ result = helper._get_cgnapt_config()
+ self.assertIsNotNone(result)
def test_scale(self):
helper = CgnaptApproxSetupEnvHelper(mock.Mock(), mock.Mock(), mock.Mock())
diff --git a/tests/unit/network_services/vnf_generic/vnf/test_sample_vnf.py b/tests/unit/network_services/vnf_generic/vnf/test_sample_vnf.py
index c41da2c45..6c102ed59 100644
--- a/tests/unit/network_services/vnf_generic/vnf/test_sample_vnf.py
+++ b/tests/unit/network_services/vnf_generic/vnf/test_sample_vnf.py
@@ -360,15 +360,6 @@ class TestSetupEnvHelper(unittest.TestCase):
with self.assertRaises(NotImplementedError):
setup_env_helper.build_config()
- def test__get_ports_gateway(self):
- vnfd_helper = VnfdHelper(self.VNFD_0)
- setup_env_helper = SetupEnvHelper(vnfd_helper, mock.Mock(), mock.Mock())
- result = setup_env_helper._get_ports_gateway("xe0")
- self.assertEqual(result, "152.16.100.20")
-
- result = setup_env_helper._get_ports_gateway("xe123")
- self.assertIsNone(result)
-
def test_setup_vnf_environment(self):
setup_env_helper = SetupEnvHelper(mock.Mock(), mock.Mock(), mock.Mock())
self.assertIsNone(setup_env_helper.setup_vnf_environment())
diff --git a/yardstick/network_services/vnf_generic/vnf/cgnapt_vnf.py b/yardstick/network_services/vnf_generic/vnf/cgnapt_vnf.py
index b5072c194..53f73b4d7 100644
--- a/yardstick/network_services/vnf_generic/vnf/cgnapt_vnf.py
+++ b/yardstick/network_services/vnf_generic/vnf/cgnapt_vnf.py
@@ -14,6 +14,7 @@
from __future__ import absolute_import
import logging
+import time
from yardstick.network_services.vnf_generic.vnf.sample_vnf import SampleVNF, DpdkVnfSetupEnvHelper
@@ -64,14 +65,12 @@ class CgnaptApproxSetupEnvHelper(DpdkVnfSetupEnvHelper):
def scale(self, flavor=""):
raise NotImplementedError
- def _get_cgnapt_config(self, interfaces=None):
- # TODO: static CGNAPT is broken, don't use it
- if interfaces is None:
- interfaces = self.vnfd_helper.interfaces
-
+ def _get_cgnapt_config(self):
# fixme: Get private port and gateway from port list
uplink_ports = self.vnfd_helper.port_pairs.uplink_ports
- return [self._get_ports_gateway(intf["name"]) for intf in uplink_ports]
+ return \
+ [self.vnfd_helper.find_interface(name=intf)["virtual-interface"]['dst_ip']
+ for intf in uplink_ports]
class CgnaptApproxVnf(SampleVNF):
@@ -98,23 +97,26 @@ class CgnaptApproxVnf(SampleVNF):
if self.scenario_helper.options.get('napt', 'static') != 'static':
return
- # ip_iter = self.setup_helper._generate_ip_from_pool("152.16.40.10")
- # gw_ips = self.setup_helper._get_cgnapt_config()
- # if self.scenario_helper.vnf_cfg.get("lb_config", "SW") == 'HW':
- # pipeline = self.setup_helper.HW_DEFAULT_CORE
- # offset = 3
- # else:
- # pipeline = self.setup_helper.SW_DEFAULT_CORE - 1
- # offset = 0
- #
- # worker_threads = int(self.scenario_helper.vnf_cfg["worker_threads"])
- # # p <pipeline id> entry addm <prv_ipv4/6> prvport> <pub_ip> <pub_port> <phy_port> <ttl>
- # # <no_of_entries> <end_prv_port> <end_pub_port>
- # cmd_template = "p {0} entry addm {1} 1 {2} 1 0 32 65535 65535 65535"
- # for gw, ip in zip(gw_ips, ip_iter):
- # cmd = cmd_template.format(pipeline, gw, ip)
- # pipeline += worker_threads
- # pipeline += offset
- # self.vnf_execute(cmd)
- #
- # time.sleep(WAIT_FOR_STATIC_NAPT)
+ flow = self.scenario_helper.all_options.get('flow', {})
+ public_ip = flow.get('public_ip', ['152.16.40.10']).pop()
+ ip_iter = self.setup_helper._generate_ip_from_pool(public_ip)
+ gw_ips = self.setup_helper._get_cgnapt_config()
+ if self.scenario_helper.vnf_cfg.get("lb_config", "SW") == 'HW':
+ pipeline = self.setup_helper.HW_DEFAULT_CORE
+ offset = 3
+ else:
+ pipeline = self.setup_helper.SW_DEFAULT_CORE - 1
+ offset = 0
+
+ worker_threads = int(self.scenario_helper.vnf_cfg["worker_threads"])
+ # p <pipeline id> entry addm <prv_ipv4/6> prvport> <pub_ip> <pub_port> <phy_port> <ttl>
+ # <no_of_entries> <end_prv_port> <end_pub_port>
+ cmd_template = "p {0} entry addm {1} 1 {2} 1 0 32 65535 65535 65535"
+ for gw, ip in zip(gw_ips, ip_iter):
+ cmd = cmd_template.format(pipeline, gw, ip)
+ pipeline += worker_threads
+ pipeline += offset
+ LOG.info(cmd)
+ self.vnf_execute(cmd)
+
+ time.sleep(WAIT_FOR_STATIC_NAPT)
diff --git a/yardstick/network_services/vnf_generic/vnf/sample_vnf.py b/yardstick/network_services/vnf_generic/vnf/sample_vnf.py
index 06f259685..b5cf03477 100644
--- a/yardstick/network_services/vnf_generic/vnf/sample_vnf.py
+++ b/yardstick/network_services/vnf_generic/vnf/sample_vnf.py
@@ -108,13 +108,6 @@ class SetupEnvHelper(object):
self.ssh_helper = ssh_helper
self.scenario_helper = scenario_helper
- def _get_ports_gateway(self, name):
- routing_table = self.vnfd_helper.vdu0.get('routing_table', [])
- for route in routing_table:
- if name == route['if']:
- return route['gateway']
- return None
-
def build_config(self):
raise NotImplementedError