1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
# Copyright (c) 2019 Viosoft Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import logging
import time
from yardstick.network_services.vnf_generic.vnf import sample_vnf
LOG = logging.getLogger(__name__)
class VimsSetupEnvHelper(sample_vnf.SetupEnvHelper):
def setup_vnf_environment(self):
LOG.debug('VimsSetupEnvHelper:\n')
class VimsResourceHelper(sample_vnf.ClientResourceHelper):
pass
class VimsPcscfVnf(sample_vnf.SampleVNF):
APP_NAME = "VimsPcscf"
APP_WORD = "VimsPcscf"
def __init__(self, name, vnfd, setup_env_helper_type=None,
resource_helper_type=None):
if resource_helper_type is None:
resource_helper_type = VimsResourceHelper
if setup_env_helper_type is None:
setup_env_helper_type = VimsSetupEnvHelper
super(VimsPcscfVnf, self).__init__(name, vnfd, setup_env_helper_type,
resource_helper_type)
def wait_for_instantiate(self):
pass
def _run(self):
pass
def start_collect(self):
# TODO
pass
def collect_kpi(self):
# TODO
pass
class VimsHssVnf(sample_vnf.SampleVNF):
APP_NAME = "VimsHss"
APP_WORD = "VimsHss"
CMD = "sudo /media/generate_user.sh {} {} >> /dev/null 2>&1"
def __init__(self, name, vnfd, setup_env_helper_type=None,
resource_helper_type=None):
if resource_helper_type is None:
resource_helper_type = VimsResourceHelper
if setup_env_helper_type is None:
setup_env_helper_type = VimsSetupEnvHelper
super(VimsHssVnf, self).__init__(name, vnfd, setup_env_helper_type,
resource_helper_type)
self.start_user = 1
self.end_user = 10000
self.WAIT_TIME = 600
def instantiate(self, scenario_cfg, context_cfg):
LOG.debug("scenario_cfg=%s\n", scenario_cfg)
self.start_user = scenario_cfg.get("options", {}).get("start_user", self.start_user)
self.end_user = scenario_cfg.get("options", {}).get("end_user", self.end_user)
# TODO
# Need to check HSS services are ready before generating user accounts
# Now, adding time sleep that manually configured by user
# to wait for HSS services.
# Note: for heat, waiting time is too long (~ 600s)
self.WAIT_TIME = scenario_cfg.get("options", {}).get("wait_time", self.WAIT_TIME)
time.sleep(self.WAIT_TIME)
LOG.debug("Generate user accounts from %d to %d\n",
self.start_user, self.end_user)
cmd = self.CMD.format(self.start_user, self.end_user)
self.ssh_helper.execute(cmd, None, 3600, False)
def wait_for_instantiate(self):
pass
def start_collect(self):
# TODO
pass
def collect_kpi(self):
# TODO
pass
|