add yardstick iruya 9.0.0 release notes
[yardstick.git] / yardstick / network_services / vnf_generic / vnf / vims_vnf.py
1 # Copyright (c) 2019 Viosoft 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 time
17
18 from yardstick.network_services.vnf_generic.vnf import sample_vnf
19
20 LOG = logging.getLogger(__name__)
21
22
23 class VimsSetupEnvHelper(sample_vnf.SetupEnvHelper):
24
25     def setup_vnf_environment(self):
26         LOG.debug('VimsSetupEnvHelper:\n')
27
28
29 class VimsResourceHelper(sample_vnf.ClientResourceHelper):
30     pass
31
32
33 class VimsPcscfVnf(sample_vnf.SampleVNF):
34
35     APP_NAME = "VimsPcscf"
36     APP_WORD = "VimsPcscf"
37
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,
45                                            resource_helper_type)
46
47     def wait_for_instantiate(self):
48         pass
49
50     def _run(self):
51         pass
52
53     def start_collect(self):
54         # TODO
55         pass
56
57     def collect_kpi(self):
58         # TODO
59         pass
60
61
62 class VimsHssVnf(sample_vnf.SampleVNF):
63
64     APP_NAME = "VimsHss"
65     APP_WORD = "VimsHss"
66     CMD = "sudo /media/generate_user.sh {} {} >> /dev/null 2>&1"
67
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,
75                                          resource_helper_type)
76         self.start_user = 1
77         self.end_user = 10000
78         self.WAIT_TIME = 600
79
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)
84         # TODO
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)
95
96     def wait_for_instantiate(self):
97         pass
98
99     def start_collect(self):
100         # TODO
101         pass
102
103     def collect_kpi(self):
104         # TODO
105         pass