add yardstick iruya 9.0.0 release notes
[yardstick.git] / yardstick / network_services / vnf_generic / vnf / tg_prox.py
1 # Copyright (c) 2017-2019 Intel Corporation
2 #
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
6 #
7 #      http://www.apache.org/licenses/LICENSE-2.0
8 #
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.
14
15 import logging
16 import copy
17
18 from yardstick.network_services.utils import get_nsb_option
19 from yardstick.network_services.vnf_generic.vnf.prox_vnf import ProxApproxVnf
20 from yardstick.network_services.vnf_generic.vnf.sample_vnf import SampleVNFTrafficGen
21
22 LOG = logging.getLogger(__name__)
23
24
25 class ProxTrafficGen(SampleVNFTrafficGen):
26
27     APP_NAME = 'ProxTG'
28     PROX_MODE = "Traffic Gen"
29     LUA_PARAMETER_NAME = "gen"
30     WAIT_TIME = 1
31
32     def __init__(self, name, vnfd, setup_env_helper_type=None,
33                  resource_helper_type=None):
34         vnfd_cpy = copy.deepcopy(vnfd)
35         super(ProxTrafficGen, self).__init__(name, vnfd_cpy)
36
37         self._vnf_wrapper = ProxApproxVnf(
38             name, vnfd, setup_env_helper_type, resource_helper_type)
39         self.bin_path = get_nsb_option('bin_path', '')
40         self.name = self._vnf_wrapper.name
41         self.ssh_helper = self._vnf_wrapper.ssh_helper
42         self.setup_helper = self._vnf_wrapper.setup_helper
43         self.resource_helper = self._vnf_wrapper.resource_helper
44         self.scenario_helper = self._vnf_wrapper.scenario_helper
45
46         self.runs_traffic = True
47         self.traffic_finished = False
48         self._tg_process = None
49         self._traffic_process = None
50
51     def terminate(self):
52         self._vnf_wrapper.terminate()
53         super(ProxTrafficGen, self).terminate()
54
55     def instantiate(self, scenario_cfg, context_cfg):
56         self._vnf_wrapper.instantiate(scenario_cfg, context_cfg)
57         self._tg_process = self._vnf_wrapper._vnf_process
58
59     def wait_for_instantiate(self):
60         self._vnf_wrapper.wait_for_instantiate()