diff options
Diffstat (limited to 'vnftest/openstack')
-rw-r--r-- | vnftest/openstack/__init__.py | 0 | ||||
-rw-r--r-- | vnftest/openstack/steps/__init__.py | 0 | ||||
-rw-r--r-- | vnftest/openstack/steps/heat.py | 54 | ||||
-rw-r--r-- | vnftest/openstack/steps/nova.py | 58 |
4 files changed, 112 insertions, 0 deletions
diff --git a/vnftest/openstack/__init__.py b/vnftest/openstack/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/vnftest/openstack/__init__.py 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] |