From e6949d0ab44d9ce6c513f17f0a6518d5a1e0b528 Mon Sep 17 00:00:00 2001 From: Will Szumski Date: Fri, 17 Jun 2022 12:29:38 +0100 Subject: [PATCH] Add enable_create_resources --- rally_openstack/common/cfg/tempest.py | 3 +++ .../verification/tempest/context.py | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/rally_openstack/common/cfg/tempest.py b/rally_openstack/common/cfg/tempest.py index b2fa25113..a982f4515 100644 --- a/rally_openstack/common/cfg/tempest.py +++ b/rally_openstack/common/cfg/tempest.py @@ -21,6 +21,9 @@ "0.5.2/cirros-0.5.2-x86_64-disk.img", deprecated_group="tempest", help="image URL"), + cfg.BoolOpt("enable_create_resources", + default=True, + help="Create openstack resources for tempest run"), cfg.StrOpt("img_disk_format", default="qcow2", deprecated_group="tempest", diff --git a/rally_openstack/verification/tempest/context.py b/rally_openstack/verification/tempest/context.py index 4ee077785..5e522ab9d 100644 --- a/rally_openstack/verification/tempest/context.py +++ b/rally_openstack/verification/tempest/context.py @@ -44,6 +44,10 @@ class TempestContext(context.VerifierContext): def __init__(self, ctx): super(TempestContext, self).__init__(ctx) + # If openstack.enable_create_resources==False you can provide + # a non-admin credential. You will need to make sure that the + # resources are discovered by supplying config options such as + # flavor_id. openstack_platform = self.verifier.env.data["platforms"]["openstack"] admin_creds = credential.OpenStackCredential( permission=consts.EndpointPermission.ADMIN, @@ -144,6 +148,8 @@ def cleanup(self): self.conf.write(configfile) def _create_tempest_roles(self): + if not conf.CONF.openstack.enable_create_resources: + return keystoneclient = self.clients.verified_keystone() roles = [conf.CONF.openstack.swift_operator_role, conf.CONF.openstack.swift_reseller_admin_role, @@ -251,6 +257,10 @@ def _discover_or_create_image(self): % (image_obj.name, image_obj.id)) return image_obj + if not conf.CONF.openstack.enable_create_resources: + msg = ("Image could not discovered and openstack.enable_create_resources is set to False") + raise exceptions.RallyException(msg) + params = { "image_name": self.generate_random_name(), "disk_format": conf.CONF.openstack.img_disk_format, @@ -283,6 +293,10 @@ def _discover_or_create_flavor(self, flv_ram, flv_disk): LOG.debug("There is no flavor with the mentioned properties.") + if not conf.CONF.openstack.enable_create_resources: + msg = ("Flavor could not discovered and openstack.enable_create_resources is set to False") + raise exceptions.RallyException(msg) + params = { "name": self.generate_random_name(), "ram": flv_ram, @@ -300,6 +314,10 @@ def _discover_or_create_flavor(self, flv_ram, flv_disk): return flavor def _create_network_resources(self): + if not conf.CONF.openstack.enable_create_resources: + msg = ("fixed_network_name not set and openstack.enable_create_resources is set to False") + raise exceptions.RallyException(msg) + client = neutron.NeutronService( clients=self.clients, name_generator=self.generate_random_name,