summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--functest/core/singlevm.py29
-rw-r--r--functest/core/tenantnetwork.py27
-rw-r--r--functest/opnfv_tests/openstack/tempest/tempest.py11
3 files changed, 39 insertions, 28 deletions
diff --git a/functest/core/singlevm.py b/functest/core/singlevm.py
index 331ada484..7520f2649 100644
--- a/functest/core/singlevm.py
+++ b/functest/core/singlevm.py
@@ -37,6 +37,8 @@ class VmReady1(tenantnetwork.TenantNetwork1):
__logger = logging.getLogger(__name__)
filename = '/home/opnfv/functest/images/cirros-0.4.0-x86_64-disk.img'
+ visibility = 'private'
+ extra_properties = None
flavor_ram = 1024
flavor_vcpus = 1
flavor_disk = 1
@@ -51,14 +53,17 @@ class VmReady1(tenantnetwork.TenantNetwork1):
def _publish_image(self):
assert self.cloud
- meta = getattr(
- config.CONF, '{}_extra_properties'.format(self.case_name), None)
self.image = self.cloud.create_image(
'{}-img_{}'.format(self.case_name, self.guid),
filename=getattr(
config.CONF, '{}_image'.format(self.case_name),
self.filename),
- meta=meta)
+ meta=getattr(
+ config.CONF, '{}_extra_properties'.format(self.case_name),
+ self.extra_properties),
+ visibility=getattr(
+ config.CONF, '{}_visibility'.format(self.case_name),
+ self.visibility))
self.__logger.debug("image: %s", self.image)
def _create_flavor(self):
@@ -104,11 +109,11 @@ class VmReady1(tenantnetwork.TenantNetwork1):
try:
assert self.orig_cloud
assert self.cloud
- self.cloud.delete_image(self.image)
+ super(VmReady1, self).clean()
+ self.cloud.delete_image(self.image.id)
self.orig_cloud.delete_flavor(self.flavor.id)
- self.cloud.delete_image(self.image)
except Exception: # pylint: disable=broad-except
- pass
+ self.__logger.exception("Cannot clean all ressources")
class VmReady2(VmReady1):
@@ -144,7 +149,7 @@ class VmReady2(VmReady1):
assert self.project
self.project.clean()
except Exception: # pylint: disable=broad-except
- self.__logger.exception("cannot clean all ressources")
+ self.__logger.exception("Cannot clean all ressources")
class SingleVm1(VmReady1):
@@ -286,15 +291,13 @@ class SingleVm1(VmReady1):
try:
assert self.orig_cloud
assert self.cloud
+ self.cloud.delete_floating_ip(self.fip.id)
self.cloud.delete_server(self.sshvm, wait=True)
self.cloud.delete_security_group(self.sec.id)
- self.cloud.delete_image(self.image)
- self.orig_cloud.delete_flavor(self.flavor.id)
self.cloud.delete_keypair(self.keypair.id)
- self.cloud.delete_floating_ip(self.fip.id)
- self.cloud.delete_image(self.image)
+ super(SingleVm1, self).clean()
except Exception: # pylint: disable=broad-except
- pass
+ self.__logger.exception("Cannot clean all ressources")
class SingleVm2(SingleVm1):
@@ -330,4 +333,4 @@ class SingleVm2(SingleVm1):
assert self.project
self.project.clean()
except Exception: # pylint: disable=broad-except
- self.__logger.exception("cannot clean all ressources")
+ self.__logger.exception("Cannot clean all ressources")
diff --git a/functest/core/tenantnetwork.py b/functest/core/tenantnetwork.py
index cdd558868..c41f470a8 100644
--- a/functest/core/tenantnetwork.py
+++ b/functest/core/tenantnetwork.py
@@ -38,8 +38,8 @@ class NewProject(object):
__logger = logging.getLogger(__name__)
def __init__(self, cloud, case_name, guid):
- self.orig_cloud = cloud
self.cloud = None
+ self.orig_cloud = cloud
self.case_name = case_name
self.guid = guid
self.project = None
@@ -51,8 +51,7 @@ class NewProject(object):
assert self.case_name
password = str(uuid.uuid4())
domain = self.orig_cloud.get_domain(
- name_or_id=self.orig_cloud.auth.get(
- "project_domain_name", "Default"))
+ name_or_id="functest")
self.project = self.orig_cloud.create_project(
name='{}-project_{}'.format(self.case_name, self.guid),
description="Created by OPNFV Functest: {}".format(
@@ -62,15 +61,18 @@ class NewProject(object):
self.user = self.orig_cloud.create_user(
name='{}-user_{}'.format(self.case_name, self.guid),
password=password,
- default_project=self.project.id,
domain_id=domain.id)
self.__logger.debug("user: %s", self.user)
- os.environ["OS_USERNAME"] = self.user.name
- os.environ["OS_PROJECT_NAME"] = self.user.default_project_id
- cloud_config = os_client_config.get_config()
- self.cloud = shade.OpenStackCloud(cloud_config=cloud_config)
- os.environ["OS_USERNAME"] = self.orig_cloud.auth["username"]
- os.environ["OS_PROJECT_NAME"] = self.orig_cloud.auth["project_name"]
+ self.orig_cloud.grant_role(
+ "_member_", user=self.user.id, project=self.project.id,
+ domain=domain.id)
+ osconfig = os_client_config.config.OpenStackConfig()
+ osconfig.cloud_config[
+ 'clouds']['envvars']['project_name'] = self.project.name
+ osconfig.cloud_config['clouds']['envvars']['username'] = self.user.name
+ osconfig.cloud_config['clouds']['envvars']['password'] = password
+ self.cloud = shade.OpenStackCloud(
+ cloud_config=osconfig.get_one_cloud())
def clean(self):
"""Remove projects/users"""
@@ -81,7 +83,7 @@ class NewProject(object):
self.orig_cloud.delete_user(self.user.id)
self.orig_cloud.delete_project(self.project.id)
except Exception: # pylint: disable=broad-except
- self.__logger.exception("cannot clean all ressources")
+ self.__logger.exception("Cannot clean all ressources")
class TenantNetwork1(testcase.TestCase):
@@ -174,6 +176,7 @@ class TenantNetwork1(testcase.TestCase):
assert self.cloud
self.cloud.remove_router_interface(self.router, self.subnet.id)
self.cloud.delete_router(self.router.id)
+ self.cloud.delete_subnet(self.subnet.id)
self.cloud.delete_network(self.network.id)
except Exception: # pylint: disable=broad-except
self.__logger.exception("cannot clean all ressources")
@@ -213,4 +216,4 @@ class TenantNetwork2(TenantNetwork1):
assert self.project
self.project.clean()
except Exception: # pylint: disable=broad-except
- self.__logger.exception("cannot clean all ressources")
+ self.__logger.exception("Cannot clean all ressources")
diff --git a/functest/opnfv_tests/openstack/tempest/tempest.py b/functest/opnfv_tests/openstack/tempest/tempest.py
index ce53dde07..2fa3bd609 100644
--- a/functest/opnfv_tests/openstack/tempest/tempest.py
+++ b/functest/opnfv_tests/openstack/tempest/tempest.py
@@ -38,6 +38,8 @@ class TempestCommon(singlevm.VmReady1):
TEMPEST_RESULTS_DIR = os.path.join(
getattr(config.CONF, 'dir_results'), 'tempest')
+ visibility = 'public'
+
def __init__(self, **kwargs):
super(TempestCommon, self).__init__(**kwargs)
self.mode = ""
@@ -265,14 +267,17 @@ class TempestCommon(singlevm.VmReady1):
LOGGER.info("Creating two images for Tempest suite")
- meta = getattr(
- config.CONF, '{}_extra_properties'.format(self.case_name), None)
self.image_alt = self.cloud.create_image(
'{}-img_alt_{}'.format(self.case_name, self.guid),
filename=getattr(
config.CONF, '{}_image'.format(self.case_name),
self.filename),
- meta=meta)
+ meta=getattr(
+ config.CONF, '{}_extra_properties'.format(self.case_name),
+ self.extra_properties),
+ visibility=getattr(
+ config.CONF, '{}_visibility'.format(self.case_name),
+ self.visibility))
LOGGER.debug("image_alt: %s", self.image_alt)
self.flavor_alt = self.orig_cloud.create_flavor(