From 9e3f6bd7080c1b39b51047a97a9f0907d8658d05 Mon Sep 17 00:00:00 2001 From: John O Loughlin Date: Thu, 15 Nov 2018 11:19:37 +0000 Subject: Add option to allow user to pass vpe_script Add option to allow user to pass their own vpe_script vpe_script will be auto-generated by default. To use your own config file use the 'script' parameter in the config file vnf_config: { file: './vpe_config/vpe_config_2_ports', action_bulk_file: './vpe_config/action_bulk_512.txt', full_tm_profile_file: './vpe_config/full_tm_profile_10G.cfg', script_file: './vpe_config/vpe_script_sample } JIRA: YARDSTICK-1525 Change-Id: Ie23e5705f4c0475e858be73b8a504a7df8898828 Signed-off-by: John O Loughlin --- yardstick/network_services/vnf_generic/vnf/sample_vnf.py | 4 ++-- yardstick/network_services/vnf_generic/vnf/vpe_vnf.py | 16 ++++++++++++---- 2 files changed, 14 insertions(+), 6 deletions(-) (limited to 'yardstick') diff --git a/yardstick/network_services/vnf_generic/vnf/sample_vnf.py b/yardstick/network_services/vnf_generic/vnf/sample_vnf.py index 673344f4e..1cb5cdd8f 100644 --- a/yardstick/network_services/vnf_generic/vnf/sample_vnf.py +++ b/yardstick/network_services/vnf_generic/vnf/sample_vnf.py @@ -180,7 +180,7 @@ class DpdkVnfSetupEnvHelper(SetupEnvHelper): """No actions/rules (flows) by default""" return None - def _build_pipeline_kwargs(self, cfg_file=None): + def _build_pipeline_kwargs(self, cfg_file=None, script=None): tool_path = self.ssh_helper.provision_tool(tool_file=self.APP_NAME) # count the number of actual ports in the list of pairs # remove duplicate ports @@ -201,7 +201,7 @@ class DpdkVnfSetupEnvHelper(SetupEnvHelper): self.pipeline_kwargs = { 'cfg_file': cfg_file if cfg_file else self.CFG_CONFIG, - 'script': self.CFG_SCRIPT, + 'script': script if script else self.CFG_SCRIPT, 'port_mask_hex': ports_mask_hex, 'tool_path': tool_path, 'hwlb': hwlb, diff --git a/yardstick/network_services/vnf_generic/vnf/vpe_vnf.py b/yardstick/network_services/vnf_generic/vnf/vpe_vnf.py index 349ef7888..dd3221386 100644 --- a/yardstick/network_services/vnf_generic/vnf/vpe_vnf.py +++ b/yardstick/network_services/vnf_generic/vnf/vpe_vnf.py @@ -106,6 +106,7 @@ class VpeApproxSetupEnvHelper(DpdkVnfSetupEnvHelper): action_bulk_file = vnf_cfg.get('action_bulk_file', '/tmp/action_bulk_512.txt') full_tm_profile_file = vnf_cfg.get('full_tm_profile_file', '/tmp/full_tm_profile_10G.cfg') config_file = vnf_cfg.get('file', '/tmp/vpe_config') + script_file = vnf_cfg.get('script_file', None) vpe_vars = { "bin_path": self.ssh_helper.bin_path, "socket": self.socket, @@ -113,8 +114,16 @@ class VpeApproxSetupEnvHelper(DpdkVnfSetupEnvHelper): self._build_vnf_ports() vpe_conf = ConfigCreate(self.vnfd_helper, self.socket) + if script_file is None: + # autogenerate vpe_script if not given + vpe_script = vpe_conf.generate_vpe_script(self.vnfd_helper.interfaces) + script_file = self.CFG_SCRIPT + else: + with utils.open_relative_file(script_file, task_path) as handle: + vpe_script = handle.read() + config_basename = posixpath.basename(config_file) - script_basename = posixpath.basename(self.CFG_SCRIPT) + script_basename = posixpath.basename(script_file) with utils.open_relative_file(action_bulk_file, task_path) as handle: action_bulk = handle.read() @@ -125,8 +134,6 @@ class VpeApproxSetupEnvHelper(DpdkVnfSetupEnvHelper): with utils.open_relative_file(config_file, task_path) as handle: vpe_config = handle.read() - # vpe_script needs to be autogenerated - vpe_script = vpe_conf.generate_vpe_script(self.vnfd_helper.interfaces) # upload the 4 config files to the target server self.ssh_helper.upload_config_file(config_basename, vpe_config.format(**vpe_vars)) self.ssh_helper.upload_config_file(script_basename, vpe_script.format(**vpe_vars)) @@ -138,7 +145,8 @@ class VpeApproxSetupEnvHelper(DpdkVnfSetupEnvHelper): LOG.info("Provision and start the %s", self.APP_NAME) LOG.info(config_file) LOG.info(self.CFG_SCRIPT) - self._build_pipeline_kwargs(cfg_file='/tmp/' + config_basename) + self._build_pipeline_kwargs(cfg_file='/tmp/' + config_basename, + script='/tmp/' + script_basename) return self.PIPELINE_COMMAND.format(**self.pipeline_kwargs) -- cgit 1.2.3-korg