Merge "Full response for VolumesClient methods"

This commit is contained in:
Jenkins 2015-09-07 16:52:17 +00:00 committed by Gerrit Code Review
commit a5a0686e15
29 changed files with 120 additions and 126 deletions

View File

@ -81,7 +81,7 @@ class LiveBlockMigrationTestJSON(base.BaseV2ComputeAdminTest):
return server_id
def _volume_clean_up(self, server_id, volume_id):
body = self.volumes_client.show_volume(volume_id)
body = self.volumes_client.show_volume(volume_id)['volume']
if body['status'] == 'in-use':
self.servers_client.detach_volume(server_id, volume_id)
self.volumes_client.wait_for_volume_status(volume_id, 'available')
@ -158,7 +158,8 @@ class LiveBlockMigrationTestJSON(base.BaseV2ComputeAdminTest):
actual_host = self._get_host_for_server(server_id)
target_host = self._get_host_other_than(actual_host)
volume = self.volumes_client.create_volume(display_name='test')
volume = self.volumes_client.create_volume(
display_name='test')['volume']
self.volumes_client.wait_for_volume_status(volume['id'],
'available')

View File

@ -75,7 +75,7 @@ class AttachVolumeTestJSON(base.BaseV2ComputeTest):
# Create a volume and wait for it to become ready
self.volume = self.volumes_client.create_volume(
CONF.volume.volume_size, display_name='test')
CONF.volume.volume_size, display_name='test')['volume']
self.addCleanup(self._delete_volume)
self.volumes_client.wait_for_volume_status(self.volume['id'],
'available')

View File

@ -34,7 +34,7 @@ class CinderResourcesTest(base.BaseOrchestrationTest):
def _cinder_verify(self, volume_id, template):
self.assertIsNotNone(volume_id)
volume = self.volumes_client.show_volume(volume_id)
volume = self.volumes_client.show_volume(volume_id)['volume']
self.assertEqual('available', volume.get('status'))
self.assertEqual(template['resources']['volume']['properties'][
'size'], volume.get('size'))

View File

@ -71,7 +71,8 @@ class VolumeMultiBackendV2Test(base.BaseVolumeAdminTest):
params = {self.name_field: vol_name, 'volume_type': type_name}
self.volume = self.admin_volume_client.create_volume(**params)
self.volume = self.admin_volume_client.create_volume(
**params)['volume']
if with_prefix:
self.volume_id_list_with_prefix.append(self.volume['id'])
else:
@ -135,7 +136,7 @@ class VolumeMultiBackendV2Test(base.BaseVolumeAdminTest):
# the multi backend feature has been enabled
# if multi-backend is enabled: os-vol-attr:host should be like:
# host@backend_name
volume = self.admin_volume_client.show_volume(volume_id)
volume = self.admin_volume_client.show_volume(volume_id)['volume']
volume1_host = volume['os-vol-host-attr:host']
msg = ("multi-backend reporting incorrect values for volume %s" %
@ -146,10 +147,10 @@ class VolumeMultiBackendV2Test(base.BaseVolumeAdminTest):
# this test checks that the two volumes created at setUp don't
# belong to the same backend (if they are, than the
# volume backend distinction is not working properly)
volume = self.admin_volume_client.show_volume(volume1_id)
volume = self.admin_volume_client.show_volume(volume1_id)['volume']
volume1_host = volume['os-vol-host-attr:host']
volume = self.admin_volume_client.show_volume(volume2_id)
volume = self.admin_volume_client.show_volume(volume2_id)['volume']
volume2_host = volume['os-vol-host-attr:host']
msg = ("volumes %s and %s were created in the same backend" %

View File

@ -34,7 +34,7 @@ class SnapshotsActionsV2Test(base.BaseVolumeAdminTest):
cls.name_field = cls.special_fields['name_field']
params = {cls.name_field: vol_name}
cls.volume = \
cls.volumes_client.create_volume(**params)
cls.volumes_client.create_volume(**params)['volume']
cls.volumes_client.wait_for_volume_status(cls.volume['id'],
'available')

View File

@ -58,7 +58,7 @@ class VolumeTypesV2Test(base.BaseVolumeAdminTest):
'volume_type': volume_types[0]['id']}
# Create volume
volume = self.volumes_client.create_volume(**params)
volume = self.volumes_client.create_volume(**params)['volume']
self.addCleanup(self._delete_volume, volume['id'])
self.assertEqual(volume_types[0]['name'], volume["volume_type"])
self.assertEqual(volume[self.name_field], vol_name,
@ -74,7 +74,8 @@ class VolumeTypesV2Test(base.BaseVolumeAdminTest):
self.volumes_client.wait_for_volume_status(volume['id'], 'available')
# Get volume details and Verify
fetched_volume = self.volumes_client.show_volume(volume['id'])
fetched_volume = self.volumes_client.show_volume(
volume['id'])['volume']
self.assertEqual(volume_types[1]['name'],
fetched_volume['volume_type'],
'The fetched Volume type is different '

View File

@ -34,7 +34,7 @@ class VolumesActionsV2Test(base.BaseVolumeAdminTest):
cls.name_field = cls.special_fields['name_field']
params = {cls.name_field: vol_name}
cls.volume = cls.client.create_volume(**params)
cls.volume = cls.client.create_volume(**params)['volume']
cls.client.wait_for_volume_status(cls.volume['id'], 'available')
@classmethod
@ -60,7 +60,7 @@ class VolumesActionsV2Test(base.BaseVolumeAdminTest):
# Create a temp volume for force delete tests
vol_name = utils.rand_name('Volume')
params = {self.name_field: vol_name}
temp_volume = self.client.create_volume(**params)
temp_volume = self.client.create_volume(**params)['volume']
self.client.wait_for_volume_status(temp_volume['id'], 'available')
return temp_volume
@ -78,7 +78,7 @@ class VolumesActionsV2Test(base.BaseVolumeAdminTest):
# test volume reset status : available->error->available
self._reset_volume_status(self.volume['id'], 'error')
volume_get = self.admin_volume_client.show_volume(
self.volume['id'])
self.volume['id'])['volume']
self.assertEqual('error', volume_get['status'])
@test.idempotent_id('21737d5a-92f2-46d7-b009-a0cc0ee7a570')

View File

@ -125,7 +125,7 @@ class VolumesBackupsV2Test(base.BaseVolumeAdminTest):
'available')
# Verify if restored volume is there in volume list
volumes = self.admin_volume_client.list_volumes()
volumes = self.admin_volume_client.list_volumes()['volumes']
self.assertIn(restore['volume_id'], [v['id'] for v in volumes])
self.backups_adm_client.wait_for_backup_status(import_backup['id'],
'available')

View File

@ -113,7 +113,7 @@ class BaseVolumeTest(tempest.test.BaseTestCase):
name_field = cls.special_fields['name_field']
kwargs[name_field] = name
volume = cls.volumes_client.create_volume(size, **kwargs)
volume = cls.volumes_client.create_volume(size, **kwargs)['volume']
cls.volumes.append(volume)
cls.volumes_client.wait_for_volume_status(volume['id'], 'available')

View File

@ -42,14 +42,16 @@ class VolumesV2MetadataTest(base.BaseVolumeTest):
"key4": "<value&special_chars>"}
body = self.volumes_client.create_volume_metadata(self.volume_id,
metadata)
metadata)['metadata']
# Get the metadata of the volume
body = self.volumes_client.show_volume_metadata(self.volume_id)
body = self.volumes_client.show_volume_metadata(
self.volume_id)['metadata']
self.assertThat(body.items(), matchers.ContainsAll(metadata.items()))
# Delete one item metadata of the volume
self.volumes_client.delete_volume_metadata_item(
self.volume_id, "key1")
body = self.volumes_client.show_volume_metadata(self.volume_id)
body = self.volumes_client.show_volume_metadata(
self.volume_id)['metadata']
self.assertNotIn("key1", body)
del metadata["key1"]
self.assertThat(body.items(), matchers.ContainsAll(metadata.items()))
@ -66,15 +68,17 @@ class VolumesV2MetadataTest(base.BaseVolumeTest):
# Create metadata for the volume
body = self.volumes_client.create_volume_metadata(
self.volume_id, metadata)
self.volume_id, metadata)['metadata']
# Get the metadata of the volume
body = self.volumes_client.show_volume_metadata(self.volume_id)
body = self.volumes_client.show_volume_metadata(
self.volume_id)['metadata']
self.assertThat(body.items(), matchers.ContainsAll(metadata.items()))
# Update metadata
body = self.volumes_client.update_volume_metadata(
self.volume_id, update)
self.volume_id, update)['metadata']
# Get the metadata of the volume
body = self.volumes_client.show_volume_metadata(self.volume_id)
body = self.volumes_client.show_volume_metadata(
self.volume_id)['metadata']
self.assertEqual(update, body)
@test.idempotent_id('862261c5-8df4-475a-8c21-946e50e36a20')
@ -89,13 +93,14 @@ class VolumesV2MetadataTest(base.BaseVolumeTest):
"key3": "value3_update"}
# Create metadata for the volume
body = self.volumes_client.create_volume_metadata(
self.volume_id, metadata)
self.volume_id, metadata)['metadata']
self.assertThat(body.items(), matchers.ContainsAll(metadata.items()))
# Update metadata item
body = self.volumes_client.update_volume_metadata_item(
self.volume_id, "key3", update_item)
self.volume_id, "key3", update_item)['meta']
# Get the metadata of the volume
body = self.volumes_client.show_volume_metadata(self.volume_id)
body = self.volumes_client.show_volume_metadata(
self.volume_id)['metadata']
self.assertThat(body.items(), matchers.ContainsAll(expect.items()))

View File

@ -47,24 +47,24 @@ class VolumesV2TransfersTest(base.BaseVolumeTest):
self.addCleanup(self._delete_volume, volume['id'])
# Create a volume transfer
transfer = self.client.create_volume_transfer(volume['id'])
transfer = self.client.create_volume_transfer(volume['id'])['transfer']
transfer_id = transfer['id']
auth_key = transfer['auth_key']
self.client.wait_for_volume_status(volume['id'],
'awaiting-transfer')
# Get a volume transfer
body = self.client.show_volume_transfer(transfer_id)
body = self.client.show_volume_transfer(transfer_id)['transfer']
self.assertEqual(volume['id'], body['volume_id'])
# List volume transfers, the result should be greater than
# or equal to 1
body = self.client.list_volume_transfers()
body = self.client.list_volume_transfers()['transfers']
self.assertThat(len(body), matchers.GreaterThan(0))
# Accept a volume transfer by alt_tenant
body = self.alt_client.accept_volume_transfer(transfer_id,
auth_key)
auth_key)['transfer']
self.alt_client.wait_for_volume_status(volume['id'], 'available')
@test.idempotent_id('ab526943-b725-4c07-b875-8e8ef87a2c30')
@ -74,13 +74,13 @@ class VolumesV2TransfersTest(base.BaseVolumeTest):
self.addCleanup(self._delete_volume, volume['id'])
# Create a volume transfer
body = self.client.create_volume_transfer(volume['id'])
body = self.client.create_volume_transfer(volume['id'])['transfer']
transfer_id = body['id']
self.client.wait_for_volume_status(volume['id'],
'awaiting-transfer')
# List all volume transfers (looking for the one we created)
body = self.client.list_volume_transfers()
body = self.client.list_volume_transfers()['transfers']
for transfer in body:
if volume['id'] == transfer['volume_id']:
break

View File

@ -75,7 +75,8 @@ class VolumesV2ActionsTest(base.BaseVolumeTest):
# Verify that a volume bootable flag is retrieved
for bool_bootable in [True, False]:
self.client.set_bootable_volume(self.volume['id'], bool_bootable)
fetched_volume = self.client.show_volume(self.volume['id'])
fetched_volume = self.client.show_volume(
self.volume['id'])['volume']
# Get Volume information
bool_flag = self._is_true(fetched_volume['bootable'])
self.assertEqual(bool_bootable, bool_flag)
@ -96,7 +97,7 @@ class VolumesV2ActionsTest(base.BaseVolumeTest):
self.volume['id'],
'available')
self.addCleanup(self.client.detach_volume, self.volume['id'])
volume = self.client.show_volume(self.volume['id'])
volume = self.client.show_volume(self.volume['id'])['volume']
self.assertIn('attachments', volume)
attachment = self.client.get_attachment_from_volume(volume)
self.assertEqual(mountpoint, attachment['device'])
@ -112,9 +113,9 @@ class VolumesV2ActionsTest(base.BaseVolumeTest):
# there is no way to delete it from Cinder, so we delete it from Glance
# using the Glance image_client and from Cinder via tearDownClass.
image_name = data_utils.rand_name('Image')
body = self.client.upload_volume(self.volume['id'],
image_name,
CONF.volume.disk_format)
body = self.client.upload_volume(
self.volume['id'], image_name,
CONF.volume.disk_format)['os-volume_upload_image']
image_id = body["image_id"]
self.addCleanup(self.image_client.delete_image, image_id)
self.image_client.wait_for_image_status(image_id, 'active')
@ -125,12 +126,12 @@ class VolumesV2ActionsTest(base.BaseVolumeTest):
# Mark volume as reserved.
body = self.client.reserve_volume(self.volume['id'])
# To get the volume info
body = self.client.show_volume(self.volume['id'])
body = self.client.show_volume(self.volume['id'])['volume']
self.assertIn('attaching', body['status'])
# Unmark volume as reserved.
body = self.client.unreserve_volume(self.volume['id'])
# To get the volume info
body = self.client.show_volume(self.volume['id'])
body = self.client.show_volume(self.volume['id'])['volume']
self.assertIn('available', body['status'])
def _is_true(self, val):
@ -143,7 +144,7 @@ class VolumesV2ActionsTest(base.BaseVolumeTest):
self.client.update_volume_readonly(self.volume['id'],
readonly)
# Get Volume information
fetched_volume = self.client.show_volume(self.volume['id'])
fetched_volume = self.client.show_volume(self.volume['id'])['volume']
bool_flag = self._is_true(fetched_volume['metadata']['readonly'])
self.assertEqual(True, bool_flag)
@ -152,7 +153,7 @@ class VolumesV2ActionsTest(base.BaseVolumeTest):
self.client.update_volume_readonly(self.volume['id'], readonly)
# Get Volume information
fetched_volume = self.client.show_volume(self.volume['id'])
fetched_volume = self.client.show_volume(self.volume['id'])['volume']
bool_flag = self._is_true(fetched_volume['metadata']['readonly'])
self.assertEqual(False, bool_flag)

View File

@ -34,7 +34,7 @@ class VolumesV2ExtendTest(base.BaseVolumeTest):
extend_size = int(self.volume['size']) + 1
self.client.extend_volume(self.volume['id'], extend_size)
self.client.wait_for_volume_status(self.volume['id'], 'available')
volume = self.client.show_volume(self.volume['id'])
volume = self.client.show_volume(self.volume['id'])['volume']
self.assertEqual(int(volume['size']), extend_size)

View File

@ -50,7 +50,7 @@ class VolumesV2GetTest(base.BaseVolumeTest):
# Create a volume
kwargs[self.name_field] = v_name
kwargs['metadata'] = metadata
volume = self.client.create_volume(**kwargs)
volume = self.client.create_volume(**kwargs)['volume']
self.assertIn('id', volume)
self.addCleanup(self._delete_volume, volume['id'])
self.client.wait_for_volume_status(volume['id'], 'available')
@ -61,7 +61,7 @@ class VolumesV2GetTest(base.BaseVolumeTest):
self.assertTrue(volume['id'] is not None,
"Field volume id is empty or not found.")
# Get Volume information
fetched_volume = self.client.show_volume(volume['id'])
fetched_volume = self.client.show_volume(volume['id'])['volume']
self.assertEqual(v_name,
fetched_volume[self.name_field],
'The fetched Volume name is different '
@ -89,12 +89,13 @@ class VolumesV2GetTest(base.BaseVolumeTest):
new_desc = 'This is the new description of volume'
params = {self.name_field: new_v_name,
self.descrip_field: new_desc}
update_volume = self.client.update_volume(volume['id'], **params)
update_volume = self.client.update_volume(
volume['id'], **params)['volume']
# Assert response body for update_volume method
self.assertEqual(new_v_name, update_volume[self.name_field])
self.assertEqual(new_desc, update_volume[self.descrip_field])
# Assert response body for show_volume method
updated_volume = self.client.show_volume(volume['id'])
updated_volume = self.client.show_volume(volume['id'])['volume']
self.assertEqual(volume['id'], updated_volume['id'])
self.assertEqual(new_v_name, updated_volume[self.name_field])
self.assertEqual(new_desc, updated_volume[self.descrip_field])
@ -109,7 +110,7 @@ class VolumesV2GetTest(base.BaseVolumeTest):
new_v_desc = data_utils.rand_name('@#$%^* description')
params = {self.descrip_field: new_v_desc,
'availability_zone': volume['availability_zone']}
new_volume = self.client.create_volume(**params)
new_volume = self.client.create_volume(**params)['volume']
self.assertIn('id', new_volume)
self.addCleanup(self._delete_volume, new_volume['id'])
self.client.wait_for_volume_status(new_volume['id'], 'available')

View File

@ -70,7 +70,7 @@ class VolumesV2ListTestJSON(base.BaseVolumeTest):
cls.metadata = {'Type': 'work'}
for i in range(3):
volume = cls.create_volume(metadata=cls.metadata)
volume = cls.client.show_volume(volume['id'])
volume = cls.client.show_volume(volume['id'])['volume']
cls.volume_list.append(volume)
cls.volume_id_list.append(volume['id'])
@ -89,9 +89,10 @@ class VolumesV2ListTestJSON(base.BaseVolumeTest):
"""
if with_detail:
fetched_vol_list = \
self.client.list_volumes(detail=True, params=params)
self.client.list_volumes(detail=True, params=params)['volumes']
else:
fetched_vol_list = self.client.list_volumes(params=params)
fetched_vol_list = self.client.list_volumes(
params=params)['volumes']
# Validating params of fetched volumes
# In v2, only list detail view includes items in params.
@ -116,7 +117,7 @@ class VolumesV2ListTestJSON(base.BaseVolumeTest):
def test_volume_list(self):
# Get a list of Volumes
# Fetch all volumes
fetched_list = self.client.list_volumes()
fetched_list = self.client.list_volumes()['volumes']
self.assertVolumesIn(fetched_list, self.volume_list,
fields=self.VOLUME_FIELDS)
@ -124,14 +125,14 @@ class VolumesV2ListTestJSON(base.BaseVolumeTest):
def test_volume_list_with_details(self):
# Get a list of Volumes with details
# Fetch all Volumes
fetched_list = self.client.list_volumes(detail=True)
fetched_list = self.client.list_volumes(detail=True)['volumes']
self.assertVolumesIn(fetched_list, self.volume_list)
@test.idempotent_id('a28e8da4-0b56-472f-87a8-0f4d3f819c02')
def test_volume_list_by_name(self):
volume = self.volume_list[data_utils.rand_int_id(0, 2)]
params = {self.name: volume[self.name]}
fetched_vol = self.client.list_volumes(params=params)
fetched_vol = self.client.list_volumes(params=params)['volumes']
self.assertEqual(1, len(fetched_vol), str(fetched_vol))
self.assertEqual(fetched_vol[0][self.name],
volume[self.name])
@ -140,7 +141,8 @@ class VolumesV2ListTestJSON(base.BaseVolumeTest):
def test_volume_list_details_by_name(self):
volume = self.volume_list[data_utils.rand_int_id(0, 2)]
params = {self.name: volume[self.name]}
fetched_vol = self.client.list_volumes(detail=True, params=params)
fetched_vol = self.client.list_volumes(
detail=True, params=params)['volumes']
self.assertEqual(1, len(fetched_vol), str(fetched_vol))
self.assertEqual(fetched_vol[0][self.name],
volume[self.name])
@ -148,7 +150,7 @@ class VolumesV2ListTestJSON(base.BaseVolumeTest):
@test.idempotent_id('39654e13-734c-4dab-95ce-7613bf8407ce')
def test_volumes_list_by_status(self):
params = {'status': 'available'}
fetched_list = self.client.list_volumes(params=params)
fetched_list = self.client.list_volumes(params=params)['volumes']
self._list_by_param_value_and_assert(params)
self.assertVolumesIn(fetched_list, self.volume_list,
fields=self.VOLUME_FIELDS)
@ -156,7 +158,8 @@ class VolumesV2ListTestJSON(base.BaseVolumeTest):
@test.idempotent_id('2943f712-71ec-482a-bf49-d5ca06216b9f')
def test_volumes_list_details_by_status(self):
params = {'status': 'available'}
fetched_list = self.client.list_volumes(detail=True, params=params)
fetched_list = self.client.list_volumes(
detail=True, params=params)['volumes']
for volume in fetched_list:
self.assertEqual('available', volume['status'])
self.assertVolumesIn(fetched_list, self.volume_list)
@ -166,7 +169,7 @@ class VolumesV2ListTestJSON(base.BaseVolumeTest):
volume = self.volume_list[data_utils.rand_int_id(0, 2)]
zone = volume['availability_zone']
params = {'availability_zone': zone}
fetched_list = self.client.list_volumes(params=params)
fetched_list = self.client.list_volumes(params=params)['volumes']
self._list_by_param_value_and_assert(params)
self.assertVolumesIn(fetched_list, self.volume_list,
fields=self.VOLUME_FIELDS)
@ -176,7 +179,8 @@ class VolumesV2ListTestJSON(base.BaseVolumeTest):
volume = self.volume_list[data_utils.rand_int_id(0, 2)]
zone = volume['availability_zone']
params = {'availability_zone': zone}
fetched_list = self.client.list_volumes(detail=True, params=params)
fetched_list = self.client.list_volumes(
detail=True, params=params)['volumes']
for volume in fetched_list:
self.assertEqual(zone, volume['availability_zone'])
self.assertVolumesIn(fetched_list, self.volume_list)

View File

@ -271,7 +271,7 @@ class VolumesV2NegativeTest(base.BaseVolumeTest):
def test_list_volumes_with_nonexistent_name(self):
v_name = data_utils.rand_name('Volume')
params = {self.name_field: v_name}
fetched_volume = self.client.list_volumes(params=params)
fetched_volume = self.client.list_volumes(params=params)['volumes']
self.assertEqual(0, len(fetched_volume))
@test.attr(type=['negative'])
@ -280,14 +280,14 @@ class VolumesV2NegativeTest(base.BaseVolumeTest):
v_name = data_utils.rand_name('Volume')
params = {self.name_field: v_name}
fetched_volume = \
self.client.list_volumes(detail=True, params=params)
self.client.list_volumes(detail=True, params=params)['volumes']
self.assertEqual(0, len(fetched_volume))
@test.attr(type=['negative'])
@test.idempotent_id('143b279b-7522-466b-81be-34a87d564a7c')
def test_list_volumes_with_invalid_status(self):
params = {'status': 'null'}
fetched_volume = self.client.list_volumes(params=params)
fetched_volume = self.client.list_volumes(params=params)['volumes']
self.assertEqual(0, len(fetched_volume))
@test.attr(type=['negative'])
@ -295,7 +295,7 @@ class VolumesV2NegativeTest(base.BaseVolumeTest):
def test_list_volumes_detail_with_invalid_status(self):
params = {'status': 'null'}
fetched_volume = \
self.client.list_volumes(detail=True, params=params)
self.client.list_volumes(detail=True, params=params)['volumes']
self.assertEqual(0, len(fetched_volume))

View File

@ -177,7 +177,7 @@ class VolumesV2SnapshotTestJSON(base.BaseVolumeTest):
snapshot = self.create_snapshot(self.volume_origin['id'])
# NOTE(gfidente): size is required also when passing snapshot_id
volume = self.volumes_client.create_volume(
snapshot_id=snapshot['id'])
snapshot_id=snapshot['id'])['volume']
self.volumes_client.wait_for_volume_status(volume['id'], 'available')
self.volumes_client.delete_volume(volume['id'])
self.volumes_client.wait_for_resource_deletion(volume['id'])

View File

@ -47,7 +47,7 @@ class VolumesV2ListTestJSON(base.BaseVolumeTest):
cls.metadata = {'Type': 'work'}
for i in range(3):
volume = cls.create_volume(metadata=cls.metadata)
volume = cls.client.show_volume(volume['id'])
volume = cls.client.show_volume(volume['id'])['volume']
cls.volume_list.append(volume)
cls.volume_id_list.append(volume['id'])
@ -71,8 +71,8 @@ class VolumesV2ListTestJSON(base.BaseVolumeTest):
'sort_dir': sort_dir,
'sort_key': sort_key
}
fetched_volume = self.client.list_volumes(detail=True,
params=params)
fetched_volume = self.client.list_volumes(
detail=True, params=params)['volumes']
self.assertEqual(limit, len(fetched_volume),
"The count of volumes is %s, expected:%s " %
(len(fetched_volume), limit))
@ -123,7 +123,7 @@ class VolumesV2ListTestJSON(base.BaseVolumeTest):
while True:
# Get a list page
response = method(return_body=True, params=params, **kwargs)
response = method(params=params, **kwargs)
# If we have to check ids
if remaining is not None:

View File

@ -322,7 +322,7 @@ class VolumeService(BaseService):
def list(self):
client = self.client
vols = client.list_volumes()
vols = client.list_volumes()['volumes']
LOG.debug("List count, %s Volumes" % len(vols))
return vols

View File

@ -945,7 +945,7 @@ def destroy_secgroups(secgroups):
#######################
def _get_volume_by_name(client, name):
body = client.volumes.list_volumes()
body = client.volumes.list_volumes()['volumes']
for volume in body:
if name == volume['display_name']:
return volume
@ -967,7 +967,7 @@ def create_volumes(volumes):
size = volume['gb']
v_name = volume['name']
body = client.volumes.create_volume(size=size,
display_name=v_name)
display_name=v_name)['volume']
client.volumes.wait_for_volume_status(body['id'], 'available')

View File

@ -163,12 +163,19 @@ def wait_for_image_status(client, image_id, status):
def wait_for_volume_status(client, volume_id, status):
"""Waits for a Volume to reach a given status."""
body = client.show_volume(volume_id)
if 'volume' in body:
body = body['volume']
volume_status = body['status']
start = int(time.time())
while volume_status != status:
time.sleep(client.build_interval)
body = client.show_volume(volume_id)
# TODO(jswarren) always extract 'volume' value
# once the compute clients also return the full
# response.
if 'volume' in body:
body = body['volume']
volume_status = body['status']
if volume_status == 'error':
raise exceptions.VolumeBuildErrorException(volume_id=volume_id)

View File

@ -202,7 +202,7 @@ class ScenarioTest(tempest.test.BaseTestCase):
name = data_utils.rand_name(self.__class__.__name__)
volume = self.volumes_client.create_volume(
size=size, display_name=name, snapshot_id=snapshot_id,
imageRef=imageRef, volume_type=volume_type)
imageRef=imageRef, volume_type=volume_type)['volume']
if wait_on_delete:
self.addCleanup(self.volumes_client.wait_for_resource_deletion,
@ -220,7 +220,7 @@ class ScenarioTest(tempest.test.BaseTestCase):
self.volumes_client.wait_for_volume_status(volume['id'], 'available')
# The volume retrieved on creation has a non-up-to-date status.
# Retrieval after it becomes active ensures correct details.
volume = self.volumes_client.show_volume(volume['id'])
volume = self.volumes_client.show_volume(volume['id'])['volume']
return volume
def _create_loginable_secgroup_rule(self, secgroup_id=None):
@ -445,14 +445,14 @@ class ScenarioTest(tempest.test.BaseTestCase):
self.assertEqual(self.volume['id'], volume['id'])
self.volumes_client.wait_for_volume_status(volume['id'], 'in-use')
# Refresh the volume after the attachment
self.volume = self.volumes_client.show_volume(volume['id'])
self.volume = self.volumes_client.show_volume(volume['id'])['volume']
def nova_volume_detach(self):
self.servers_client.detach_volume(self.server['id'], self.volume['id'])
self.volumes_client.wait_for_volume_status(self.volume['id'],
'available')
volume = self.volumes_client.show_volume(self.volume['id'])
volume = self.volumes_client.show_volume(self.volume['id'])['volume']
self.assertEqual('available', volume['status'])
def rebuild_server(self, server_id, image=None,

View File

@ -74,11 +74,11 @@ class TestMinimumBasicScenario(manager.ScenarioTest):
self.volume = self.create_volume()
def cinder_list(self):
volumes = self.volumes_client.list_volumes()
volumes = self.volumes_client.list_volumes()['volumes']
self.assertIn(self.volume['id'], [x['id'] for x in volumes])
def cinder_show(self):
volume = self.volumes_client.show_volume(self.volume['id'])
volume = self.volumes_client.show_volume(self.volume['id'])['volume']
self.assertEqual(self.volume, volume)
def nova_reboot(self):

View File

@ -39,30 +39,6 @@ class BaseVolumesClient(service_client.ServiceClient):
"""Return the element 'attachment' from input volumes."""
return volume['attachments'][0]
def _ext_get(self, url, key=None, status=200):
"""Extended get method.
Retrieves requested url, checks that status is expected status and
return a ResponseBody, ResponseBodyList or ResponseBodyData depending
on received data's key entry.
If key is not specified or is None we will return the whole body in a
ResponseBody class.
"""
resp, body = self.get(url)
body = json.loads(body)
self.expected_success(status, resp.status)
if not key:
return service_client.ResponseBody(resp, body)
elif isinstance(body[key], dict):
return service_client.ResponseBody(resp, body[key])
elif isinstance(body[key], list):
return service_client.ResponseBodyList(resp, body[key])
return service_client.ResponseBodyData(resp, body[key])
def _prepare_params(self, params):
"""Prepares params for use in get or _ext_get methods.
@ -73,14 +49,10 @@ class BaseVolumesClient(service_client.ServiceClient):
return params
return urllib.urlencode(params)
def list_volumes(self, detail=False, params=None, return_body=False):
def list_volumes(self, detail=False, params=None):
"""List all the volumes created.
Params can be a string (must be urlencoded) or a dictionary.
If return_body is True then we will return the whole response body in
a ResponseBody class, it it's False or has not been specified we will
return only the list of volumes in a ResponseBodyList (inherits from
list).
"""
url = 'volumes'
if detail:
@ -88,8 +60,10 @@ class BaseVolumesClient(service_client.ServiceClient):
if params:
url += '?%s' % self._prepare_params(params)
key = None if return_body else 'volumes'
return self._ext_get(url, key)
resp, body = self.get(url)
body = json.loads(body)
self.expected_success(200, resp.status)
return service_client.ResponseBody(resp, body)
def show_volume(self, volume_id):
"""Returns the details of a single volume."""
@ -97,7 +71,7 @@ class BaseVolumesClient(service_client.ServiceClient):
resp, body = self.get(url)
body = json.loads(body)
self.expected_success(200, resp.status)
return service_client.ResponseBody(resp, body['volume'])
return service_client.ResponseBody(resp, body)
def create_volume(self, size=None, **kwargs):
"""
@ -119,7 +93,7 @@ class BaseVolumesClient(service_client.ServiceClient):
resp, body = self.post('volumes', post_body)
body = json.loads(body)
self.expected_success(self.create_resp, resp.status)
return service_client.ResponseBody(resp, body['volume'])
return service_client.ResponseBody(resp, body)
def update_volume(self, volume_id, **kwargs):
"""Updates the Specified Volume."""
@ -127,7 +101,7 @@ class BaseVolumesClient(service_client.ServiceClient):
resp, body = self.put('volumes/%s' % volume_id, put_body)
body = json.loads(body)
self.expected_success(200, resp.status)
return service_client.ResponseBody(resp, body['volume'])
return service_client.ResponseBody(resp, body)
def delete_volume(self, volume_id):
"""Deletes the Specified Volume."""
@ -146,8 +120,7 @@ class BaseVolumesClient(service_client.ServiceClient):
resp, body = self.post(url, post_body)
body = json.loads(body)
self.expected_success(202, resp.status)
return service_client.ResponseBody(resp,
body['os-volume_upload_image'])
return service_client.ResponseBody(resp, body)
def attach_volume(self, volume_id, instance_uuid, mountpoint):
"""Attaches a volume to a given instance on a given mountpoint."""
@ -258,7 +231,7 @@ class BaseVolumesClient(service_client.ServiceClient):
resp, body = self.post('os-volume-transfer', post_body)
body = json.loads(body)
self.expected_success(202, resp.status)
return service_client.ResponseBody(resp, body['transfer'])
return service_client.ResponseBody(resp, body)
def show_volume_transfer(self, transfer_id):
"""Returns the details of a volume transfer."""
@ -266,7 +239,7 @@ class BaseVolumesClient(service_client.ServiceClient):
resp, body = self.get(url)
body = json.loads(body)
self.expected_success(200, resp.status)
return service_client.ResponseBody(resp, body['transfer'])
return service_client.ResponseBody(resp, body)
def list_volume_transfers(self, params=None):
"""List all the volume transfers created."""
@ -276,7 +249,7 @@ class BaseVolumesClient(service_client.ServiceClient):
resp, body = self.get(url)
body = json.loads(body)
self.expected_success(200, resp.status)
return service_client.ResponseBodyList(resp, body['transfers'])
return service_client.ResponseBody(resp, body)
def delete_volume_transfer(self, transfer_id):
"""Delete a volume transfer."""
@ -294,7 +267,7 @@ class BaseVolumesClient(service_client.ServiceClient):
resp, body = self.post(url, post_body)
body = json.loads(body)
self.expected_success(202, resp.status)
return service_client.ResponseBody(resp, body['transfer'])
return service_client.ResponseBody(resp, body)
def update_volume_readonly(self, volume_id, readonly):
"""Update the Specified Volume readonly."""
@ -321,7 +294,7 @@ class BaseVolumesClient(service_client.ServiceClient):
resp, body = self.post(url, put_body)
body = json.loads(body)
self.expected_success(200, resp.status)
return service_client.ResponseBody(resp, body['metadata'])
return service_client.ResponseBody(resp, body)
def show_volume_metadata(self, volume_id):
"""Get metadata of the volume."""
@ -329,7 +302,7 @@ class BaseVolumesClient(service_client.ServiceClient):
resp, body = self.get(url)
body = json.loads(body)
self.expected_success(200, resp.status)
return service_client.ResponseBody(resp, body['metadata'])
return service_client.ResponseBody(resp, body)
def update_volume_metadata(self, volume_id, metadata):
"""Update metadata for the volume."""
@ -338,7 +311,7 @@ class BaseVolumesClient(service_client.ServiceClient):
resp, body = self.put(url, put_body)
body = json.loads(body)
self.expected_success(200, resp.status)
return service_client.ResponseBody(resp, body['metadata'])
return service_client.ResponseBody(resp, body)
def update_volume_metadata_item(self, volume_id, id, meta_item):
"""Update metadata item for the volume."""
@ -347,7 +320,7 @@ class BaseVolumesClient(service_client.ServiceClient):
resp, body = self.put(url, put_body)
body = json.loads(body)
self.expected_success(200, resp.status)
return service_client.ResponseBody(resp, body['meta'])
return service_client.ResponseBody(resp, body)
def delete_volume_metadata_item(self, volume_id, id):
"""Delete metadata item for the volume."""

View File

@ -30,7 +30,7 @@ class VolumeAttachDeleteTest(stressaction.StressAction):
name = data_utils.rand_name("volume")
self.logger.info("creating volume: %s" % name)
volume = self.manager.volumes_client.create_volume(
display_name=name)
display_name=name)['volume']
self.manager.volumes_client.wait_for_volume_status(volume['id'],
'available')
self.logger.info("created volume: %s" % volume['id'])

View File

@ -85,7 +85,7 @@ class VolumeVerifyStress(stressaction.StressAction):
self.logger.info("creating volume: %s" % name)
volumes_client = self.manager.volumes_client
self.volume = volumes_client.create_volume(
display_name=name)
display_name=name)['volume']
volumes_client.wait_for_volume_status(self.volume['id'],
'available')
self.logger.info("created volume: %s" % self.volume['id'])

View File

@ -20,7 +20,7 @@ class VolumeCreateDeleteTest(stressaction.StressAction):
name = data_utils.rand_name("volume")
self.logger.info("creating %s" % name)
volumes_client = self.manager.volumes_client
volume = volumes_client.create_volume(display_name=name)
volume = volumes_client.create_volume(display_name=name)['volume']
vol_id = volume['id']
volumes_client.wait_for_volume_status(vol_id, 'available')
self.logger.info("created %s" % volume['id'])

View File

@ -227,7 +227,7 @@ class TestCreateResources(JavelinUnitTest):
display_name=self.fake_object['name'])
mocked_function = self.fake_client.volumes.wait_for_volume_status
mocked_function.assert_called_once_with(
self.fake_object.body['id'],
self.fake_object.body['volume']['id'],
'available')
def test_create_volume_existing(self):

View File

@ -55,8 +55,8 @@ class TestImageWaiters(base.TestCase):
# the volume status is 'error_restoring'.
client = mock.Mock(spec=volumes_client.BaseVolumesClient,
build_interval=1)
volume1 = {'status': 'restoring-backup'}
volume2 = {'status': 'error_restoring'}
volume1 = {'volume': {'status': 'restoring-backup'}}
volume2 = {'volume': {'status': 'error_restoring'}}
mock_show = mock.Mock(side_effect=(volume1, volume2))
client.show_volume = mock_show
volume_id = '7532b91e-aa0a-4e06-b3e5-20c0c5ee1caa'