diff options
author | 2018-04-24 12:05:02 +0000 | |
---|---|---|
committer | 2018-04-24 12:05:02 +0000 | |
commit | 0911abc82403066af66d285db739cff03772b06c (patch) | |
tree | 1b17bff1a3db07a7c57b6bcf108160467422404e /functest/opnfv_tests | |
parent | 7bfdcd4b7d5ad67004f9f7467148089016c45ba5 (diff) | |
parent | fd18d52e94cc293c32bb7f69a00ec4604bdace0e (diff) |
Merge "Switch from deploy utils to the right objects"
Diffstat (limited to 'functest/opnfv_tests')
-rw-r--r-- | functest/opnfv_tests/openstack/vping/vping_base.py | 37 | ||||
-rw-r--r-- | functest/opnfv_tests/openstack/vping/vping_ssh.py | 7 | ||||
-rw-r--r-- | functest/opnfv_tests/openstack/vping/vping_userdata.py | 2 |
3 files changed, 28 insertions, 18 deletions
diff --git a/functest/opnfv_tests/openstack/vping/vping_base.py b/functest/opnfv_tests/openstack/vping/vping_base.py index 13e0efbc8..4b6e4e97f 100644 --- a/functest/opnfv_tests/openstack/vping/vping_base.py +++ b/functest/opnfv_tests/openstack/vping/vping_base.py @@ -16,11 +16,14 @@ import time import uuid from snaps.config.flavor import FlavorConfig -from snaps.config.network import NetworkConfig, SubnetConfig +from snaps.config.network import NetworkConfig +from snaps.config.network import SubnetConfig from snaps.config.router import RouterConfig from snaps.openstack.create_flavor import OpenStackFlavor +from snaps.openstack.create_image import OpenStackImage +from snaps.openstack.create_network import OpenStackNetwork +from snaps.openstack.create_router import OpenStackRouter from snaps.openstack.tests import openstack_tests -from snaps.openstack.utils import deploy_utils from xtesting.core import testcase from functest.opnfv_tests.openstack.snaps import snaps_utils @@ -85,14 +88,14 @@ class VPingBase(testcase.TestCase): '%Y-%m-%d %H:%M:%S')) image_base_name = '{}-{}'.format( - getattr(config.CONF, 'vping_image_name'), - str(self.guid)) + getattr(config.CONF, 'vping_image_name'), self.guid) os_image_settings = openstack_tests.cirros_image_settings( image_base_name, image_metadata=self.cirros_image_config) self.logger.info("Creating image with name: '%s'", image_base_name) - self.image_creator = deploy_utils.create_image( + self.image_creator = OpenStackImage( self.os_creds, os_image_settings) + self.image_creator.create() self.creators.append(self.image_creator) private_net_name = getattr( @@ -116,29 +119,31 @@ class VPingBase(testcase.TestCase): self.logger.info( "Creating network with name: '%s'", private_net_name) - self.network_creator = deploy_utils.create_network( + subnet_settings = SubnetConfig( + name=private_subnet_name, + cidr=private_subnet_cidr, + dns_nameservers=[env.get('NAMESERVER')]) + self.network_creator = OpenStackNetwork( self.os_creds, NetworkConfig( name=private_net_name, network_type=vping_network_type, physical_network=vping_physical_network, segmentation_id=vping_segmentation_id, - subnet_settings=[SubnetConfig( - name=private_subnet_name, - cidr=private_subnet_cidr, - dns_nameservers=[env.get('NAMESERVER')])])) + subnet_settings=[subnet_settings])) + self.network_creator.create() self.creators.append(self.network_creator) # Creating router to external network - log = "Creating router with name: '%s'" % self.router_name - self.logger.info(log) + self.logger.info("Creating router with name: '%s'", self.router_name) ext_net_name = snaps_utils.get_ext_net_name(self.os_creds) - self.router_creator = deploy_utils.create_router( + self.router_creator = OpenStackRouter( self.os_creds, RouterConfig( name=self.router_name, external_gateway=ext_net_name, - internal_subnets=[private_subnet_name])) + internal_subnets=[subnet_settings.name])) + self.router_creator.create() self.creators.append(self.router_creator) self.logger.info( @@ -187,8 +192,8 @@ class VPingBase(testcase.TestCase): for creator in reversed(self.creators): try: creator.clean() - except Exception as error: # pylint: disable=broad-except - self.logger.error('Unexpected error cleaning - %s', error) + except Exception: # pylint: disable=broad-except + self.logger.exception('Unexpected error cleaning') def _do_vping(self, vm_creator, test_ip): """ diff --git a/functest/opnfv_tests/openstack/vping/vping_ssh.py b/functest/opnfv_tests/openstack/vping/vping_ssh.py index 7cdcd2576..93c9c0976 100644 --- a/functest/opnfv_tests/openstack/vping/vping_ssh.py +++ b/functest/opnfv_tests/openstack/vping/vping_ssh.py @@ -9,6 +9,7 @@ """vPingSSH testcase.""" +import logging import time from scp import SCPClient @@ -29,6 +30,7 @@ from functest.utils import config class VPingSSH(vping_base.VPingBase): + # pylint: disable=too-many-instance-attributes """ VPingSSH testcase implementation. @@ -41,6 +43,7 @@ class VPingSSH(vping_base.VPingBase): if "case_name" not in kwargs: kwargs["case_name"] = "vping_ssh" super(VPingSSH, self).__init__(**kwargs) + self.logger = logging.getLogger(__name__) self.kp_name = getattr(config.CONF, 'vping_keypair_name') + self.guid self.kp_priv_file = getattr(config.CONF, 'vping_keypair_priv_file') @@ -120,8 +123,8 @@ class VPingSSH(vping_base.VPingBase): self.creators.append(self.vm2_creator) return self._execute() - except Exception as exc: # pylint: disable=broad-except - self.logger.error('Unexpected error running test - ' + exc.message) + except Exception: # pylint: disable=broad-except + self.logger.exception('Unexpected error running test') return testcase.TestCase.EX_RUN_ERROR def _do_vping(self, vm_creator, test_ip): diff --git a/functest/opnfv_tests/openstack/vping/vping_userdata.py b/functest/opnfv_tests/openstack/vping/vping_userdata.py index 7d9a57c93..c2ff75150 100644 --- a/functest/opnfv_tests/openstack/vping/vping_userdata.py +++ b/functest/opnfv_tests/openstack/vping/vping_userdata.py @@ -9,6 +9,7 @@ """vping_userdata testcase.""" +import logging import time from snaps.config.network import PortConfig @@ -28,6 +29,7 @@ class VPingUserdata(vping_base.VPingBase): if "case_name" not in kwargs: kwargs["case_name"] = "vping_userdata" super(VPingUserdata, self).__init__(**kwargs) + self.logger = logging.getLogger(__name__) def run(self, **kwargs): """ |