1 # Copyright (c) 2019 Viosoft 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.
18 from yardstick.network_services.vnf_generic.vnf import sample_vnf
20 LOG = logging.getLogger(__name__)
23 class VimsSetupEnvHelper(sample_vnf.SetupEnvHelper):
25 def setup_vnf_environment(self):
26 LOG.debug('VimsSetupEnvHelper:\n')
29 class VimsResourceHelper(sample_vnf.ClientResourceHelper):
33 class VimsPcscfVnf(sample_vnf.SampleVNF):
35 APP_NAME = "VimsPcscf"
36 APP_WORD = "VimsPcscf"
38 def __init__(self, name, vnfd, setup_env_helper_type=None,
39 resource_helper_type=None):
40 if resource_helper_type is None:
41 resource_helper_type = VimsResourceHelper
42 if setup_env_helper_type is None:
43 setup_env_helper_type = VimsSetupEnvHelper
44 super(VimsPcscfVnf, self).__init__(name, vnfd, setup_env_helper_type,
47 def wait_for_instantiate(self):
53 def start_collect(self):
57 def collect_kpi(self):
62 class VimsHssVnf(sample_vnf.SampleVNF):
66 CMD = "sudo /media/generate_user.sh {} {} >> /dev/null 2>&1"
68 def __init__(self, name, vnfd, setup_env_helper_type=None,
69 resource_helper_type=None):
70 if resource_helper_type is None:
71 resource_helper_type = VimsResourceHelper
72 if setup_env_helper_type is None:
73 setup_env_helper_type = VimsSetupEnvHelper
74 super(VimsHssVnf, self).__init__(name, vnfd, setup_env_helper_type,
80 def instantiate(self, scenario_cfg, context_cfg):
81 LOG.debug("scenario_cfg=%s\n", scenario_cfg)
82 self.start_user = scenario_cfg.get("options", {}).get("start_user", self.start_user)
83 self.end_user = scenario_cfg.get("options", {}).get("end_user", self.end_user)
85 # Need to check HSS services are ready before generating user accounts
86 # Now, adding time sleep that manually configured by user
87 # to wait for HSS services.
88 # Note: for heat, waiting time is too long (~ 600s)
89 self.WAIT_TIME = scenario_cfg.get("options", {}).get("wait_time", self.WAIT_TIME)
90 time.sleep(self.WAIT_TIME)
91 LOG.debug("Generate user accounts from %d to %d\n",
92 self.start_user, self.end_user)
93 cmd = self.CMD.format(self.start_user, self.end_user)
94 self.ssh_helper.execute(cmd, None, 3600, False)
96 def wait_for_instantiate(self):
99 def start_collect(self):
103 def collect_kpi(self):