diff options
author | Abhijit Sinha <abhijit.sinha@intel.com> | 2019-01-03 17:27:11 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@opnfv.org> | 2019-01-03 17:27:11 +0000 |
commit | 62fda8b9ec846747a6132c980f8e892b74de6d25 (patch) | |
tree | 801c70e1f295fe6c50f7cd68943af49f6351be33 | |
parent | 0ef21e67f84dfbb48230ad164041e867537ed331 (diff) | |
parent | 92d0631ed6dd48d7c323c4bf76350be6e920176f (diff) |
Merge "NSB support for [core x-y] NSB PROX NFVI configuration"
-rw-r--r-- | yardstick/network_services/vnf_generic/vnf/prox_helpers.py | 36 | ||||
-rw-r--r-- | yardstick/tests/unit/network_services/vnf_generic/vnf/test_prox_helpers.py | 78 |
2 files changed, 114 insertions, 0 deletions
diff --git a/yardstick/network_services/vnf_generic/vnf/prox_helpers.py b/yardstick/network_services/vnf_generic/vnf/prox_helpers.py index 5d980037a..cd3035ef8 100644 --- a/yardstick/network_services/vnf_generic/vnf/prox_helpers.py +++ b/yardstick/network_services/vnf_generic/vnf/prox_helpers.py @@ -870,6 +870,30 @@ class ProxDpdkVnfSetupEnvHelper(DpdkVnfSetupEnvHelper): file_str[1] = self.additional_files[base_name] return '"'.join(file_str) + def _make_core_list(self, inputStr): + + my_input = inputStr.split("core ", 1)[1] + ok_list = set() + + substrs = [x.strip() for x in my_input.split(',')] + for i in substrs: + try: + ok_list.add(int(i)) + + except ValueError: + try: + substr = [int(k.strip()) for k in i.split('-')] + if len(substr) > 1: + startstr = substr[0] + endstr = substr[len(substr) - 1] + for z in range(startstr, endstr + 1): + ok_list.add(z) + except ValueError: + LOG.error("Error in cores list ... resuming ") + return ok_list + + return ok_list + def generate_prox_config_file(self, config_path): sections = [] prox_config = ConfigParser(config_path, sections) @@ -889,6 +913,18 @@ class ProxDpdkVnfSetupEnvHelper(DpdkVnfSetupEnvHelper): if section_data[0] == "mac": section_data[1] = "hardware" + # adjust for range of cores + new_sections = [] + for section_name, section in sections: + if section_name.startswith('core') and section_name.find('$') == -1: + core_list = self._make_core_list(section_name) + for core in core_list: + new_sections.append(["core " + str(core), section]) + else: + new_sections.append([section_name, section]) + + sections = new_sections + # search for dst mac for _, section in sections: for section_data in section: diff --git a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_prox_helpers.py b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_prox_helpers.py index 31f08da3e..9a30fb9e9 100644 --- a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_prox_helpers.py +++ b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_prox_helpers.py @@ -1374,6 +1374,36 @@ class TestProxDpdkVnfSetupEnvHelper(unittest.TestCase): ['missing_addtional_file', 'dofile("nosuch")'], ], ], + [ + 'core 0', + [ + ['name', 'p0'] + ] + ], + [ + 'core 1-4', + [ + ['name', 'p1'] + ] + ], + [ + 'core 5,6', + [ + ['name', 'p2'] + ] + ], + [ + 'core xx', + [ + ['name', 'p3'] + ] + ], + [ + 'core $x', + [ + ['name', 'p4'] + ] + ] ] expected = [ @@ -1403,6 +1433,54 @@ class TestProxDpdkVnfSetupEnvHelper(unittest.TestCase): ['missing_addtional_file', 'dofile("nosuch")'], ], ], + [ + 'core 0', + [ + ['name', 'p0'] + ] + ], + [ + 'core 1', + [ + ['name', 'p1'] + ] + ], + [ + 'core 2', + [ + ['name', 'p1'] + ] + ], + [ + 'core 3', + [ + ['name', 'p1'] + ] + ], + [ + 'core 4', + [ + ['name', 'p1'] + ] + ], + [ + 'core 5', + [ + ['name', 'p2'] + ] + ], + [ + 'core 6', + [ + ['name', 'p2'] + ] + ], + [ + 'core $x', + [ + ['name', 'p4'] + ] + ] ] result = helper.generate_prox_config_file('/c/d/e') self.assertEqual(result, expected, str(result)) |