Create a SampleVNF MQ consumer class
[yardstick.git] / yardstick / network_services / vnf_generic / vnf / tg_prox.py
1 # Copyright (c) 2017 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 from __future__ import absolute_import
16
17 import logging
18
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
22
23 LOG = logging.getLogger(__name__)
24
25
26 class ProxTrafficGen(SampleVNFTrafficGen):
27
28     APP_NAME = 'ProxTG'
29     PROX_MODE = "Traffic Gen"
30     LUA_PARAMETER_NAME = "gen"
31     WAIT_TIME = 1
32
33     def __init__(self, name, vnfd, task_id, setup_env_helper_type=None,
34                  resource_helper_type=None):
35         # don't call superclass, use custom wrapper of ProxApproxVnf
36         self._vnf_wrapper = ProxApproxVnf(
37             name, vnfd, task_id, setup_env_helper_type, resource_helper_type)
38         self.bin_path = get_nsb_option('bin_path', '')
39         self.name = self._vnf_wrapper.name
40         self.ssh_helper = self._vnf_wrapper.ssh_helper
41         self.setup_helper = self._vnf_wrapper.setup_helper
42         self.resource_helper = self._vnf_wrapper.resource_helper
43         self.scenario_helper = self._vnf_wrapper.scenario_helper
44
45         self.runs_traffic = True
46         self.traffic_finished = False
47         self._tg_process = None
48         self._traffic_process = None
49
50     def terminate(self):
51         self._vnf_wrapper.terminate()
52         super(ProxTrafficGen, self).terminate()
53
54     def instantiate(self, scenario_cfg, context_cfg):
55         self._vnf_wrapper.instantiate(scenario_cfg, context_cfg)
56         self._tg_process = self._vnf_wrapper._vnf_process
57
58     def wait_for_instantiate(self):
59         self._vnf_wrapper.wait_for_instantiate()