1 # Copyright (c) 2017 Intel Corporation
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
15 from __future__ import absolute_import
19 from yardstick.network_services.utils import get_nsb_option
20 from yardstick.network_services.vnf_generic.vnf.prox_vnf import ProxApproxVnf
21 from yardstick.network_services.vnf_generic.vnf.sample_vnf import SampleVNFTrafficGen
23 LOG = logging.getLogger(__name__)
26 class ProxTrafficGen(SampleVNFTrafficGen):
29 PROX_MODE = "Traffic Gen"
30 LUA_PARAMETER_NAME = "gen"
33 def __init__(self, name, vnfd, setup_env_helper_type=None, resource_helper_type=None):
34 # don't call superclass, use custom wrapper of ProxApproxVnf
35 self._vnf_wrapper = ProxApproxVnf(name, vnfd, setup_env_helper_type, resource_helper_type)
36 self.bin_path = get_nsb_option('bin_path', '')
37 self.name = self._vnf_wrapper.name
38 self.ssh_helper = self._vnf_wrapper.ssh_helper
39 self.setup_helper = self._vnf_wrapper.setup_helper
40 self.resource_helper = self._vnf_wrapper.resource_helper
41 self.scenario_helper = self._vnf_wrapper.scenario_helper
43 self.runs_traffic = True
44 self.traffic_finished = False
45 self._tg_process = None
46 self._traffic_process = None
49 self._vnf_wrapper.terminate()
50 super(ProxTrafficGen, self).terminate()
52 def instantiate(self, scenario_cfg, context_cfg):
53 self._vnf_wrapper.instantiate(scenario_cfg, context_cfg)
54 self._tg_process = self._vnf_wrapper._vnf_process
56 def wait_for_instantiate(self):
57 self._vnf_wrapper.wait_for_instantiate()