Merge "Change compute image client methods to return one value"
diff --git a/tempest/api/compute/base.py b/tempest/api/compute/base.py
index 4f2715f..6b6c8e7 100644
--- a/tempest/api/compute/base.py
+++ b/tempest/api/compute/base.py
@@ -293,20 +293,20 @@
if 'name' in kwargs:
name = kwargs.pop('name')
- resp, image = cls.images_client.create_image(server_id, name)
- image_id = data_utils.parse_image_id(resp['location'])
+ image = cls.images_client.create_image(server_id, name)
+ image_id = data_utils.parse_image_id(image.response['location'])
cls.images.append(image_id)
if 'wait_until' in kwargs:
cls.images_client.wait_for_image_status(image_id,
kwargs['wait_until'])
- resp, image = cls.images_client.get_image(image_id)
+ image = cls.images_client.get_image(image_id)
if kwargs['wait_until'] == 'ACTIVE':
if kwargs.get('wait_for_server', True):
cls.servers_client.wait_for_server_status(server_id,
'ACTIVE')
- return resp, image
+ return image
@classmethod
def rebuild_server(cls, server_id, **kwargs):
diff --git a/tempest/api/compute/images/test_image_metadata.py b/tempest/api/compute/images/test_image_metadata.py
index 38e55b1..e45e941 100644
--- a/tempest/api/compute/images/test_image_metadata.py
+++ b/tempest/api/compute/images/test_image_metadata.py
@@ -50,13 +50,12 @@
def setUp(self):
super(ImagesMetadataTestJSON, self).setUp()
meta = {'key1': 'value1', 'key2': 'value2'}
- resp, _ = self.client.set_image_metadata(self.image_id, meta)
- self.assertEqual(resp.status, 200)
+ self.client.set_image_metadata(self.image_id, meta)
@test.attr(type='gate')
def test_list_image_metadata(self):
# All metadata key/value pairs for an image should be returned
- resp, resp_metadata = self.client.list_image_metadata(self.image_id)
+ resp_metadata = self.client.list_image_metadata(self.image_id)
expected = {'key1': 'value1', 'key2': 'value2'}
self.assertEqual(expected, resp_metadata)
@@ -64,28 +63,28 @@
def test_set_image_metadata(self):
# The metadata for the image should match the new values
req_metadata = {'meta2': 'value2', 'meta3': 'value3'}
- resp, body = self.client.set_image_metadata(self.image_id,
- req_metadata)
+ self.client.set_image_metadata(self.image_id,
+ req_metadata)
- resp, resp_metadata = self.client.list_image_metadata(self.image_id)
+ resp_metadata = self.client.list_image_metadata(self.image_id)
self.assertEqual(req_metadata, resp_metadata)
@test.attr(type='gate')
def test_update_image_metadata(self):
# The metadata for the image should match the updated values
req_metadata = {'key1': 'alt1', 'key3': 'value3'}
- resp, metadata = self.client.update_image_metadata(self.image_id,
- req_metadata)
+ self.client.update_image_metadata(self.image_id,
+ req_metadata)
- resp, resp_metadata = self.client.list_image_metadata(self.image_id)
+ resp_metadata = self.client.list_image_metadata(self.image_id)
expected = {'key1': 'alt1', 'key2': 'value2', 'key3': 'value3'}
self.assertEqual(expected, resp_metadata)
@test.attr(type='gate')
def test_get_image_metadata_item(self):
# The value for a specific metadata key should be returned
- resp, meta = self.client.get_image_metadata_item(self.image_id,
- 'key2')
+ meta = self.client.get_image_metadata_item(self.image_id,
+ 'key2')
self.assertEqual('value2', meta['key2'])
@test.attr(type='gate')
@@ -93,17 +92,17 @@
# The value provided for the given meta item should be set for
# the image
meta = {'key1': 'alt'}
- resp, body = self.client.set_image_metadata_item(self.image_id,
- 'key1', meta)
- resp, resp_metadata = self.client.list_image_metadata(self.image_id)
+ self.client.set_image_metadata_item(self.image_id,
+ 'key1', meta)
+ resp_metadata = self.client.list_image_metadata(self.image_id)
expected = {'key1': 'alt', 'key2': 'value2'}
self.assertEqual(expected, resp_metadata)
@test.attr(type='gate')
def test_delete_image_metadata_item(self):
# The metadata value/key pair should be deleted from the image
- resp, body = self.client.delete_image_metadata_item(self.image_id,
- 'key1')
- resp, resp_metadata = self.client.list_image_metadata(self.image_id)
+ self.client.delete_image_metadata_item(self.image_id,
+ 'key1')
+ resp_metadata = self.client.list_image_metadata(self.image_id)
expected = {'key2': 'value2'}
self.assertEqual(expected, resp_metadata)
diff --git a/tempest/api/compute/images/test_images.py b/tempest/api/compute/images/test_images.py
index 51dae65..dc27a70 100644
--- a/tempest/api/compute/images/test_images.py
+++ b/tempest/api/compute/images/test_images.py
@@ -42,8 +42,7 @@
snapshot_name = data_utils.rand_name('test-snap-')
resp, server = self.create_test_server(wait_until='ACTIVE')
self.addCleanup(self.servers_client.delete_server, server['id'])
- resp, image = self.create_image_from_server(server['id'],
- name=snapshot_name,
- wait_until='SAVING')
- resp, body = self.client.delete_image(image['id'])
- self.assertEqual('204', resp['status'])
+ image = self.create_image_from_server(server['id'],
+ name=snapshot_name,
+ wait_until='SAVING')
+ self.client.delete_image(image['id'])
diff --git a/tempest/api/compute/images/test_images_negative.py b/tempest/api/compute/images/test_images_negative.py
index 9570ca5..58fc20d 100644
--- a/tempest/api/compute/images/test_images_negative.py
+++ b/tempest/api/compute/images/test_images_negative.py
@@ -72,10 +72,10 @@
'SHUTOFF')
self.addCleanup(self.servers_client.delete_server, server['id'])
snapshot_name = data_utils.rand_name('test-snap-')
- resp, image = self.create_image_from_server(server['id'],
- name=snapshot_name,
- wait_until='ACTIVE',
- wait_for_server=False)
+ image = self.create_image_from_server(server['id'],
+ name=snapshot_name,
+ wait_until='ACTIVE',
+ wait_for_server=False)
self.addCleanup(self.client.delete_image, image['id'])
self.assertEqual(snapshot_name, image['name'])
diff --git a/tempest/api/compute/images/test_images_oneserver.py b/tempest/api/compute/images/test_images_oneserver.py
index 91e0423..6156c5a 100644
--- a/tempest/api/compute/images/test_images_oneserver.py
+++ b/tempest/api/compute/images/test_images_oneserver.py
@@ -72,17 +72,16 @@
# Create a new image
name = data_utils.rand_name('image')
meta = {'image_type': 'test'}
- resp, body = self.client.create_image(self.server_id, name, meta)
- self.assertEqual(202, resp.status)
- image_id = data_utils.parse_image_id(resp['location'])
+ body = self.client.create_image(self.server_id, name, meta)
+ image_id = data_utils.parse_image_id(body.response['location'])
self.client.wait_for_image_status(image_id, 'ACTIVE')
# Verify the image was created correctly
- resp, image = self.client.get_image(image_id)
+ image = self.client.get_image(image_id)
self.assertEqual(name, image['name'])
self.assertEqual('test', image['metadata']['image_type'])
- resp, original_image = self.client.get_image(self.image_ref)
+ original_image = self.client.get_image(self.image_ref)
# Verify minRAM is the same as the original image
self.assertEqual(image['minRam'], original_image['minRam'])
@@ -93,8 +92,7 @@
(str(original_image['minDisk']), str(flavor_disk_size)))
# Verify the image was deleted correctly
- resp, body = self.client.delete_image(image_id)
- self.assertEqual('204', resp['status'])
+ self.client.delete_image(image_id)
self.client.wait_for_resource_deletion(image_id)
@test.attr(type=['gate'])
@@ -106,7 +104,6 @@
# #1370954 in glance which will 500 if mysql is used as the
# backend and it attempts to store a 4 byte utf-8 character
utf8_name = data_utils.rand_name('\xe2\x82\xa1')
- resp, body = self.client.create_image(self.server_id, utf8_name)
- image_id = data_utils.parse_image_id(resp['location'])
+ body = self.client.create_image(self.server_id, utf8_name)
+ image_id = data_utils.parse_image_id(body.response['location'])
self.addCleanup(self.client.delete_image, image_id)
- self.assertEqual('202', resp['status'])
diff --git a/tempest/api/compute/images/test_images_oneserver_negative.py b/tempest/api/compute/images/test_images_oneserver_negative.py
index ae6e712..46cec9b 100644
--- a/tempest/api/compute/images/test_images_oneserver_negative.py
+++ b/tempest/api/compute/images/test_images_oneserver_negative.py
@@ -94,10 +94,9 @@
# Create first snapshot
snapshot_name = data_utils.rand_name('test-snap-')
- resp, body = self.client.create_image(self.server_id,
- snapshot_name)
- self.assertEqual(202, resp.status)
- image_id = data_utils.parse_image_id(resp['location'])
+ body = self.client.create_image(self.server_id,
+ snapshot_name)
+ image_id = data_utils.parse_image_id(body.response['location'])
self.image_ids.append(image_id)
self.addCleanup(self._reset_server)
@@ -119,15 +118,13 @@
# Return an error while trying to delete an image what is creating
snapshot_name = data_utils.rand_name('test-snap-')
- resp, body = self.client.create_image(self.server_id, snapshot_name)
- self.assertEqual(202, resp.status)
- image_id = data_utils.parse_image_id(resp['location'])
+ body = self.client.create_image(self.server_id, snapshot_name)
+ image_id = data_utils.parse_image_id(body.response['location'])
self.image_ids.append(image_id)
self.addCleanup(self._reset_server)
# Do not wait, attempt to delete the image, ensure it's successful
- resp, body = self.client.delete_image(image_id)
- self.assertEqual('204', resp['status'])
+ self.client.delete_image(image_id)
self.image_ids.remove(image_id)
self.assertRaises(exceptions.NotFound, self.client.get_image, image_id)
diff --git a/tempest/api/compute/images/test_list_image_filters.py b/tempest/api/compute/images/test_list_image_filters.py
index d9a7201..742c2dd 100644
--- a/tempest/api/compute/images/test_list_image_filters.py
+++ b/tempest/api/compute/images/test_list_image_filters.py
@@ -54,7 +54,7 @@
image_file = StringIO.StringIO(('*' * 1024))
cls.glance_client.update_image(image_id, data=image_file)
cls.client.wait_for_image_status(image_id, 'ACTIVE')
- _, body = cls.client.get_image(image_id)
+ body = cls.client.get_image(image_id)
return body
# Create non-snapshot images via glance
@@ -76,19 +76,19 @@
'ACTIVE')
# Create images to be used in the filter tests
- resp, cls.snapshot1 = cls.create_image_from_server(
+ cls.snapshot1 = cls.create_image_from_server(
cls.server1['id'], wait_until='ACTIVE')
cls.snapshot1_id = cls.snapshot1['id']
# Servers have a hidden property for when they are being imaged
# Performing back-to-back create image calls on a single
# server will sometimes cause failures
- resp, cls.snapshot3 = cls.create_image_from_server(
+ cls.snapshot3 = cls.create_image_from_server(
cls.server2['id'], wait_until='ACTIVE')
cls.snapshot3_id = cls.snapshot3['id']
# Wait for the server to be active after the image upload
- resp, cls.snapshot2 = cls.create_image_from_server(
+ cls.snapshot2 = cls.create_image_from_server(
cls.server1['id'], wait_until='ACTIVE')
cls.snapshot2_id = cls.snapshot2['id']
@@ -97,7 +97,7 @@
# The list of images should contain only images with the
# provided status
params = {'status': 'ACTIVE'}
- resp, images = self.client.list_images(params)
+ images = self.client.list_images(params)
self.assertTrue(any([i for i in images if i['id'] == self.image1_id]))
self.assertTrue(any([i for i in images if i['id'] == self.image2_id]))
@@ -108,7 +108,7 @@
# List of all images should contain the expected images filtered
# by name
params = {'name': self.image1['name']}
- resp, images = self.client.list_images(params)
+ images = self.client.list_images(params)
self.assertTrue(any([i for i in images if i['id'] == self.image1_id]))
self.assertFalse(any([i for i in images if i['id'] == self.image2_id]))
@@ -120,7 +120,7 @@
def test_list_images_filter_by_server_id(self):
# The images should contain images filtered by server id
params = {'server': self.server1['id']}
- resp, images = self.client.list_images(params)
+ images = self.client.list_images(params)
self.assertTrue(any([i for i in images
if i['id'] == self.snapshot1_id]),
@@ -141,7 +141,7 @@
# Try all server link types
for link in server_links:
params = {'server': link['href']}
- resp, images = self.client.list_images(params)
+ images = self.client.list_images(params)
self.assertFalse(any([i for i in images
if i['id'] == self.snapshot1_id]))
@@ -156,7 +156,7 @@
def test_list_images_filter_by_type(self):
# The list of servers should be filtered by image type
params = {'type': 'snapshot'}
- resp, images = self.client.list_images(params)
+ images = self.client.list_images(params)
self.assertTrue(any([i for i in images
if i['id'] == self.snapshot1_id]))
@@ -171,7 +171,7 @@
def test_list_images_limit_results(self):
# Verify only the expected number of results are returned
params = {'limit': '1'}
- resp, images = self.client.list_images(params)
+ images = self.client.list_images(params)
# when _interface='xml', one element for images_links in images
# ref: Question #224349
self.assertEqual(1, len([x for x in images if 'id' in x]))
@@ -183,7 +183,7 @@
# Becoming ACTIVE will modify the updated time
# Filter by the image's created time
params = {'changes-since': self.image3['created']}
- resp, images = self.client.list_images(params)
+ images = self.client.list_images(params)
found = any([i for i in images if i['id'] == self.image3_id])
self.assertTrue(found)
@@ -192,7 +192,7 @@
# Detailed list of all images should only contain images
# with the provided status
params = {'status': 'ACTIVE'}
- resp, images = self.client.list_images_with_detail(params)
+ images = self.client.list_images_with_detail(params)
self.assertTrue(any([i for i in images if i['id'] == self.image1_id]))
self.assertTrue(any([i for i in images if i['id'] == self.image2_id]))
@@ -203,7 +203,7 @@
# Detailed list of all images should contain the expected
# images filtered by name
params = {'name': self.image1['name']}
- resp, images = self.client.list_images_with_detail(params)
+ images = self.client.list_images_with_detail(params)
self.assertTrue(any([i for i in images if i['id'] == self.image1_id]))
self.assertFalse(any([i for i in images if i['id'] == self.image2_id]))
@@ -214,7 +214,7 @@
# Verify only the expected number of results (with full details)
# are returned
params = {'limit': '1'}
- resp, images = self.client.list_images_with_detail(params)
+ images = self.client.list_images_with_detail(params)
self.assertEqual(1, len(images))
@testtools.skipUnless(CONF.compute_feature_enabled.snapshot,
@@ -227,7 +227,7 @@
# Try all server link types
for link in server_links:
params = {'server': link['href']}
- resp, images = self.client.list_images_with_detail(params)
+ images = self.client.list_images_with_detail(params)
self.assertFalse(any([i for i in images
if i['id'] == self.snapshot1_id]))
@@ -242,8 +242,8 @@
def test_list_images_with_detail_filter_by_type(self):
# The detailed list of servers should be filtered by image type
params = {'type': 'snapshot'}
- resp, images = self.client.list_images_with_detail(params)
- resp, image4 = self.client.get_image(self.image_ref)
+ images = self.client.list_images_with_detail(params)
+ self.client.get_image(self.image_ref)
self.assertTrue(any([i for i in images
if i['id'] == self.snapshot1_id]))
@@ -261,5 +261,5 @@
# Becoming ACTIVE will modify the updated time
# Filter by the image's created time
params = {'changes-since': self.image1['created']}
- resp, images = self.client.list_images_with_detail(params)
+ images = self.client.list_images_with_detail(params)
self.assertTrue(any([i for i in images if i['id'] == self.image1_id]))
diff --git a/tempest/api/compute/images/test_list_images.py b/tempest/api/compute/images/test_list_images.py
index 22d64e9..cd01147 100644
--- a/tempest/api/compute/images/test_list_images.py
+++ b/tempest/api/compute/images/test_list_images.py
@@ -33,19 +33,19 @@
@test.attr(type='smoke')
def test_get_image(self):
# Returns the correct details for a single image
- resp, image = self.client.get_image(self.image_ref)
+ image = self.client.get_image(self.image_ref)
self.assertEqual(self.image_ref, image['id'])
@test.attr(type='smoke')
def test_list_images(self):
# The list of all images should contain the image
- resp, images = self.client.list_images()
+ images = self.client.list_images()
found = any([i for i in images if i['id'] == self.image_ref])
self.assertTrue(found)
@test.attr(type='smoke')
def test_list_images_with_detail(self):
# Detailed list of all images should contain the expected images
- resp, images = self.client.list_images_with_detail()
+ images = self.client.list_images_with_detail()
found = any([i for i in images if i['id'] == self.image_ref])
self.assertTrue(found)
diff --git a/tempest/api/compute/servers/test_list_server_filters.py b/tempest/api/compute/servers/test_list_server_filters.py
index 5ff39df..7964cf7 100644
--- a/tempest/api/compute/servers/test_list_server_filters.py
+++ b/tempest/api/compute/servers/test_list_server_filters.py
@@ -33,7 +33,7 @@
# Check to see if the alternate image ref actually exists...
images_client = cls.images_client
- resp, images = images_client.list_images()
+ images = images_client.list_images()
if cls.image_ref != cls.image_ref_alt and \
any([image for image in images
diff --git a/tempest/api/compute/servers/test_server_actions.py b/tempest/api/compute/servers/test_server_actions.py
index 76c858b..17e3669 100644
--- a/tempest/api/compute/servers/test_server_actions.py
+++ b/tempest/api/compute/servers/test_server_actions.py
@@ -437,7 +437,7 @@
resp, server = self.client.get_server(self.server_id)
image_name = server['name'] + '-shelved'
params = {'name': image_name}
- resp, images = self.images_client.list_images(params)
+ images = self.images_client.list_images(params)
self.assertEqual(1, len(images))
self.assertEqual(image_name, images[0]['name'])
diff --git a/tempest/api/compute/servers/test_servers_negative.py b/tempest/api/compute/servers/test_servers_negative.py
index f44d158..b703cfe 100644
--- a/tempest/api/compute/servers/test_servers_negative.py
+++ b/tempest/api/compute/servers/test_servers_negative.py
@@ -431,7 +431,7 @@
resp, server = self.client.get_server(self.server_id)
image_name = server['name'] + '-shelved'
params = {'name': image_name}
- resp, images = self.images_client.list_images(params)
+ images = self.images_client.list_images(params)
self.assertEqual(1, len(images))
self.assertEqual(image_name, images[0]['name'])
diff --git a/tempest/api/compute/test_authorization.py b/tempest/api/compute/test_authorization.py
index 3dd6e34..60cb812 100644
--- a/tempest/api/compute/test_authorization.py
+++ b/tempest/api/compute/test_authorization.py
@@ -65,7 +65,7 @@
image_file = StringIO.StringIO(('*' * 1024))
body = cls.glance_client.update_image(image_id, data=image_file)
cls.glance_client.wait_for_image_status(image_id, 'active')
- resp, cls.image = cls.images_client.get_image(image_id)
+ cls.image = cls.images_client.get_image(image_id)
cls.keypairname = data_utils.rand_name('keypair')
resp, keypair = \
diff --git a/tempest/api/telemetry/base.py b/tempest/api/telemetry/base.py
index 769c201..e840e3b 100644
--- a/tempest/api/telemetry/base.py
+++ b/tempest/api/telemetry/base.py
@@ -69,11 +69,11 @@
@classmethod
def create_image(cls, client):
- resp, body = client.create_image(
+ body = client.create_image(
data_utils.rand_name('image'), container_format='bare',
disk_format='raw', visibility='private')
cls.image_ids.append(body['id'])
- return resp, body
+ return body
@staticmethod
def cleanup_resources(method, list_of_ids):
diff --git a/tempest/api/telemetry/test_telemetry_notification_api.py b/tempest/api/telemetry/test_telemetry_notification_api.py
index 7267183..e64cd4a 100644
--- a/tempest/api/telemetry/test_telemetry_notification_api.py
+++ b/tempest/api/telemetry/test_telemetry_notification_api.py
@@ -48,7 +48,7 @@
"Glance api v1 is disabled")
@test.skip_because(bug='1351627')
def test_check_glance_v1_notifications(self):
- _, body = self.create_image(self.image_client)
+ body = self.create_image(self.image_client)
self.image_client.update_image(body['id'], data='data')
query = 'resource', 'eq', body['id']
@@ -64,7 +64,7 @@
"Glance api v2 is disabled")
@test.skip_because(bug='1351627')
def test_check_glance_v2_notifications(self):
- _, body = self.create_image(self.image_client_v2)
+ body = self.create_image(self.image_client_v2)
self.image_client_v2.store_image(body['id'], "file")
self.image_client_v2.get_image_file(body['id'])
diff --git a/tempest/common/waiters.py b/tempest/common/waiters.py
index 3066667..c77c81e 100644
--- a/tempest/common/waiters.py
+++ b/tempest/common/waiters.py
@@ -101,12 +101,12 @@
The client should have a get_image(image_id) method to get the image.
The client should also have build_interval and build_timeout attributes.
"""
- resp, image = client.get_image(image_id)
+ image = client.get_image(image_id)
start = int(time.time())
while image['status'] != status:
time.sleep(client.build_interval)
- resp, image = client.get_image(image_id)
+ image = client.get_image(image_id)
status_curr = image['status']
if status_curr == 'ERROR':
raise exceptions.AddImageException(image_id=image_id)
diff --git a/tempest/scenario/manager.py b/tempest/scenario/manager.py
index 1fdd26a..1c53f45 100644
--- a/tempest/scenario/manager.py
+++ b/tempest/scenario/manager.py
@@ -399,8 +399,8 @@
if name is None:
name = data_utils.rand_name('scenario-snapshot-')
LOG.debug("Creating a snapshot image for server: %s", server['name'])
- resp, image = _images_client.create_image(server['id'], name)
- image_id = resp['location'].split('images/')[1]
+ image = _images_client.create_image(server['id'], name)
+ image_id = image.response['location'].split('images/')[1]
_image_client.wait_for_image_status(image_id, 'active')
self.addCleanup_with_wait(
waiter_callable=_image_client.wait_for_resource_deletion,
diff --git a/tempest/scenario/utils.py b/tempest/scenario/utils.py
index e6624a3..7967949 100644
--- a/tempest/scenario/utils.py
+++ b/tempest/scenario/utils.py
@@ -46,7 +46,7 @@
self.flavors_client = os.flavors_client
def ssh_user(self, image_id):
- _, _image = self.images_client.get_image(image_id)
+ _image = self.images_client.get_image(image_id)
for regex, user in self.ssh_users:
# First match wins
if re.match(regex, _image['name']) is not None:
@@ -59,14 +59,14 @@
string=str(image['name']))
def is_sshable_image(self, image_id):
- _, _image = self.images_client.get_image(image_id)
+ _image = self.images_client.get_image(image_id)
return self._is_sshable_image(_image)
def _is_flavor_enough(self, flavor, image):
return image['minDisk'] <= flavor['disk']
def is_flavor_enough(self, flavor_id, image_id):
- _, _image = self.images_client.get_image(image_id)
+ _image = self.images_client.get_image(image_id)
_, _flavor = self.flavors_client.get_flavor_details(flavor_id)
return self._is_flavor_enough(_flavor, _image)
@@ -120,7 +120,7 @@
if not CONF.service_available.glance:
return []
if not hasattr(self, '_scenario_images'):
- _, images = self.images_client.list_images()
+ images = self.images_client.list_images()
self._scenario_images = [
(self._normalize_name(i['name']), dict(image_ref=i['id']))
for i in images if re.search(self.image_pattern,
diff --git a/tempest/services/compute/json/images_client.py b/tempest/services/compute/json/images_client.py
index a4cfe57..5b0ebe1 100644
--- a/tempest/services/compute/json/images_client.py
+++ b/tempest/services/compute/json/images_client.py
@@ -17,6 +17,7 @@
import urllib
from tempest.api_schema.response.compute.v2 import images as schema
+from tempest.common import service_client
from tempest.common import waiters
from tempest import exceptions
from tempest.services.compute.json import base
@@ -40,7 +41,7 @@
resp, body = self.post('servers/%s/action' % str(server_id),
post_body)
self.validate_response(schema.create_image, resp, body)
- return resp, body
+ return service_client.ResponseBody(resp, body)
def list_images(self, params=None):
"""Returns a list of all images filtered by any parameters."""
@@ -51,7 +52,7 @@
resp, body = self.get(url)
body = json.loads(body)
self.validate_response(schema.list_images, resp, body)
- return resp, body['images']
+ return service_client.ResponseBodyList(resp, body['images'])
def list_images_with_detail(self, params=None):
"""Returns a detailed list of images filtered by any parameters."""
@@ -62,7 +63,7 @@
resp, body = self.get(url)
body = json.loads(body)
self.validate_response(schema.list_images_details, resp, body)
- return resp, body['images']
+ return service_client.ResponseBodyList(resp, body['images'])
def get_image(self, image_id):
"""Returns the details of a single image."""
@@ -70,13 +71,13 @@
self.expected_success(200, resp.status)
body = json.loads(body)
self.validate_response(schema.get_image, resp, body)
- return resp, body['image']
+ return service_client.ResponseBody(resp, body['image'])
def delete_image(self, image_id):
"""Deletes the provided image."""
resp, body = self.delete("images/%s" % str(image_id))
self.validate_response(schema.delete, resp, body)
- return resp, body
+ return service_client.ResponseBody(resp, body)
def wait_for_image_status(self, image_id, status):
"""Waits for an image to reach a given status."""
@@ -87,7 +88,7 @@
resp, body = self.get("images/%s/metadata" % str(image_id))
body = json.loads(body)
self.validate_response(schema.image_metadata, resp, body)
- return resp, body['metadata']
+ return service_client.ResponseBody(resp, body['metadata'])
def set_image_metadata(self, image_id, meta):
"""Sets the metadata for an image."""
@@ -95,7 +96,7 @@
resp, body = self.put('images/%s/metadata' % str(image_id), post_body)
body = json.loads(body)
self.validate_response(schema.image_metadata, resp, body)
- return resp, body['metadata']
+ return service_client.ResponseBody(resp, body['metadata'])
def update_image_metadata(self, image_id, meta):
"""Updates the metadata for an image."""
@@ -103,14 +104,14 @@
resp, body = self.post('images/%s/metadata' % str(image_id), post_body)
body = json.loads(body)
self.validate_response(schema.image_metadata, resp, body)
- return resp, body['metadata']
+ return service_client.ResponseBody(resp, body['metadata'])
def get_image_metadata_item(self, image_id, key):
"""Returns the value for a specific image metadata key."""
resp, body = self.get("images/%s/metadata/%s" % (str(image_id), key))
body = json.loads(body)
self.validate_response(schema.image_meta_item, resp, body)
- return resp, body['meta']
+ return service_client.ResponseBody(resp, body['meta'])
def set_image_metadata_item(self, image_id, key, meta):
"""Sets the value for a specific image metadata key."""
@@ -119,14 +120,14 @@
post_body)
body = json.loads(body)
self.validate_response(schema.image_meta_item, resp, body)
- return resp, body['meta']
+ return service_client.ResponseBody(resp, body['meta'])
def delete_image_metadata_item(self, image_id, key):
"""Deletes a single image metadata key/value pair."""
resp, body = self.delete("images/%s/metadata/%s" %
(str(image_id), key))
self.validate_response(schema.delete, resp, body)
- return resp, body
+ return service_client.ResponseBody(resp, body)
def is_resource_deleted(self, id):
try:
diff --git a/tempest/tests/test_waiters.py b/tempest/tests/test_waiters.py
index 1f9825e..cdf5362 100644
--- a/tempest/tests/test_waiters.py
+++ b/tempest/tests/test_waiters.py
@@ -29,7 +29,7 @@
self.client.build_interval = 1
def test_wait_for_image_status(self):
- self.client.get_image.return_value = (None, {'status': 'active'})
+ self.client.get_image.return_value = ({'status': 'active'})
start_time = int(time.time())
waiters.wait_for_image_status(self.client, 'fake_image_id', 'active')
end_time = int(time.time())
@@ -37,13 +37,13 @@
self.assertTrue((end_time - start_time) < 10)
def test_wait_for_image_status_timeout(self):
- self.client.get_image.return_value = (None, {'status': 'saving'})
+ self.client.get_image.return_value = ({'status': 'saving'})
self.assertRaises(exceptions.TimeoutException,
waiters.wait_for_image_status,
self.client, 'fake_image_id', 'active')
def test_wait_for_image_status_error_on_image_create(self):
- self.client.get_image.return_value = (None, {'status': 'ERROR'})
+ self.client.get_image.return_value = ({'status': 'ERROR'})
self.assertRaises(exceptions.AddImageException,
waiters.wait_for_image_status,
self.client, 'fake_image_id', 'active')