Merge "Make rest_client.wait_for_resource_deletion timeout error more specific"

This commit is contained in:
Jenkins 2014-10-15 17:12:33 +00:00 committed by Gerrit Code Review
commit 9aeebd7ce0
24 changed files with 124 additions and 3 deletions

View File

@ -568,9 +568,10 @@ class RestClient(object):
if self.is_resource_deleted(id):
return
if int(time.time()) - start_time >= self.build_timeout:
message = ('Failed to delete resource %(id)s within the '
'required time (%(timeout)s s).' %
{'id': id, 'timeout': self.build_timeout})
message = ('Failed to delete %(resource_type)s %(id)s within '
'the required time (%(timeout)s s).' %
{'resource_type': self.resource_type, 'id': id,
'timeout': self.build_timeout})
caller = misc_utils.find_test_caller()
if caller:
message = '(%s) %s' % (caller, message)
@ -585,6 +586,11 @@ class RestClient(object):
% self.__class__.__name__)
raise NotImplementedError(message)
@property
def resource_type(self):
"""Returns the primary type of resource this client works with."""
return 'resource'
@classmethod
def validate_response(cls, schema, resp, body):
# Only check the response if the status code is a success code

View File

@ -79,6 +79,11 @@ class AggregatesClientJSON(rest_client.RestClient):
return True
return False
@property
def resource_type(self):
"""Returns the primary type of resource this client works with."""
return 'aggregate'
def add_host(self, aggregate_id, host):
"""Adds a host to the given aggregate."""
post_body = {

View File

@ -99,6 +99,11 @@ class FlavorsClientJSON(rest_client.RestClient):
return False
return True
@property
def resource_type(self):
"""Returns the primary type of resource this client works with."""
return 'flavor'
def set_flavor_extra_spec(self, flavor_id, specs):
"""Sets extra Specs to the mentioned flavor."""
post_body = json.dumps({'extra_specs': specs})

View File

@ -102,6 +102,11 @@ class FloatingIPsClientJSON(rest_client.RestClient):
return True
return False
@property
def resource_type(self):
"""Returns the primary type of resource this client works with."""
return 'floating_ip'
def list_floating_ip_pools(self, params=None):
"""Returns a list of all floating IP Pools."""
url = 'os-floating-ip-pools'

View File

@ -143,3 +143,8 @@ class ImagesClientJSON(rest_client.RestClient):
except exceptions.NotFound:
return True
return False
@property
def resource_type(self):
"""Returns the primary type of resource this client works with."""
return 'image'

View File

@ -143,3 +143,8 @@ class SecurityGroupsClientJSON(rest_client.RestClient):
except exceptions.NotFound:
return True
return False
@property
def resource_type(self):
"""Returns the primary type of resource this client works with."""
return 'security_group'

View File

@ -116,3 +116,8 @@ class VolumesExtensionsClientJSON(rest_client.RestClient):
except exceptions.NotFound:
return True
return False
@property
def resource_type(self):
"""Returns the primary type of resource this client works with."""
return 'volume'

View File

@ -79,6 +79,11 @@ class AggregatesV3ClientJSON(rest_client.RestClient):
return True
return False
@property
def resource_type(self):
"""Returns the primary type of resource this client works with."""
return 'aggregate'
def add_host(self, aggregate_id, host):
"""Adds a host to the given aggregate."""
post_body = {

View File

@ -99,6 +99,11 @@ class FlavorsV3ClientJSON(rest_client.RestClient):
return False
return True
@property
def resource_type(self):
"""Returns the primary type of resource this client works with."""
return 'flavor'
def set_flavor_extra_spec(self, flavor_id, specs):
"""Sets extra Specs to the mentioned flavor."""
post_body = json.dumps({'extra_specs': specs})

View File

@ -94,6 +94,11 @@ class AggregatesClientXML(rest_client.RestClient):
return True
return False
@property
def resource_type(self):
"""Returns the primary type of resource this client works with."""
return 'aggregate'
def add_host(self, aggregate_id, host):
"""Adds a host to the given aggregate."""
post_body = xml_utils.Element("add_host", host=host)

View File

@ -136,6 +136,11 @@ class FlavorsClientXML(rest_client.RestClient):
return False
return True
@property
def resource_type(self):
"""Returns the primary type of resource this client works with."""
return 'flavor'
def set_flavor_extra_spec(self, flavor_id, specs):
"""Sets extra Specs to the mentioned flavor."""
extra_specs = xml_utils.Element("extra_specs")

View File

@ -108,6 +108,11 @@ class FloatingIPsClientXML(rest_client.RestClient):
return True
return False
@property
def resource_type(self):
"""Returns the primary type of resource this client works with."""
return 'floating_ip'
def list_floating_ip_pools(self, params=None):
"""Returns a list of all floating IP Pools."""
url = 'os-floating-ip-pools'

View File

@ -204,3 +204,8 @@ class ImagesClientXML(rest_client.RestClient):
except exceptions.NotFound:
return True
return False
@property
def resource_type(self):
"""Returns the primary type of resource this client works with."""
return 'image'

View File

@ -159,3 +159,8 @@ class SecurityGroupsClientXML(rest_client.RestClient):
except exceptions.NotFound:
return True
return False
@property
def resource_type(self):
"""Returns the primary type of resource this client works with."""
return 'security_group'

View File

@ -141,3 +141,8 @@ class VolumesExtensionsClientXML(rest_client.RestClient):
except exceptions.NotFound:
return True
return False
@property
def resource_type(self):
"""Returns the primary type of resource this client works with."""
return 'volume'

View File

@ -240,6 +240,11 @@ class ImageClientJSON(rest_client.RestClient):
return True
return False
@property
def resource_type(self):
"""Returns the primary type of resource this client works with."""
return 'image_meta'
def get_image_membership(self, image_id):
url = 'v1/images/%s/members' % image_id
resp, body = self.get(url)

View File

@ -117,6 +117,11 @@ class ImageClientV2JSON(rest_client.RestClient):
return True
return False
@property
def resource_type(self):
"""Returns the primary type of resource this client works with."""
return 'image'
def store_image(self, image_id, data):
url = 'v2/images/%s/file' % image_id
headers = {'Content-Type': 'application/octet-stream'}

View File

@ -55,6 +55,11 @@ class VolumeTypesClientJSON(rest_client.RestClient):
return True
return False
@property
def resource_type(self):
"""Returns the primary type of resource this client works with."""
return 'volume-type/encryption-type'
def list_volume_types(self, params=None):
"""List all the volume_types created."""
url = 'types'

View File

@ -38,6 +38,11 @@ class BaseQosSpecsClientJSON(rest_client.RestClient):
return True
return False
@property
def resource_type(self):
"""Returns the primary type of resource this client works with."""
return 'qos'
def wait_for_qos_operations(self, qos_id, operation, args=None):
"""Waits for a qos operations to be completed.

View File

@ -138,6 +138,11 @@ class BaseSnapshotsClientJSON(rest_client.RestClient):
return True
return False
@property
def resource_type(self):
"""Returns the primary type of resource this client works with."""
return 'volume-snapshot'
def reset_snapshot_status(self, snapshot_id, status):
"""Reset the specified snapshot's status."""
post_body = json.dumps({'os-reset_status': {"status": status}})

View File

@ -187,6 +187,11 @@ class BaseVolumesClientJSON(rest_client.RestClient):
return True
return False
@property
def resource_type(self):
"""Returns the primary type of resource this client works with."""
return 'volume'
def extend_volume(self, volume_id, extend_size):
"""Extend a volume."""
post_body = {

View File

@ -205,3 +205,8 @@ class VolumeTypesClientXML(rest_client.RestClient):
except exceptions.NotFound:
return True
return False
@property
def resource_type(self):
"""Returns the primary type of resource this client works with."""
return 'volume-type'

View File

@ -153,6 +153,11 @@ class BaseSnapshotsClientXML(rest_client.RestClient):
return True
return False
@property
def resource_type(self):
"""Returns the primary type of resource this client works with."""
return 'volume-snapshot'
def reset_snapshot_status(self, snapshot_id, status):
"""Reset the specified snapshot's status."""
post_body = common.Element("os-reset_status", status=status)

View File

@ -226,6 +226,11 @@ class BaseVolumesClientXML(rest_client.RestClient):
return True
return False
@property
def resource_type(self):
"""Returns the primary type of resource this client works with."""
return 'volume'
def attach_volume(self, volume_id, instance_uuid, mountpoint):
"""Attaches a volume to a given instance on a given mountpoint."""
post_body = common.Element("os-attach",