X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=functest%2Fopnfv_tests%2Fopenstack%2Fvping%2Fvping_base.py;h=edc78482b17fe3d3cc8703b4e6f22b0b287c1d62;hb=530c678677cc314c159936fdf5e121e83fc1d0cc;hp=318e9c45f7a5837e0d222cfbd65b18c618257136;hpb=0da9c0665df587b97129472b38c52dd6c1ab12a4;p=functest.git diff --git a/functest/opnfv_tests/openstack/vping/vping_base.py b/functest/opnfv_tests/openstack/vping/vping_base.py index 318e9c45f..edc78482b 100644 --- a/functest/opnfv_tests/openstack/vping/vping_base.py +++ b/functest/opnfv_tests/openstack/vping/vping_base.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python + # Copyright (c) 2017 Cable Television Laboratories, Inc. and others. # # This program and the accompanying materials @@ -13,10 +15,6 @@ import logging import time import uuid -from functest.core import testcase -from functest.opnfv_tests.openstack.snaps import snaps_utils -from functest.utils.constants import CONST - from snaps.config.flavor import FlavorConfig from snaps.config.network import NetworkConfig, SubnetConfig from snaps.config.router import RouterConfig @@ -24,6 +22,11 @@ from snaps.openstack import create_flavor from snaps.openstack.create_flavor import OpenStackFlavor 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 +from functest.utils import config +from functest.utils import env class VPingBase(testcase.TestCase): @@ -37,21 +40,8 @@ class VPingBase(testcase.TestCase): def __init__(self, **kwargs): super(VPingBase, self).__init__(**kwargs) - self.logger = logging.getLogger(__name__) - - if 'os_creds' in kwargs: - self.os_creds = kwargs['os_creds'] - else: - creds_override = None - if hasattr(CONST, 'snaps_os_creds_override'): - creds_override = CONST.__getattribute__( - 'snaps_os_creds_override') - - self.os_creds = openstack_tests.get_credentials( - os_env_file=CONST.__getattribute__('openstack_creds'), - overrides=creds_override) - + self.os_creds = kwargs.get('os_creds') or snaps_utils.get_credentials() self.creators = list() self.image_creator = None self.network_creator = None @@ -60,31 +50,30 @@ class VPingBase(testcase.TestCase): self.router_creator = None # Shared metadata - self.guid = '' - if CONST.__getattribute__('vping_unique_names'): - self.guid = '-' + str(uuid.uuid4()) - - self.router_name = CONST.__getattribute__( - 'vping_router_name') + self.guid - self.vm1_name = CONST.__getattribute__('vping_vm_name_1') + self.guid - self.vm2_name = CONST.__getattribute__('vping_vm_name_2') + self.guid - - self.vm_boot_timeout = CONST.__getattribute__('vping_vm_boot_timeout') - self.vm_delete_timeout = CONST.__getattribute__( - 'vping_vm_delete_timeout') - self.vm_ssh_connect_timeout = CONST.__getattribute__( - 'vping_vm_ssh_connect_timeout') - self.ping_timeout = CONST.__getattribute__('vping_ping_timeout') + self.guid = '-' + str(uuid.uuid4()) + + self.router_name = getattr( + config.CONF, 'vping_router_name') + self.guid + self.vm1_name = getattr( + config.CONF, 'vping_vm_name_1') + self.guid + self.vm2_name = getattr(config.CONF, 'vping_vm_name_2') + self.guid + + self.vm_boot_timeout = getattr(config.CONF, 'vping_vm_boot_timeout') + self.vm_delete_timeout = getattr( + config.CONF, 'vping_vm_delete_timeout') + self.vm_ssh_connect_timeout = getattr( + config.CONF, 'vping_vm_ssh_connect_timeout') + self.ping_timeout = getattr(config.CONF, 'vping_ping_timeout') self.flavor_name = 'vping-flavor' + self.guid # Move this configuration option up for all tests to leverage - if hasattr(CONST, 'snaps_images_cirros'): - self.cirros_image_config = CONST.__getattribute__( - 'snaps_images_cirros') + if hasattr(config.CONF, 'snaps_images_cirros'): + self.cirros_image_config = getattr( + config.CONF, 'snaps_images_cirros') else: self.cirros_image_config = None - def run(self): + def run(self, **kwargs): # pylint: disable=too-many-locals """ Begins the test execution which should originate from the subclass """ @@ -97,7 +86,7 @@ class VPingBase(testcase.TestCase): '%Y-%m-%d %H:%M:%S')) image_base_name = '{}-{}'.format( - CONST.__getattribute__('vping_image_name'), + getattr(config.CONF, 'vping_image_name'), str(self.guid)) os_image_settings = openstack_tests.cirros_image_settings( image_base_name, image_metadata=self.cirros_image_config) @@ -107,26 +96,24 @@ class VPingBase(testcase.TestCase): self.os_creds, os_image_settings) self.creators.append(self.image_creator) - private_net_name = CONST.__getattribute__( - 'vping_private_net_name') + self.guid - private_subnet_name = CONST.__getattribute__( - 'vping_private_subnet_name') + self.guid - private_subnet_cidr = CONST.__getattribute__( - 'vping_private_subnet_cidr') + private_net_name = getattr( + config.CONF, 'vping_private_net_name') + self.guid + private_subnet_name = getattr( + config.CONF, 'vping_private_subnet_name') + self.guid + private_subnet_cidr = getattr(config.CONF, 'vping_private_subnet_cidr') vping_network_type = None vping_physical_network = None vping_segmentation_id = None - if hasattr(CONST, 'vping_network_type'): - vping_network_type = CONST.__getattribute__( - 'vping_network_type') - if hasattr(CONST, 'vping_physical_network'): - vping_physical_network = CONST.__getattribute__( - 'vping_physical_network') - if hasattr(CONST, 'vping_segmentation_id'): - vping_segmentation_id = CONST.__getattribute__( - 'vping_segmentation_id') + if hasattr(config.CONF, 'vping_network_type'): + vping_network_type = getattr(config.CONF, 'vping_network_type') + if hasattr(config.CONF, 'vping_physical_network'): + vping_physical_network = getattr( + config.CONF, 'vping_physical_network') + if hasattr(config.CONF, 'vping_segmentation_id'): + vping_segmentation_id = getattr( + config.CONF, 'vping_segmentation_id') self.logger.info( "Creating network with name: '%s'", private_net_name) @@ -139,7 +126,8 @@ class VPingBase(testcase.TestCase): segmentation_id=vping_segmentation_id, subnet_settings=[SubnetConfig( name=private_subnet_name, - cidr=private_subnet_cidr)])) + cidr=private_subnet_cidr, + dns_nameservers=[env.get('NAMESERVER')])])) self.creators.append(self.network_creator) # Creating router to external network @@ -156,14 +144,16 @@ class VPingBase(testcase.TestCase): self.logger.info( "Creating flavor with name: '%s'", self.flavor_name) - scenario = CONST.__getattribute__('DEPLOY_SCENARIO') + scenario = env.get('DEPLOY_SCENARIO') flavor_metadata = None + flavor_ram = 512 if 'ovs' in scenario or 'fdio' in scenario: flavor_metadata = create_flavor.MEM_PAGE_SIZE_LARGE + flavor_ram = 1024 flavor_creator = OpenStackFlavor( self.os_creds, - FlavorConfig(name=self.flavor_name, ram=512, disk=1, vcpus=1, - metadata=flavor_metadata)) + FlavorConfig(name=self.flavor_name, ram=flavor_ram, disk=1, + vcpus=1, metadata=flavor_metadata)) flavor_creator.create() self.creators.append(flavor_creator) @@ -197,7 +187,7 @@ class VPingBase(testcase.TestCase): Cleanup all OpenStack objects. Should be called on completion :return: """ - if CONST.__getattribute__('vping_cleanup_objects'): + if getattr(config.CONF, 'vping_cleanup_objects') == 'True': for creator in reversed(self.creators): try: creator.clean()