Include class name in resource names for resource cleanup debugging

Applied class names in calling of data_utils.rand_name()

Change-Id: Ia73b3b484721803f084de4648249ed1f586226c6
Closes-Bug: #1690429
This commit is contained in:
maniksidana 2017-05-17 02:47:35 -05:00 committed by Felipe Monteiro
parent 4791c4b11b
commit 20e780f445
31 changed files with 109 additions and 73 deletions

View File

@ -58,7 +58,7 @@ class BaseV2ComputeRbacTest(compute_base.BaseV2ComputeTest):
@classmethod
def _create_flavor(cls, **kwargs):
flavor_kwargs = {
"name": data_utils.rand_name('flavor'),
"name": data_utils.rand_name(cls.__name__ + '-flavor'),
"ram": data_utils.rand_int_id(1, 10),
"vcpus": data_utils.rand_int_id(1, 10),
"disk": data_utils.rand_int_id(1, 10),

View File

@ -37,7 +37,7 @@ class AggregatesRbacTest(rbac_base.BaseV2ComputeRbacTest):
cls.hosts_client = cls.os_primary.hosts_client
def _create_aggregate(self):
agg_name = data_utils.rand_name('aggregate')
agg_name = data_utils.rand_name(self.__class__.__name__ + '-aggregate')
aggregate = self.aggregates_client.create_aggregate(name=agg_name)
aggregate_id = aggregate['aggregate']['id']
self.addCleanup(test_utils.call_and_ignore_notfound_exc,
@ -82,7 +82,7 @@ class AggregatesRbacTest(rbac_base.BaseV2ComputeRbacTest):
def test_update_aggregate_rbac(self):
aggregate_id = self._create_aggregate()
self.rbac_utils.switch_role(self, toggle_rbac_role=True)
new_name = data_utils.rand_name('aggregate')
new_name = data_utils.rand_name(self.__class__.__name__ + '-aggregate')
self.aggregates_client.update_aggregate(aggregate_id, name=new_name)
@rbac_rule_validation.action(
@ -115,8 +115,8 @@ class AggregatesRbacTest(rbac_base.BaseV2ComputeRbacTest):
@decorators.idempotent_id('ed6f3849-065c-4ae9-a81e-6ad7ed0d3d9d')
def test_set_metadata_on_aggregate_rbac(self):
aggregate_id = self._create_aggregate()
rand_key = data_utils.rand_name('key')
rand_val = data_utils.rand_name('val')
rand_key = data_utils.rand_name(self.__class__.__name__ + '-key')
rand_val = data_utils.rand_name(self.__class__.__name__ + '-val')
self.rbac_utils.switch_role(self, toggle_rbac_role=True)
self.aggregates_client.set_metadata(
aggregate_id,

View File

@ -48,8 +48,8 @@ class FlavorExtraSpecsRbacTest(rbac_base.BaseV2ComputeRbacTest):
super(FlavorExtraSpecsRbacTest, cls).resource_cleanup()
def _set_flavor_extra_spec(self):
rand_key = data_utils.rand_name('key')
rand_val = data_utils.rand_name('val')
rand_key = data_utils.rand_name(self.__class__.__name__ + '-key')
rand_val = data_utils.rand_name(self.__class__.__name__ + '-val')
specs = {rand_key: rand_val}
self.client.set_flavor_extra_spec(self.flavor['id'],
**specs)['extra_specs']
@ -82,7 +82,7 @@ class FlavorExtraSpecsRbacTest(rbac_base.BaseV2ComputeRbacTest):
def test_update_flavor_extra_spec(self):
key = self._set_flavor_extra_spec()
self.rbac_utils.switch_role(self, toggle_rbac_role=True)
update_val = data_utils.rand_name('val')
update_val = data_utils.rand_name(self.__class__.__name__ + '-val')
self.client.update_flavor_extra_spec(self.flavor['id'], key,
**{key: update_val})[key]

View File

@ -54,7 +54,7 @@ class ImagesV235RbacTest(rbac_base.BaseV2ComputeRbacTest):
def resource_setup(cls):
super(ImagesV235RbacTest, cls).resource_setup()
cls.image = cls.glance_image_client.create_image(
name=data_utils.rand_name('image'))
name=data_utils.rand_name(cls.__name__ + '-image'))
@classmethod
def resource_cleanup(cls):
@ -111,7 +111,7 @@ class ImagesV235RbacTest(rbac_base.BaseV2ComputeRbacTest):
rule="delete_image")
def test_delete_image(self):
image = self.glance_image_client.create_image(
name=data_utils.rand_name('image'))
name=data_utils.rand_name(self.__class__.__name__ + '-image'))
self.addCleanup(test_utils.call_and_ignore_notfound_exc,
self.glance_image_client.delete_image, image['id'])

View File

@ -29,7 +29,7 @@ class KeypairsRbacTest(rbac_base.BaseV2ComputeRbacTest):
cls.client = cls.keypairs_client
def _create_keypair(self):
key_name = data_utils.rand_name('key')
key_name = data_utils.rand_name(self.__class__.__name__ + '-key')
keypair = self.client.create_keypair(name=key_name)
self.addCleanup(test_utils.call_and_ignore_notfound_exc,
self.client.delete_keypair,

View File

@ -88,7 +88,8 @@ class QuotaSetsRbacTest(rbac_base.BaseV2ComputeRbacTest):
service="nova",
rule="os_compute_api:os-quota-sets:delete")
def test_delete_quota_set(self):
project_name = data_utils.rand_name('project')
project_name = data_utils.rand_name(
self.__class__.__name__ + '-project')
project = self.projects_client.create_project(name=project_name)
project_id = project['project']['id']
self.addCleanup(test_utils.call_and_ignore_notfound_exc,

View File

@ -174,7 +174,7 @@ class ComputeServersRbacTest(base.BaseV2ComputeRbacTest):
@decorators.idempotent_id('077b17cb-5621-43b9-8adf-5725f0d7a863')
def test_update_server(self):
server = self.create_test_server(wait_until='ACTIVE')
new_name = data_utils.rand_name('server')
new_name = data_utils.rand_name(self.__class__.__name__ + '-server')
self.rbac_utils.switch_role(self, toggle_rbac_role=True)
try:
self.client.update_server(server['id'], name=new_name)

View File

@ -44,7 +44,7 @@ class ServerTagsRbacTest(rbac_base.BaseV2ComputeRbacTest):
cls.server = cls.create_test_server(wait_until='ACTIVE')
def _add_tag_to_server(self):
tag_name = data_utils.rand_name('tag')
tag_name = data_utils.rand_name(self.__class__.__name__ + '-tag')
self.client.update_tag(self.server['id'], tag_name)
self.addCleanup(self.client.delete_all_tags, self.server['id'])
return tag_name
@ -89,7 +89,7 @@ class ServerTagsRbacTest(rbac_base.BaseV2ComputeRbacTest):
rule="os_compute_api:os-server-tags:update_all")
def test_update_all_tags(self):
self.rbac_utils.switch_role(self, toggle_rbac_role=True)
new_tag_name = data_utils.rand_name('tag')
new_tag_name = data_utils.rand_name(self.__class__.__name__ + '-tag')
self.client.update_all_tags(self.server['id'], [new_tag_name])['tags']
@decorators.idempotent_id('89d51936-e333-42f9-a045-132a4865ba1a')

View File

@ -78,7 +78,8 @@ class BaseIdentityRbacTest(base.BaseIdentityTest):
"""Creates a service and an endpoint for test."""
interface = 'public'
url = data_utils.rand_url()
region_name = data_utils.rand_name('region')
region_name = data_utils.rand_name(
cls.__name__ + '-region')
# Endpoint creation requires a service
if service is None:
service = cls.setup_test_service()
@ -104,7 +105,7 @@ class BaseIdentityRbacTest(base.BaseIdentityTest):
@classmethod
def setup_test_role(cls):
"""Set up a test role."""
name = data_utils.rand_name('test_role')
name = data_utils.rand_name(cls.__name__ + '-test_role')
role = cls.roles_client.create_role(name=name)['role']
cls.roles.append(role)
@ -113,9 +114,9 @@ class BaseIdentityRbacTest(base.BaseIdentityTest):
@classmethod
def setup_test_service(cls):
"""Setup a test service."""
name = data_utils.rand_name('service')
name = data_utils.rand_name(cls.__name__ + '-service')
serv_type = data_utils.rand_name('type')
desc = data_utils.rand_name('description')
desc = data_utils.rand_name(cls.__name__ + '-description')
service = cls.services_client.create_service(
name=name,
@ -138,7 +139,7 @@ class BaseIdentityRbacTest(base.BaseIdentityTest):
@classmethod
def setup_test_user(cls, password=None, **kwargs):
"""Set up a test user."""
username = data_utils.rand_name('test_user')
username = data_utils.rand_name(cls.__name__ + '-test_user')
email = username + '@testmail.tm'
user = cls.users_client.create_user(
@ -196,10 +197,11 @@ class BaseIdentityV2AdminRbacTest(BaseIdentityRbacTest):
@classmethod
def setup_test_tenant(cls):
"""Set up a test tenant."""
name = data_utils.rand_name('test_tenant')
name = data_utils.rand_name(cls.__name__ + '-test_tenant')
tenant = cls.tenants_client.create_tenant(
name=name,
description=data_utils.rand_name('desc'))['tenant']
description=data_utils.rand_name(
cls.__name__ + '-desc'))['tenant']
cls.tenants.append(tenant)
return tenant
@ -294,8 +296,9 @@ class BaseIdentityV3RbacTest(BaseIdentityRbacTest):
def setup_test_domain(cls):
"""Set up a test domain."""
domain = cls.domains_client.create_domain(
name=data_utils.rand_name('test_domain'),
description=data_utils.rand_name('desc'))['domain']
name=data_utils.rand_name(cls.__name__ + '-test_domain'),
description=data_utils.rand_name(
cls.__name__ + '-desc'))['domain']
cls.domains.append(domain)
return domain
@ -303,7 +306,7 @@ class BaseIdentityV3RbacTest(BaseIdentityRbacTest):
@classmethod
def setup_test_group(cls):
"""Creates a group for test."""
name = data_utils.rand_name('test_group')
name = data_utils.rand_name(cls.__name__ + '-test_group')
group = cls.groups_client.create_group(name=name)['group']
cls.groups.append(group)
@ -312,8 +315,9 @@ class BaseIdentityV3RbacTest(BaseIdentityRbacTest):
@classmethod
def setup_test_policy(cls):
"""Creates a policy for test."""
blob = data_utils.rand_name('test_blob')
policy_type = data_utils.rand_name('policy_type')
blob = data_utils.rand_name(cls.__name__ + '-test_blob')
policy_type = data_utils.rand_name(
cls.__name__ + '-policy_type')
policy = cls.policies_client.create_policy(
blob=blob,
@ -327,8 +331,10 @@ class BaseIdentityV3RbacTest(BaseIdentityRbacTest):
def setup_test_project(cls):
"""Set up a test project."""
project = cls.projects_client.create_project(
name=data_utils.rand_name('test_project'),
description=data_utils.rand_name('desc'))['project']
name=data_utils.rand_name(
cls.__name__ + '-testproject'),
description=data_utils.rand_name(
cls.__name__ + '-desc'))['project']
cls.projects.append(project)
return project
@ -336,7 +342,8 @@ class BaseIdentityV3RbacTest(BaseIdentityRbacTest):
@classmethod
def setup_test_region(cls):
"""Creates a region for test."""
description = data_utils.rand_name('test_region_desc')
description = data_utils.rand_name(
cls.__name__ + '-test_region_desc')
region = cls.regions_client.create_region(
description=description)['region']

View File

@ -34,7 +34,8 @@ class IdentityDomainsV3RbacTest(rbac_base.BaseIdentityV3RbacTest):
@decorators.idempotent_id('6bdaecd4-0843-4ed6-ab64-3a57ab0cd111')
def test_update_domain(self):
domain = self.setup_test_domain()
new_domain_name = data_utils.rand_name('test_update_domain')
new_domain_name = data_utils.rand_name(
self.__class__.__name__ + '-test_update_domain')
self.rbac_utils.switch_role(self, toggle_rbac_role=True)
self.domains_client.update_domain(domain['id'],
domain=domain,

View File

@ -41,7 +41,8 @@ class IdentityGroupsV3RbacTest(rbac_base.BaseIdentityV3RbacTest):
@decorators.idempotent_id('790fb7be-a657-4a64-9b83-c43425cf180b')
def test_update_group(self):
group = self.setup_test_group()
new_group_name = data_utils.rand_name('group')
new_group_name = data_utils.rand_name(
self.__class__.__name__ + '-group')
self.rbac_utils.switch_role(self, toggle_rbac_role=True)
self.groups_client.update_group(group['id'],

View File

@ -24,7 +24,8 @@ from patrole_tempest_plugin.tests.api.identity import rbac_base
class IdentityConsumersV3RbacTest(rbac_base.BaseIdentityV3RbacTest):
def _create_consumer(self):
description = data_utils.rand_name('test_create_consumer')
description = data_utils.rand_name(
self.__class__.__name__ + '-test_consumer')
consumer = self.consumers_client.create_consumer(
description)['consumer']
self.addCleanup(test_utils.call_and_ignore_notfound_exc,
@ -53,7 +54,8 @@ class IdentityConsumersV3RbacTest(rbac_base.BaseIdentityV3RbacTest):
@decorators.idempotent_id('0f148510-63bf-11e6-4522-080044d0d972')
def test_update_consumer(self):
consumer = self._create_consumer()
new_description = data_utils.rand_name('test_update_consumer')
new_description = data_utils.rand_name(
self.__class__.__name__ + '-test_consumer')
self.rbac_utils.switch_role(self, toggle_rbac_role=True)
self.consumers_client.update_consumer(consumer['id'],

View File

@ -34,7 +34,8 @@ class IdentityPoliciesV3RbacTest(rbac_base.BaseIdentityV3RbacTest):
@decorators.idempotent_id('9cfed3c6-0b27-4d15-be67-e06e0cfb01b9')
def test_update_policy(self):
policy = self.setup_test_policy()
updated_policy_type = data_utils.rand_name('policy_type')
updated_policy_type = data_utils.rand_name(
self.__class__.__name__ + '-policy_type')
self.rbac_utils.switch_role(self, toggle_rbac_role=True)
self.policies_client.update_policy(policy['id'],

View File

@ -34,7 +34,8 @@ class IdentityProjectV3RbacTest(rbac_base.BaseIdentityV3RbacTest):
@decorators.idempotent_id('0f148510-63bf-11e6-1564-080044d0d905')
def test_update_project(self):
project = self.setup_test_project()
new_desc = data_utils.rand_name('description')
new_desc = data_utils.rand_name(
self.__class__.__name__ + '-description')
self.rbac_utils.switch_role(self, toggle_rbac_role=True)
self.projects_client.update_project(project['id'],

View File

@ -34,7 +34,8 @@ class IdentityRegionsV3RbacTest(rbac_base.BaseIdentityV3RbacTest):
@decorators.idempotent_id('6bdaecd4-0843-4ed6-ab64-3a57ab0cd120')
def test_update_region(self):
region = self.setup_test_region()
new_description = data_utils.rand_name('test_update_region')
new_description = data_utils.rand_name(
self.__class__.__name__ + '-test_update_region')
self.rbac_utils.switch_role(self, toggle_rbac_role=True)
self.regions_client.update_region(region['id'],

View File

@ -44,7 +44,8 @@ class IdentityRolesV3RbacTest(rbac_base.BaseIdentityV3RbacTest):
rule="identity:update_role")
@decorators.idempotent_id('0f148510-63bf-11e6-1395-080044d0d905')
def test_update_role(self):
new_role_name = data_utils.rand_name('test_update_role')
new_role_name = data_utils.rand_name(
self.__class__.__name__ + '-test_update_role')
self.rbac_utils.switch_role(self, toggle_rbac_role=True)
self.roles_client.update_role(self.role['id'],

View File

@ -34,7 +34,7 @@ class IdentitySericesV3RbacTest(rbac_base.BaseIdentityV3RbacTest):
@decorators.idempotent_id('b39447d1-2cf6-40e5-a899-46f287f2ecf0')
def test_update_service(self):
service = self.setup_test_service()
new_name = data_utils.rand_name('service')
new_name = data_utils.rand_name(self.__class__.__name__ + '-service')
self.rbac_utils.switch_role(self, toggle_rbac_role=True)
self.services_client.update_service(service['id'],

View File

@ -39,7 +39,8 @@ class IdentityUserV3AdminRbacTest(rbac_base.BaseIdentityV3RbacTest):
@decorators.idempotent_id('0f148510-63bf-11e6-4522-080044d0d905')
def test_update_user(self):
user = self.setup_test_user()
new_email = data_utils.rand_name('user_email')
new_email = data_utils.rand_name(
self.__class__.__name__ + '-user_email')
self.rbac_utils.switch_role(self, toggle_rbac_role=True)
self.users_client.update_user(user['id'],

View File

@ -35,7 +35,7 @@ class BasicOperationsImagesRbacTest(rbac_base.BaseV1ImageRbacTest):
RBAC test for the glance add_image policy.
"""
properties = {'prop1': 'val1'}
image_name = data_utils.rand_name('image')
image_name = data_utils.rand_name(self.__class__.__name__ + '-Image')
self.rbac_utils.switch_role(self, toggle_rbac_role=True)
self.create_image(name=image_name,
container_format='bare',
@ -50,7 +50,7 @@ class BasicOperationsImagesRbacTest(rbac_base.BaseV1ImageRbacTest):
RBAC test for the glance delete_image policy.
"""
image_name = data_utils.rand_name('image')
image_name = data_utils.rand_name(self.__class__.__name__ + '-Image')
properties = {'prop1': 'val1'}
body = self.create_image(name=image_name,
container_format='bare',
@ -68,7 +68,7 @@ class BasicOperationsImagesRbacTest(rbac_base.BaseV1ImageRbacTest):
RBAC test for the glance download_image policy.
"""
image_name = data_utils.rand_name('image')
image_name = data_utils.rand_name(self.__class__.__name__ + '-Image')
properties = {'prop1': 'val1'}
body = self.create_image(name=image_name,
container_format='bare',
@ -90,7 +90,7 @@ class BasicOperationsImagesRbacTest(rbac_base.BaseV1ImageRbacTest):
RBAC test for the glance get_image policy.
"""
image_name = data_utils.rand_name('image')
image_name = data_utils.rand_name(self.__class__.__name__ + '-Image')
properties = {'prop1': 'val1'}
body = self.create_image(name=image_name,
container_format='bare',
@ -122,7 +122,7 @@ class BasicOperationsImagesRbacTest(rbac_base.BaseV1ImageRbacTest):
RBAC test for the glance modify_image policy.
"""
image_name = data_utils.rand_name('image')
image_name = data_utils.rand_name(self.__class__.__name__ + '-Image')
properties = {'prop1': 'val1'}
body = self.create_image(name=image_name,
container_format='bare',
@ -141,7 +141,7 @@ class BasicOperationsImagesRbacTest(rbac_base.BaseV1ImageRbacTest):
RBAC test for the glance publicize_image policy.
"""
image_name = data_utils.rand_name('image')
image_name = data_utils.rand_name(self.__class__.__name__ + '-Image')
properties = {'prop1': 'val1'}
self.rbac_utils.switch_role(self, toggle_rbac_role=True)
self.create_image(name=image_name,

View File

@ -35,7 +35,8 @@ class ImageNamespacesObjectsRbacTest(rbac_base.BaseV2ImageRbacTest):
self.rbac_utils.switch_role(self, toggle_rbac_role=True)
# create a md object, it will be cleaned automatically after
# cleanup of namespace
object_name = data_utils.rand_name('test-object')
object_name = data_utils.rand_name(
self.__class__.__name__ + '-test-object')
self.namespace_objects_client.create_namespace_object(
namespace['namespace'],
name=object_name)
@ -66,7 +67,8 @@ class ImageNamespacesObjectsRbacTest(rbac_base.BaseV2ImageRbacTest):
RBAC test for the glance modify_metadef_object policy
"""
namespace = self.create_namespace()
object_name = data_utils.rand_name('test-object')
object_name = data_utils.rand_name(
self.__class__.__name__ + '-test-object')
self.namespace_objects_client.create_namespace_object(
namespace['namespace'],
name=object_name)
@ -89,7 +91,8 @@ class ImageNamespacesObjectsRbacTest(rbac_base.BaseV2ImageRbacTest):
RBAC test for the glance get_metadef_object policy
"""
namespace = self.create_namespace()
object_name = data_utils.rand_name('test-object')
object_name = data_utils.rand_name(
self.__class__.__name__ + '-test-object')
self.namespace_objects_client.create_namespace_object(
namespace['namespace'],
name=object_name)

View File

@ -38,7 +38,8 @@ class NamespacesPropertyRbacTest(rbac_base.BaseV2ImageRbacTest):
"""
namespace = self.create_namespace()
self.rbac_utils.switch_role(self, toggle_rbac_role=True)
property_name = data_utils.rand_name('test-ns-property')
property_name = data_utils.rand_name(
self.__class__.__name__ + '-test-ns-property')
self.namespace_properties_client.create_namespace_property(
namespace=namespace['namespace'], type="string",
title=property_name, name=self.resource_name)
@ -65,7 +66,8 @@ class NamespacesPropertyRbacTest(rbac_base.BaseV2ImageRbacTest):
RBAC test for the glance get_metadef_property policy
"""
namespace = self.create_namespace()
property_name = data_utils.rand_name('test-ns-property')
property_name = data_utils.rand_name(
self.__class__.__name__ + '-test-ns-property')
self.namespace_properties_client.create_namespace_property(
namespace=namespace['namespace'], type="string",
title=property_name, name=self.resource_name)
@ -83,7 +85,8 @@ class NamespacesPropertyRbacTest(rbac_base.BaseV2ImageRbacTest):
RBAC test for the glance modify_metadef_property policy
"""
namespace = self.create_namespace()
property_name = data_utils.rand_name('test-ns-property')
property_name = data_utils.rand_name(
self.__class__.__name__ + '-test-ns-property')
self.namespace_properties_client.create_namespace_property(
namespace=namespace['namespace'], type="string",
title=property_name, name=self.resource_name)

View File

@ -31,7 +31,8 @@ class ImageNamespacesRbacTest(rbac_base.BaseV2ImageRbacTest):
RBAC test for the glance add_metadef_namespace policy
"""
namespace_name = data_utils.rand_name('test-ns')
namespace_name = data_utils.rand_name(
self.__class__.__name__ + '-test-ns')
self.rbac_utils.switch_role(self, toggle_rbac_role=True)
self.namespaces_client.create_namespace(
namespace=namespace_name,
@ -60,7 +61,8 @@ class ImageNamespacesRbacTest(rbac_base.BaseV2ImageRbacTest):
RBAC test for the glance modify_metadef_namespace policy
"""
namespace_name = data_utils.rand_name('test-ns')
namespace_name = data_utils.rand_name(
self.__class__.__name__ + '-test-ns')
body = self.namespaces_client.create_namespace(
namespace=namespace_name,
protected=False)

View File

@ -42,7 +42,8 @@ class NamespaceTagsRbacTest(base.BaseV2ImageRbacTest):
def resource_setup(cls):
super(NamespaceTagsRbacTest, cls).resource_setup()
cls.namespace = cls.namespaces_client.create_namespace(
namespace=data_utils.rand_name('namespace'))['namespace']
namespace=data_utils.rand_name(
cls.__name__ + '-namespace'))['namespace']
@classmethod
def resource_cleanup(cls):
@ -54,7 +55,7 @@ class NamespaceTagsRbacTest(base.BaseV2ImageRbacTest):
namespace_tag_names = []
for i in range(tag_count):
tag_name = data_utils.rand_name('tag')
tag_name = data_utils.rand_name(self.__class__.__name__ + '-tag')
namespace_tag_names.append({'name': tag_name})
if multiple:
@ -91,7 +92,8 @@ class NamespaceTagsRbacTest(base.BaseV2ImageRbacTest):
rule="modify_metadef_tag")
def test_update_namespace_tag(self):
tag_name = self._create_namespace_tag()
updated_tag_name = data_utils.rand_name('tag')
updated_tag_name = data_utils.rand_name(
self.__class__.__name__ + '-tag')
self.rbac_utils.switch_role(self, toggle_rbac_role=True)
self.client.update_namespace_tag(self.namespace, tag_name,

View File

@ -26,7 +26,8 @@ class ImageResourceTypesRbacTest(rbac_base.BaseV2ImageRbacTest):
@classmethod
def resource_setup(cls):
super(ImageResourceTypesRbacTest, cls).resource_setup()
cls.namespace_name = data_utils.rand_name('test-ns')
cls.namespace_name = data_utils.rand_name(
cls.__name__ + '-test-ns')
cls.namespaces_client.create_namespace(
namespace=cls.namespace_name,
protected=False)

View File

@ -30,7 +30,7 @@ class BasicOperationsImagesRbacTest(rbac_base.BaseV2ImageRbacTest):
cls.client = cls.os_primary.image_client_v2
def _create_image(self, **kwargs):
image_name = data_utils.rand_name('image')
image_name = data_utils.rand_name(self.__class__.__name__ + '-Image')
image = self.create_image(name=image_name,
container_format='bare',
disk_format='raw',
@ -135,7 +135,8 @@ class BasicOperationsImagesRbacTest(rbac_base.BaseV2ImageRbacTest):
image = self._create_image()
self.rbac_utils.switch_role(self, toggle_rbac_role=True)
updated_image_name = data_utils.rand_name('image')
updated_image_name = data_utils.rand_name(
self.__class__.__name__ + '-image')
self.client.update_image(image['id'], [
dict(replace='/name', value=updated_image_name)])
@ -151,7 +152,9 @@ class BasicOperationsImagesRbacTest(rbac_base.BaseV2ImageRbacTest):
image = self._create_image()
self.rbac_utils.switch_role(self, toggle_rbac_role=True)
self.client.add_image_tag(image['id'], data_utils.rand_name('tag'))
self.client.add_image_tag(
image['id'],
data_utils.rand_name(self.__class__.__name__ + '-tag'))
@decorators.idempotent_id('c4a0bf9c-b78b-48c6-a31f-72c95f943c6e')
@rbac_rule_validation.action(service="glance",
@ -163,7 +166,7 @@ class BasicOperationsImagesRbacTest(rbac_base.BaseV2ImageRbacTest):
RBAC test for the glance delete_image_tag endpoint
"""
image = self._create_image()
tag_name = data_utils.rand_name('tag')
tag_name = data_utils.rand_name(self.__class__.__name__ + '-tag')
self.client.add_image_tag(image['id'], tag_name)
self.rbac_utils.switch_role(self, toggle_rbac_role=True)

View File

@ -33,7 +33,8 @@ class RbacNetworksTest(base.BaseNetworkRbacTest):
def resource_setup(cls):
super(RbacNetworksTest, cls).resource_setup()
network_name = data_utils.rand_name('rbac-admin-network-')
network_name = data_utils.rand_name(
cls.__name__ + '-rbac-admin-network-')
post_body = {'name': network_name}
body = cls.networks_client.create_network(**post_body)
@ -65,7 +66,8 @@ class RbacNetworksTest(base.BaseNetworkRbacTest):
provider_physical_network=None,
provider_segmentation_id=None):
network_name = data_utils.rand_name('test-network-')
network_name = data_utils.rand_name(
self.__class__.__name__ + '-test-network-')
post_body = {'name': network_name}
if shared is not None:

View File

@ -74,7 +74,7 @@ class RouterRbacTest(base.BaseNetworkRbacTest):
RBAC test for the neutron
create_router:external_gateway_info:enable_snat policy
"""
name = data_utils.rand_name('snat-router')
name = data_utils.rand_name(self.__class__.__name__ + '-snat-router')
external_gateway_info = {'network_id': self.network['id'],
'enable_snat': True}
@ -94,7 +94,7 @@ class RouterRbacTest(base.BaseNetworkRbacTest):
RBAC test for the neutron
create_router:external_gateway_info:external_fixed_ips policy
"""
name = data_utils.rand_name('snat-router')
name = data_utils.rand_name(self.__class__.__name__ + '-snat-router')
# Pick an unused IP address.
ip_list = net_utils.get_unused_ip_addresses(self.ports_client,
@ -134,7 +134,8 @@ class RouterRbacTest(base.BaseNetworkRbacTest):
RBAC test for the neutron update_router policy
"""
new_name = data_utils.rand_name('new-router-name')
new_name = data_utils.rand_name(self.__class__.__name__ +
'-new-router-name')
self.rbac_utils.switch_role(self, toggle_rbac_role=True)
self.routers_client.update_router(self.router['id'],
name=new_name)

View File

@ -30,7 +30,7 @@ class SecGroupRbacTest(base.BaseNetworkRbacTest):
@classmethod
def resource_setup(cls):
super(SecGroupRbacTest, cls).resource_setup()
secgroup_name = data_utils.rand_name('secgroup')
secgroup_name = data_utils.rand_name(cls.__name__ + '-secgroup')
cls.secgroup = cls.security_groups_client.create_security_group(
name=secgroup_name)['security_group']
@ -44,7 +44,7 @@ class SecGroupRbacTest(base.BaseNetworkRbacTest):
def _create_security_group(self):
# Create a security group
name = data_utils.rand_name('secgroup')
name = data_utils.rand_name(self.__class__.__name__ + '-secgroup')
security_group =\
self.security_groups_client.create_security_group(
name=name)['security_group']

View File

@ -36,8 +36,10 @@ class MessagesV3RbacTest(rbac_base.BaseVolumeRbacTest):
def _create_user_message(self):
"""Trigger a 'no valid host' situation to generate a message."""
bad_protocol = data_utils.rand_name('storage_protocol')
bad_vendor = data_utils.rand_name('vendor_name')
bad_protocol = data_utils.rand_name(
self.__class__.__name__ + '-storage_protocol')
bad_vendor = data_utils.rand_name(
self.__class__.__name__ + '-vendor_name')
extra_specs = {'storage_protocol': bad_protocol,
'vendor_name': bad_vendor}
vol_type_name = data_utils.rand_name(

View File

@ -58,7 +58,7 @@ class VolumesV2BasicCrudRbacTest(rbac_base.BaseVolumeRbacTest):
@rbac_rule_validation.action(service="cinder", rule="volume:update")
@decorators.idempotent_id('b751b889-9a9b-40d8-ae7d-4b0f65e71ac7')
def test_update_volume(self):
update_name = data_utils.rand_name('volume')
update_name = data_utils.rand_name(self.__class__.__name__ + 'volume')
self.rbac_utils.switch_role(self, toggle_rbac_role=True)
self.volumes_client.update_volume(self.volume['id'],
name=update_name)

View File

@ -43,7 +43,7 @@ class VolumesBackupsRbacTest(rbac_base.BaseVolumeRbacTest):
cls.volume = cls.create_volume()
def _create_backup(self, volume_id):
backup_name = data_utils.rand_name('backup')
backup_name = data_utils.rand_name(self.__class__.__name__ + 'backup')
backup = self.backups_client.create_backup(
volume_id=volume_id, name=backup_name)['backup']
self.addCleanup(