summaryrefslogtreecommitdiffstats
path: root/vnftest/openstack/steps
diff options
context:
space:
mode:
authorMoshe <moshehoa@amdocs.com>2018-06-20 10:23:28 +0300
committerMoshe <moshehoa@amdocs.com>2018-06-20 12:13:36 +0300
commitc7c4cc227ed9447b4fdceeceece35384404bd7ec (patch)
tree5a7900dfa5ce66c1821e2ab0719741e9cccfb126 /vnftest/openstack/steps
parente65155cab8d6d74989f1dd0bd1a493e1c91a30d9 (diff)
Add validation abilities to test cases
Change-Id: I76b28e6170d6e91836b195d58c0b882168c11a67 Issue-ID: VNFSDK-275 Signed-off-by: Moshe <moshehoa@amdocs.com> Add unit tests Issue-ID: VNFSDK-275 Change-Id: I34bc9a11e16e4092fdad3b4a1733c7219e624f5f Signed-off-by: Moshe <moshehoa@amdocs.com> add unit tests Issue-ID: VNFSDK-275 Change-Id: Ib99c3521438b002e0d8aaff9870224673e34899f Signed-off-by: Moshe <moshehoa@amdocs.com> add unit tests Issue-ID: VNFSDK-275 Change-Id: I1ac560dfb40df5f346b0db8f40b8c52a2fb6b350 Signed-off-by: Moshe <moshehoa@amdocs.com>
Diffstat (limited to 'vnftest/openstack/steps')
-rw-r--r--vnftest/openstack/steps/__init__.py0
-rw-r--r--vnftest/openstack/steps/heat.py54
-rw-r--r--vnftest/openstack/steps/nova.py58
3 files changed, 112 insertions, 0 deletions
diff --git a/vnftest/openstack/steps/__init__.py b/vnftest/openstack/steps/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/vnftest/openstack/steps/__init__.py
diff --git a/vnftest/openstack/steps/heat.py b/vnftest/openstack/steps/heat.py
new file mode 100644
index 0000000..2d5822c
--- /dev/null
+++ b/vnftest/openstack/steps/heat.py
@@ -0,0 +1,54 @@
+##############################################################################
+# Copyright 2018 EuropeanSoftwareMarketingLtd.
+# ===================================================================
+# Licensed under the ApacheLicense, Version2.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
+#
+# 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
+##############################################################################
+
+from __future__ import absolute_import
+
+from vnftest.crawlers.base import Crawler
+
+from vnftest.common import openstack_utils, utils
+
+import logging
+
+from vnftest.steps import base
+
+LOG = logging.getLogger(__name__)
+
+
+class Heat(base.Step):
+ __step_type__ = "Heat"
+
+ def __init__(self, step_cfg, context, input_params):
+ self.step_cfg = step_cfg
+ self.context = context
+ self.input_params = input_params
+ self.output_cfg = None
+ self.operation = None
+ self.heat_stack_id = None
+
+ def setup(self):
+ options = self.step_cfg['options']
+ self.operation = options.get("operation")
+ self.output_cfg = options.get("output", {})
+ heat_stack_id_def = options.get("heat_stack_id")
+ self.heat_stack_id = utils.format(heat_stack_id_def, self.input_params)
+
+ def run(self, result):
+ op_result = getattr(self, self.operation)()
+ op_result = utils.normalize_data_struct(op_result)
+ output = Crawler.crawl(op_result, self.output_cfg)
+ result.update(output)
+ return output
+
+ def get_stack_vms(self):
+ return openstack_utils.get_stack_vms(self.heat_stack_id)
diff --git a/vnftest/openstack/steps/nova.py b/vnftest/openstack/steps/nova.py
new file mode 100644
index 0000000..fad5d7d
--- /dev/null
+++ b/vnftest/openstack/steps/nova.py
@@ -0,0 +1,58 @@
+##############################################################################
+# Copyright 2018 EuropeanSoftwareMarketingLtd.
+# ===================================================================
+# Licensed under the ApacheLicense, Version2.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
+#
+# 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
+##############################################################################
+
+from __future__ import absolute_import
+
+from vnftest.crawlers.base import Crawler
+
+from vnftest.common import openstack_utils, utils
+
+import logging
+
+from vnftest.steps import base
+
+LOG = logging.getLogger(__name__)
+
+
+class Nova(base.Step):
+ __step_type__ = "Nova"
+
+ def __init__(self, step_cfg, context, input_params):
+ self.step_cfg = step_cfg
+ self.context = context
+ self.input_params = input_params
+ self.output_cfg = None
+ self.operation = None
+ self.resource_id = None
+
+ def setup(self):
+ options = self.step_cfg['options']
+ self.operation = options.get("operation")
+ self.output_cfg = options.get("output", {})
+ resource_id_def = options.get("resource_id")
+ self.resource_id = utils.format(resource_id_def, self.input_params)
+
+ def run(self, result):
+ op_result = getattr(self, self.operation)()
+ op_result = utils.normalize_data_struct(op_result)
+ output = Crawler.crawl(op_result, self.output_cfg)
+ result.update(output)
+ return output
+
+ def get_vm_external_ip(self):
+ instance = openstack_utils.get_instance_by_id(self.resource_id)
+ for network_name, ip_list in instance.networks.iteritems():
+ network = openstack_utils.get_network_by_name(network_name)
+ if network['router:external']:
+ return ip_list[0]