Change volume client methods to return one value

Change volume client methods to return one value and update tests.

Partially implements: blueprint clients-return-one-value

Change-Id: I017b9a69f5da9c6fac0a46acae037a2a912bef97
This commit is contained in:
Joseph Lanoux 2014-12-18 14:57:18 +00:00
parent cbaba25603
commit 6809bab06e
44 changed files with 283 additions and 278 deletions

View File

@ -271,7 +271,7 @@ class BaseComputeTest(tempest.test.BaseTestCase):
def _delete_volume(volumes_client, volume_id):
"""Deletes the given volume and waits for it to be gone."""
try:
resp, _ = volumes_client.delete_volume(volume_id)
volumes_client.delete_volume(volume_id)
# TODO(mriedem): We should move the wait_for_resource_deletion
# into the delete_volume method as a convenience to the caller.
volumes_client.wait_for_resource_deletion(volume_id)

View File

@ -61,7 +61,7 @@ class AttachVolumeTestJSON(base.BaseV2ComputeTest):
self.servers_client.list_addresses(self.server['id']))
# Create a volume and wait for it to become ready
_, self.volume = self.volumes_client.create_volume(
self.volume = self.volumes_client.create_volume(
1, display_name='test')
self.addCleanup(self._delete_volume)
self.volumes_client.wait_for_volume_status(self.volume['id'],

View File

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

View File

@ -60,14 +60,14 @@ class VolumeMultiBackendV2Test(base.BaseVolumeAdminTest):
extra_specs = {spec_key_with_prefix: backend_name_key}
else:
extra_specs = {spec_key_without_prefix: backend_name_key}
_, self.type = self.volume_types_client.create_volume_type(
self.type = self.volume_types_client.create_volume_type(
type_name, extra_specs=extra_specs)
self.volume_type_id_list.append(self.type['id'])
params = {self.name_field: vol_name, 'volume_type': type_name}
_, self.volume = self.admin_volume_client.create_volume(size=1,
**params)
self.volume = self.admin_volume_client.create_volume(size=1,
**params)
if with_prefix:
self.volume_id_list_with_prefix.append(self.volume['id'])
else:
@ -131,7 +131,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.get_volume(volume_id)
volume = self.admin_volume_client.get_volume(volume_id)
volume1_host = volume['os-vol-host-attr:host']
msg = ("multi-backend reporting incorrect values for volume %s" %
@ -142,10 +142,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.get_volume(volume1_id)
volume = self.admin_volume_client.get_volume(volume1_id)
volume1_host = volume['os-vol-host-attr:host']
_, volume = self.admin_volume_client.get_volume(volume2_id)
volume = self.admin_volume_client.get_volume(volume2_id)
volume2_host = volume['os-vol-host-attr:host']
msg = ("volumes %s and %s were created in the same backend" %

View File

@ -30,7 +30,7 @@ class SnapshotsActionsV2Test(base.BaseVolumeAdminTest):
vol_name = data_utils.rand_name(cls.__name__ + '-Volume-')
cls.name_field = cls.special_fields['name_field']
params = {cls.name_field: vol_name}
_, cls.volume = \
cls.volume = \
cls.volumes_client.create_volume(size=1, **params)
cls.volumes_client.wait_for_volume_status(cls.volume['id'],
'available')
@ -38,7 +38,7 @@ class SnapshotsActionsV2Test(base.BaseVolumeAdminTest):
# Create a test shared snapshot for tests
snap_name = data_utils.rand_name(cls.__name__ + '-Snapshot-')
params = {cls.name_field: snap_name}
_, cls.snapshot = \
cls.snapshot = \
cls.client.create_snapshot(cls.volume['id'], **params)
cls.client.wait_for_snapshot_status(cls.snapshot['id'],
'available')
@ -68,9 +68,9 @@ class SnapshotsActionsV2Test(base.BaseVolumeAdminTest):
# and force delete temp snapshot
temp_snapshot = self.create_snapshot(self.volume['id'])
if status:
_, body = self.admin_snapshots_client.\
self.admin_snapshots_client.\
reset_snapshot_status(temp_snapshot['id'], status)
_, volume_delete = self.admin_snapshots_client.\
self.admin_snapshots_client.\
force_delete_snapshot(temp_snapshot['id'])
self.client.wait_for_resource_deletion(temp_snapshot['id'])
@ -81,9 +81,9 @@ class SnapshotsActionsV2Test(base.BaseVolumeAdminTest):
def test_reset_snapshot_status(self):
# Reset snapshot status to creating
status = 'creating'
_, body = self.admin_snapshots_client.\
self.admin_snapshots_client.\
reset_snapshot_status(self.snapshot['id'], status)
_, snapshot_get \
snapshot_get \
= self.admin_snapshots_client.get_snapshot(self.snapshot['id'])
self.assertEqual(status, snapshot_get['status'])
@ -98,9 +98,9 @@ class SnapshotsActionsV2Test(base.BaseVolumeAdminTest):
progress = '80%'
status = 'error'
progress_alias = self._get_progress_alias()
_, body = self.client.update_snapshot_status(self.snapshot['id'],
status, progress)
_, snapshot_get \
self.client.update_snapshot_status(self.snapshot['id'],
status, progress)
snapshot_get \
= self.admin_snapshots_client.get_snapshot(self.snapshot['id'])
self.assertEqual(status, snapshot_get['status'])
self.assertEqual(progress, snapshot_get[progress_alias])

View File

@ -22,7 +22,7 @@ class VolumeHostsAdminV2TestsJSON(base.BaseVolumeAdminTest):
@test.attr(type='gate')
def test_list_hosts(self):
_, hosts = self.hosts_client.list_hosts()
hosts = self.hosts_client.list_hosts()
self.assertTrue(len(hosts) >= 2, "No. of hosts are < 2,"
"response of list hosts is: % s" % hosts)

View File

@ -33,13 +33,13 @@ class BaseVolumeQuotasAdminV2TestJSON(base.BaseVolumeAdminTest):
@test.attr(type='gate')
def test_list_quotas(self):
_, quotas = self.quotas_client.get_quota_set(self.demo_tenant_id)
quotas = self.quotas_client.get_quota_set(self.demo_tenant_id)
for key in QUOTA_KEYS:
self.assertIn(key, quotas)
@test.attr(type='gate')
def test_list_default_quotas(self):
_, quotas = self.quotas_client.get_default_quota_set(
quotas = self.quotas_client.get_default_quota_set(
self.demo_tenant_id)
for key in QUOTA_KEYS:
self.assertIn(key, quotas)
@ -47,14 +47,14 @@ class BaseVolumeQuotasAdminV2TestJSON(base.BaseVolumeAdminTest):
@test.attr(type='gate')
def test_update_all_quota_resources_for_tenant(self):
# Admin can update all the resource quota limits for a tenant
_, default_quota_set = self.quotas_client.get_default_quota_set(
default_quota_set = self.quotas_client.get_default_quota_set(
self.demo_tenant_id)
new_quota_set = {'gigabytes': 1009,
'volumes': 11,
'snapshots': 11}
# Update limits for all quota resources
_, quota_set = self.quotas_client.update_quota_set(
quota_set = self.quotas_client.update_quota_set(
self.demo_tenant_id,
**new_quota_set)
@ -70,7 +70,7 @@ class BaseVolumeQuotasAdminV2TestJSON(base.BaseVolumeAdminTest):
@test.attr(type='gate')
def test_show_quota_usage(self):
_, quota_usage = self.quotas_client.get_quota_usage(
quota_usage = self.quotas_client.get_quota_usage(
self.os_adm.credentials.tenant_id)
for key in QUOTA_KEYS:
self.assertIn(key, quota_usage)
@ -79,14 +79,14 @@ class BaseVolumeQuotasAdminV2TestJSON(base.BaseVolumeAdminTest):
@test.attr(type='gate')
def test_quota_usage(self):
_, quota_usage = self.quotas_client.get_quota_usage(
quota_usage = self.quotas_client.get_quota_usage(
self.demo_tenant_id)
volume = self.create_volume(size=1)
self.addCleanup(self.admin_volume_client.delete_volume,
volume['id'])
_, new_quota_usage = self.quotas_client.get_quota_usage(
new_quota_usage = self.quotas_client.get_quota_usage(
self.demo_tenant_id)
self.assertEqual(quota_usage['volumes']['in_use'] + 1,
@ -103,7 +103,7 @@ class BaseVolumeQuotasAdminV2TestJSON(base.BaseVolumeAdminTest):
tenant = identity_client.create_tenant(tenant_name)
tenant_id = tenant['id']
self.addCleanup(identity_client.delete_tenant, tenant_id)
_, quota_set_default = self.quotas_client.get_default_quota_set(
quota_set_default = self.quotas_client.get_default_quota_set(
tenant_id)
volume_default = quota_set_default['volumes']
@ -111,7 +111,7 @@ class BaseVolumeQuotasAdminV2TestJSON(base.BaseVolumeAdminTest):
volumes=(int(volume_default) + 5))
self.quotas_client.delete_quota_set(tenant_id)
_, quota_set_new = self.quotas_client.get_quota_set(tenant_id)
quota_set_new = self.quotas_client.get_quota_set(tenant_id)
self.assertEqual(volume_default, quota_set_new['volumes'])

View File

@ -31,7 +31,7 @@ class BaseVolumeQuotasNegativeV2TestJSON(base.BaseVolumeAdminTest):
# NOTE(gfidente): no need to restore original quota set
# after the tests as they only work with tenant isolation.
_, quota_set = cls.quotas_client.update_quota_set(
cls.quotas_client.update_quota_set(
cls.demo_tenant_id,
**cls.shared_quota_set)
@ -62,7 +62,7 @@ class BaseVolumeQuotasNegativeV2TestJSON(base.BaseVolumeAdminTest):
**self.shared_quota_set)
new_quota_set = {'gigabytes': 2, 'volumes': 2, 'snapshots': 1}
_, quota_set = self.quotas_client.update_quota_set(
self.quotas_client.update_quota_set(
self.demo_tenant_id,
**new_quota_set)
self.assertRaises(exceptions.OverLimit,
@ -70,7 +70,7 @@ class BaseVolumeQuotasNegativeV2TestJSON(base.BaseVolumeAdminTest):
size=1)
new_quota_set = {'gigabytes': 2, 'volumes': 1, 'snapshots': 2}
_, quota_set = self.quotas_client.update_quota_set(
self.quotas_client.update_quota_set(
self.demo_tenant_id,
**self.shared_quota_set)
self.assertRaises(exceptions.OverLimit,

View File

@ -27,19 +27,19 @@ class VolumesServicesV2TestJSON(base.BaseVolumeAdminTest):
@classmethod
def resource_setup(cls):
super(VolumesServicesV2TestJSON, cls).resource_setup()
_, cls.services = cls.admin_volume_services_client.list_services()
cls.services = cls.admin_volume_services_client.list_services()
cls.host_name = cls.services[0]['host']
cls.binary_name = cls.services[0]['binary']
@test.attr(type='gate')
def test_list_services(self):
_, services = self.admin_volume_services_client.list_services()
services = self.admin_volume_services_client.list_services()
self.assertNotEqual(0, len(services))
@test.attr(type='gate')
def test_get_service_by_service_binary_name(self):
params = {'binary': self.binary_name}
_, services = self.admin_volume_services_client.list_services(params)
services = self.admin_volume_services_client.list_services(params)
self.assertNotEqual(0, len(services))
for service in services:
self.assertEqual(self.binary_name, service['binary'])
@ -50,7 +50,7 @@ class VolumesServicesV2TestJSON(base.BaseVolumeAdminTest):
service['host'] == self.host_name]
params = {'host': self.host_name}
_, services = self.admin_volume_services_client.list_services(params)
services = self.admin_volume_services_client.list_services(params)
# we could have a periodic job checkin between the 2 service
# lookups, so only compare binary lists.
@ -64,7 +64,7 @@ class VolumesServicesV2TestJSON(base.BaseVolumeAdminTest):
def test_get_service_by_service_and_host_name(self):
params = {'host': self.host_name, 'binary': self.binary_name}
_, services = self.admin_volume_services_client.list_services(params)
services = self.admin_volume_services_client.list_services(params)
self.assertEqual(1, len(services))
self.assertEqual(self.host_name, services[0]['host'])
self.assertEqual(self.binary_name, services[0]['binary'])

View File

@ -34,7 +34,7 @@ class VolumeTypesV2Test(base.BaseVolumeAdminTest):
@test.attr(type='smoke')
def test_volume_type_list(self):
# List Volume types.
_, body = self.volume_types_client.list_volume_types()
body = self.volume_types_client.list_volume_types()
self.assertIsInstance(body, list)
@test.attr(type='smoke')
@ -49,14 +49,14 @@ class VolumeTypesV2Test(base.BaseVolumeAdminTest):
extra_specs = {"storage_protocol": proto,
"vendor_name": vendor}
body = {}
_, body = self.volume_types_client.create_volume_type(
body = self.volume_types_client.create_volume_type(
vol_type_name,
extra_specs=extra_specs)
self.assertIn('id', body)
self.addCleanup(self._delete_volume_type, body['id'])
self.assertIn('name', body)
params = {self.name_field: vol_name, 'volume_type': vol_type_name}
_, volume = self.volumes_client.create_volume(
volume = self.volumes_client.create_volume(
size=1, **params)
self.assertIn('id', volume)
self.addCleanup(self._delete_volume, volume['id'])
@ -67,7 +67,7 @@ class VolumeTypesV2Test(base.BaseVolumeAdminTest):
self.assertTrue(volume['id'] is not None,
"Field volume id is empty or not found.")
self.volumes_client.wait_for_volume_status(volume['id'], 'available')
_, fetched_volume = self.volumes_client.get_volume(volume['id'])
fetched_volume = self.volumes_client.get_volume(volume['id'])
self.assertEqual(vol_name, fetched_volume[self.name_field],
'The fetched Volume is different '
'from the created Volume')
@ -87,7 +87,7 @@ class VolumeTypesV2Test(base.BaseVolumeAdminTest):
vendor = CONF.volume.vendor_name
extra_specs = {"storage_protocol": proto,
"vendor_name": vendor}
_, body = self.volume_types_client.create_volume_type(
body = self.volume_types_client.create_volume_type(
name,
extra_specs=extra_specs)
self.assertIn('id', body)
@ -98,7 +98,7 @@ class VolumeTypesV2Test(base.BaseVolumeAdminTest):
"to the requested name")
self.assertTrue(body['id'] is not None,
"Field volume_type id is empty or not found.")
_, fetched_volume_type = self.volume_types_client.get_volume_type(
fetched_volume_type = self.volume_types_client.get_volume_type(
body['id'])
self.assertEqual(name, fetched_volume_type['name'],
'The fetched Volume_type is different '
@ -116,11 +116,11 @@ class VolumeTypesV2Test(base.BaseVolumeAdminTest):
provider = "LuksEncryptor"
control_location = "front-end"
name = data_utils.rand_name("volume-type-")
_, body = self.volume_types_client.create_volume_type(name)
body = self.volume_types_client.create_volume_type(name)
self.addCleanup(self._delete_volume_type, body['id'])
# Create encryption type
_, encryption_type = self.volume_types_client.create_encryption_type(
encryption_type = self.volume_types_client.create_encryption_type(
body['id'], provider=provider,
control_location=control_location)
self.assertIn('volume_type_id', encryption_type)
@ -132,7 +132,7 @@ class VolumeTypesV2Test(base.BaseVolumeAdminTest):
"equal to the requested control_location")
# Get encryption type
_, fetched_encryption_type = (
fetched_encryption_type = (
self.volume_types_client.get_encryption_type(
encryption_type['volume_type_id']))
self.assertEqual(provider,
@ -150,7 +150,7 @@ class VolumeTypesV2Test(base.BaseVolumeAdminTest):
resource = {"id": encryption_type['volume_type_id'],
"type": "encryption-type"}
self.volume_types_client.wait_for_resource_deletion(resource)
_, deleted_encryption_type = (
deleted_encryption_type = (
self.volume_types_client.get_encryption_type(
encryption_type['volume_type_id']))
self.assertEmpty(deleted_encryption_type)

View File

@ -25,7 +25,7 @@ class VolumeTypesExtraSpecsV2Test(base.BaseVolumeAdminTest):
def resource_setup(cls):
super(VolumeTypesExtraSpecsV2Test, cls).resource_setup()
vol_type_name = data_utils.rand_name('Volume-type-')
_, cls.volume_type = cls.volume_types_client.create_volume_type(
cls.volume_type = cls.volume_types_client.create_volume_type(
vol_type_name)
@classmethod
@ -37,11 +37,11 @@ class VolumeTypesExtraSpecsV2Test(base.BaseVolumeAdminTest):
def test_volume_type_extra_specs_list(self):
# List Volume types extra specs.
extra_specs = {"spec1": "val1"}
_, body = self.volume_types_client.create_volume_type_extra_specs(
body = self.volume_types_client.create_volume_type_extra_specs(
self.volume_type['id'], extra_specs)
self.assertEqual(extra_specs, body,
"Volume type extra spec incorrectly created")
_, body = self.volume_types_client.list_volume_types_extra_specs(
body = self.volume_types_client.list_volume_types_extra_specs(
self.volume_type['id'])
self.assertIsInstance(body, dict)
self.assertIn('spec1', body)
@ -50,13 +50,13 @@ class VolumeTypesExtraSpecsV2Test(base.BaseVolumeAdminTest):
def test_volume_type_extra_specs_update(self):
# Update volume type extra specs
extra_specs = {"spec2": "val1"}
_, body = self.volume_types_client.create_volume_type_extra_specs(
body = self.volume_types_client.create_volume_type_extra_specs(
self.volume_type['id'], extra_specs)
self.assertEqual(extra_specs, body,
"Volume type extra spec incorrectly created")
extra_spec = {"spec2": "val2"}
_, body = self.volume_types_client.update_volume_type_extra_specs(
body = self.volume_types_client.update_volume_type_extra_specs(
self.volume_type['id'],
extra_spec.keys()[0],
extra_spec)
@ -68,7 +68,7 @@ class VolumeTypesExtraSpecsV2Test(base.BaseVolumeAdminTest):
def test_volume_type_extra_spec_create_get_delete(self):
# Create/Get/Delete volume type extra spec.
extra_specs = {"spec3": "val1"}
_, body = self.volume_types_client.create_volume_type_extra_specs(
body = self.volume_types_client.create_volume_type_extra_specs(
self.volume_type['id'],
extra_specs)
self.assertEqual(extra_specs, body,

View File

@ -29,7 +29,7 @@ class ExtraSpecsNegativeV2Test(base.BaseVolumeAdminTest):
super(ExtraSpecsNegativeV2Test, cls).resource_setup()
vol_type_name = data_utils.rand_name('Volume-type-')
cls.extra_specs = {"spec1": "val1"}
_, cls.volume_type = cls.volume_types_client.create_volume_type(
cls.volume_type = cls.volume_types_client.create_volume_type(
vol_type_name,
extra_specs=cls.extra_specs)

View File

@ -31,8 +31,8 @@ class VolumesActionsV2Test(base.BaseVolumeAdminTest):
cls.name_field = cls.special_fields['name_field']
params = {cls.name_field: vol_name}
_, cls.volume = cls.client.create_volume(size=1,
**params)
cls.volume = cls.client.create_volume(size=1,
**params)
cls.client.wait_for_volume_status(cls.volume['id'], 'available')
@classmethod
@ -45,9 +45,9 @@ class VolumesActionsV2Test(base.BaseVolumeAdminTest):
def _reset_volume_status(self, volume_id, status):
# Reset the volume status
_, body = self.admin_volume_client.reset_volume_status(volume_id,
status)
return _, body
body = self.admin_volume_client.reset_volume_status(volume_id,
status)
return body
def tearDown(self):
# Set volume's status to available after test
@ -58,8 +58,8 @@ 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(size=1,
**params)
temp_volume = self.client.create_volume(size=1,
**params)
self.client.wait_for_volume_status(temp_volume['id'], 'available')
return temp_volume
@ -68,16 +68,15 @@ class VolumesActionsV2Test(base.BaseVolumeAdminTest):
# Create volume, reset volume status, and force delete temp volume
temp_volume = self._create_temp_volume()
if status:
_, body = self._reset_volume_status(temp_volume['id'], status)
_, volume_delete = self.admin_volume_client.\
force_delete_volume(temp_volume['id'])
self._reset_volume_status(temp_volume['id'], status)
self.admin_volume_client.force_delete_volume(temp_volume['id'])
self.client.wait_for_resource_deletion(temp_volume['id'])
@test.attr(type='gate')
def test_volume_reset_status(self):
# test volume reset status : available->error->available
_, body = self._reset_volume_status(self.volume['id'], 'error')
_, volume_get = self.admin_volume_client.get_volume(
self._reset_volume_status(self.volume['id'], 'error')
volume_get = self.admin_volume_client.get_volume(
self.volume['id'])
self.assertEqual('error', volume_get['status'])

View File

@ -40,8 +40,8 @@ class VolumesBackupsV2Test(base.BaseVolumeAdminTest):
# Create backup
backup_name = data_utils.rand_name('Backup')
create_backup = self.backups_adm_client.create_backup
_, backup = create_backup(self.volume['id'],
name=backup_name)
backup = create_backup(self.volume['id'],
name=backup_name)
self.addCleanup(self.backups_adm_client.delete_backup,
backup['id'])
self.assertEqual(backup_name, backup['name'])
@ -51,16 +51,16 @@ class VolumesBackupsV2Test(base.BaseVolumeAdminTest):
'available')
# Get a given backup
_, backup = self.backups_adm_client.get_backup(backup['id'])
backup = self.backups_adm_client.get_backup(backup['id'])
self.assertEqual(backup_name, backup['name'])
# Get all backups with detail
_, backups = self.backups_adm_client.list_backups_with_detail()
backups = self.backups_adm_client.list_backups_with_detail()
self.assertIn((backup['name'], backup['id']),
[(m['name'], m['id']) for m in backups])
# Restore backup
_, restore = self.backups_adm_client.restore_backup(backup['id'])
restore = self.backups_adm_client.restore_backup(backup['id'])
# Delete backup
self.addCleanup(self.admin_volume_client.delete_volume,

View File

@ -97,7 +97,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)
cls.volumes.append(volume)
cls.volumes_client.wait_for_volume_status(volume['id'], 'available')
@ -106,8 +106,8 @@ class BaseVolumeTest(tempest.test.BaseTestCase):
@classmethod
def create_snapshot(cls, volume_id=1, **kwargs):
"""Wrapper utility that returns a test snapshot."""
_, snapshot = cls.snapshots_client.create_snapshot(volume_id,
**kwargs)
snapshot = cls.snapshots_client.create_snapshot(volume_id,
**kwargs)
cls.snapshots.append(snapshot)
cls.snapshots_client.wait_for_snapshot_status(snapshot['id'],
'available')
@ -198,8 +198,8 @@ class BaseVolumeAdminTest(BaseVolumeTest):
"""create a test Qos-Specs."""
name = name or data_utils.rand_name(cls.__name__ + '-QoS')
consumer = consumer or 'front-end'
_, qos_specs = cls.volume_qos_client.create_qos(name, consumer,
**kwargs)
qos_specs = cls.volume_qos_client.create_qos(name, consumer,
**kwargs)
cls.qos_specs.append(qos_specs['id'])
return qos_specs

View File

@ -31,7 +31,7 @@ class AvailabilityZoneV2TestJSON(base.BaseVolumeTest):
@test.attr(type='gate')
def test_get_availability_zone_list(self):
# List of availability zone
_, availability_zone = self.client.get_availability_zone_list()
availability_zone = self.client.get_availability_zone_list()
self.assertTrue(len(availability_zone) > 0)

View File

@ -30,7 +30,7 @@ class ExtensionsV2TestJSON(base.BaseVolumeTest):
@test.attr(type='gate')
def test_list_extensions(self):
# List of all extensions
_, extensions = self.volumes_extension_client.list_extensions()
extensions = self.volumes_extension_client.list_extensions()
if len(CONF.volume_feature_enabled.api_extensions) == 0:
raise self.skipException('There are not any extensions configured')
extension_list = [extension.get('alias') for extension in extensions]

View File

@ -47,12 +47,12 @@ class QosSpecsV2TestJSON(base.BaseVolumeAdminTest):
self.volume_qos_client.wait_for_resource_deletion(body['id'])
# validate the deletion
_, list_qos = self.volume_qos_client.list_qos()
list_qos = self.volume_qos_client.list_qos()
self.assertNotIn(body, list_qos)
def _create_test_volume_type(self):
vol_type_name = utils.rand_name("volume-type")
_, vol_type = self.volume_types_client.create_volume_type(
vol_type = self.volume_types_client.create_volume_type(
vol_type_name)
self.addCleanup(self.volume_types_client.delete_volume_type,
vol_type['id'])
@ -63,7 +63,7 @@ class QosSpecsV2TestJSON(base.BaseVolumeAdminTest):
self.created_qos['id'], vol_type_id)
def _test_get_association_qos(self):
_, body = self.volume_qos_client.get_association_qos(
body = self.volume_qos_client.get_association_qos(
self.created_qos['id'])
associations = []
@ -97,24 +97,24 @@ class QosSpecsV2TestJSON(base.BaseVolumeAdminTest):
@test.attr(type='smoke')
def test_get_qos(self):
"""Tests the detail of a given qos-specs"""
_, body = self.volume_qos_client.get_qos(self.created_qos['id'])
body = self.volume_qos_client.get_qos(self.created_qos['id'])
self.assertEqual(self.qos_name, body['name'])
self.assertEqual(self.qos_consumer, body['consumer'])
@test.attr(type='smoke')
def test_list_qos(self):
"""Tests the list of all qos-specs"""
_, body = self.volume_qos_client.list_qos()
body = self.volume_qos_client.list_qos()
self.assertIn(self.created_qos, body)
@test.attr(type='smoke')
def test_set_unset_qos_key(self):
"""Test the addition of a specs key to qos-specs"""
args = {'iops_bytes': '500'}
_, body = self.volume_qos_client.set_qos_key(self.created_qos['id'],
iops_bytes='500')
body = self.volume_qos_client.set_qos_key(self.created_qos['id'],
iops_bytes='500')
self.assertEqual(args, body)
_, body = self.volume_qos_client.get_qos(self.created_qos['id'])
body = self.volume_qos_client.get_qos(self.created_qos['id'])
self.assertEqual(args['iops_bytes'], body['specs']['iops_bytes'])
# test the deletion of a specs key from qos-specs
@ -123,7 +123,7 @@ class QosSpecsV2TestJSON(base.BaseVolumeAdminTest):
operation = 'qos-key-unset'
self.volume_qos_client.wait_for_qos_operations(self.created_qos['id'],
operation, keys)
_, body = self.volume_qos_client.get_qos(self.created_qos['id'])
body = self.volume_qos_client.get_qos(self.created_qos['id'])
self.assertNotIn(keys[0], body['specs'])
@test.attr(type='smoke')

View File

@ -42,15 +42,15 @@ class SnapshotV2MetadataTestJSON(base.BaseVolumeTest):
"key3": "value3"}
expected = {"key2": "value2",
"key3": "value3"}
_, body = self.client.create_snapshot_metadata(self.snapshot_id,
metadata)
body = self.client.create_snapshot_metadata(self.snapshot_id,
metadata)
# Get the metadata of the snapshot
_, body = self.client.get_snapshot_metadata(self.snapshot_id)
body = self.client.get_snapshot_metadata(self.snapshot_id)
self.assertEqual(metadata, body)
# Delete one item metadata of the snapshot
self.client.delete_snapshot_metadata_item(
self.snapshot_id, "key1")
_, body = self.client.get_snapshot_metadata(self.snapshot_id)
body = self.client.get_snapshot_metadata(self.snapshot_id)
self.assertEqual(expected, body)
@test.attr(type='gate')
@ -62,16 +62,16 @@ class SnapshotV2MetadataTestJSON(base.BaseVolumeTest):
update = {"key3": "value3_update",
"key4": "value4"}
# Create metadata for the snapshot
_, body = self.client.create_snapshot_metadata(self.snapshot_id,
metadata)
body = self.client.create_snapshot_metadata(self.snapshot_id,
metadata)
# Get the metadata of the snapshot
_, body = self.client.get_snapshot_metadata(self.snapshot_id)
body = self.client.get_snapshot_metadata(self.snapshot_id)
self.assertEqual(metadata, body)
# Update metadata item
_, body = self.client.update_snapshot_metadata(
body = self.client.update_snapshot_metadata(
self.snapshot_id, update)
# Get the metadata of the snapshot
_, body = self.client.get_snapshot_metadata(self.snapshot_id)
body = self.client.get_snapshot_metadata(self.snapshot_id)
self.assertEqual(update, body)
@test.attr(type='gate')
@ -85,16 +85,16 @@ class SnapshotV2MetadataTestJSON(base.BaseVolumeTest):
"key2": "value2",
"key3": "value3_update"}
# Create metadata for the snapshot
_, body = self.client.create_snapshot_metadata(self.snapshot_id,
metadata)
body = self.client.create_snapshot_metadata(self.snapshot_id,
metadata)
# Get the metadata of the snapshot
_, body = self.client.get_snapshot_metadata(self.snapshot_id)
body = self.client.get_snapshot_metadata(self.snapshot_id)
self.assertEqual(metadata, body)
# Update metadata item
_, body = self.client.update_snapshot_metadata_item(
body = self.client.update_snapshot_metadata_item(
self.snapshot_id, "key3", update_item)
# Get the metadata of the snapshot
_, body = self.client.get_snapshot_metadata(self.snapshot_id)
body = self.client.get_snapshot_metadata(self.snapshot_id)
self.assertEqual(expect, body)

View File

@ -41,15 +41,15 @@ class VolumesV2MetadataTest(base.BaseVolumeTest):
"key3": "value3",
"key4": "<value&special_chars>"}
_, body = self.volumes_client.create_volume_metadata(self.volume_id,
metadata)
body = self.volumes_client.create_volume_metadata(self.volume_id,
metadata)
# Get the metadata of the volume
_, body = self.volumes_client.get_volume_metadata(self.volume_id)
body = self.volumes_client.get_volume_metadata(self.volume_id)
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.get_volume_metadata(self.volume_id)
body = self.volumes_client.get_volume_metadata(self.volume_id)
self.assertNotIn("key1", body)
del metadata["key1"]
self.assertThat(body.items(), matchers.ContainsAll(metadata.items()))
@ -65,16 +65,16 @@ class VolumesV2MetadataTest(base.BaseVolumeTest):
"key1": "value1_update"}
# Create metadata for the volume
_, body = self.volumes_client.create_volume_metadata(
body = self.volumes_client.create_volume_metadata(
self.volume_id, metadata)
# Get the metadata of the volume
_, body = self.volumes_client.get_volume_metadata(self.volume_id)
body = self.volumes_client.get_volume_metadata(self.volume_id)
self.assertThat(body.items(), matchers.ContainsAll(metadata.items()))
# Update metadata
_, body = self.volumes_client.update_volume_metadata(
body = self.volumes_client.update_volume_metadata(
self.volume_id, update)
# Get the metadata of the volume
_, body = self.volumes_client.get_volume_metadata(self.volume_id)
body = self.volumes_client.get_volume_metadata(self.volume_id)
self.assertThat(body.items(), matchers.ContainsAll(update.items()))
@test.attr(type='gate')
@ -88,14 +88,14 @@ class VolumesV2MetadataTest(base.BaseVolumeTest):
"key2": "value2",
"key3": "value3_update"}
# Create metadata for the volume
_, body = self.volumes_client.create_volume_metadata(
body = self.volumes_client.create_volume_metadata(
self.volume_id, metadata)
self.assertThat(body.items(), matchers.ContainsAll(metadata.items()))
# Update metadata item
_, body = self.volumes_client.update_volume_metadata_item(
body = self.volumes_client.update_volume_metadata_item(
self.volume_id, "key3", update_item)
# Get the metadata of the volume
_, body = self.volumes_client.get_volume_metadata(self.volume_id)
body = self.volumes_client.get_volume_metadata(self.volume_id)
self.assertThat(body.items(), matchers.ContainsAll(expect.items()))

View File

@ -58,24 +58,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_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.get_volume_transfer(transfer_id)
body = self.client.get_volume_transfer(transfer_id)
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()
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)
body = self.alt_client.accept_volume_transfer(transfer_id,
auth_key)
self.alt_client.wait_for_volume_status(volume['id'], 'available')
def test_create_list_delete_volume_transfer(self):
@ -84,13 +84,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_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()
for transfer in body:
if volume['id'] == transfer['volume_id']:
break

View File

@ -57,11 +57,11 @@ class VolumesV2ActionsTest(base.BaseVolumeTest):
def test_attach_detach_volume_to_instance(self):
# Volume is attached and detached successfully from an instance
mountpoint = '/dev/vdc'
_, body = self.client.attach_volume(self.volume['id'],
self.server['id'],
mountpoint)
self.client.attach_volume(self.volume['id'],
self.server['id'],
mountpoint)
self.client.wait_for_volume_status(self.volume['id'], 'in-use')
_, body = self.client.detach_volume(self.volume['id'])
self.client.detach_volume(self.volume['id'])
self.client.wait_for_volume_status(self.volume['id'], 'available')
@test.stresstest(class_setup_per='process')
@ -70,9 +70,9 @@ class VolumesV2ActionsTest(base.BaseVolumeTest):
def test_get_volume_attachment(self):
# Verify that a volume's attachment information is retrieved
mountpoint = '/dev/vdc'
_, body = self.client.attach_volume(self.volume['id'],
self.server['id'],
mountpoint)
self.client.attach_volume(self.volume['id'],
self.server['id'],
mountpoint)
self.client.wait_for_volume_status(self.volume['id'], 'in-use')
# NOTE(gfidente): added in reverse order because functions will be
# called in reverse order to the order they are added (LIFO)
@ -80,7 +80,7 @@ class VolumesV2ActionsTest(base.BaseVolumeTest):
self.volume['id'],
'available')
self.addCleanup(self.client.detach_volume, self.volume['id'])
_, volume = self.client.get_volume(self.volume['id'])
volume = self.client.get_volume(self.volume['id'])
self.assertIn('attachments', volume)
attachment = self.client.get_attachment_from_volume(volume)
self.assertEqual(mountpoint, attachment['device'])
@ -96,9 +96,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)
image_id = body["image_id"]
self.addCleanup(self.image_client.delete_image, image_id)
self.image_client.wait_for_image_status(image_id, 'active')
@ -107,14 +107,14 @@ class VolumesV2ActionsTest(base.BaseVolumeTest):
@test.attr(type='gate')
def test_reserve_unreserve_volume(self):
# Mark volume as reserved.
_, body = self.client.reserve_volume(self.volume['id'])
body = self.client.reserve_volume(self.volume['id'])
# To get the volume info
_, body = self.client.get_volume(self.volume['id'])
body = self.client.get_volume(self.volume['id'])
self.assertIn('attaching', body['status'])
# Unmark volume as reserved.
_, body = self.client.unreserve_volume(self.volume['id'])
body = self.client.unreserve_volume(self.volume['id'])
# To get the volume info
_, body = self.client.get_volume(self.volume['id'])
body = self.client.get_volume(self.volume['id'])
self.assertIn('available', body['status'])
def _is_true(self, val):
@ -124,20 +124,19 @@ class VolumesV2ActionsTest(base.BaseVolumeTest):
def test_volume_readonly_update(self):
# Update volume readonly true
readonly = True
_, body = self.client.update_volume_readonly(self.volume['id'],
readonly)
self.client.update_volume_readonly(self.volume['id'],
readonly)
# Get Volume information
_, fetched_volume = self.client.get_volume(self.volume['id'])
fetched_volume = self.client.get_volume(self.volume['id'])
bool_flag = self._is_true(fetched_volume['metadata']['readonly'])
self.assertEqual(True, bool_flag)
# Update volume readonly false
readonly = False
_, body = self.client.update_volume_readonly(self.volume['id'],
readonly)
self.client.update_volume_readonly(self.volume['id'], readonly)
# Get Volume information
_, fetched_volume = self.client.get_volume(self.volume['id'])
fetched_volume = self.client.get_volume(self.volume['id'])
bool_flag = self._is_true(fetched_volume['metadata']['readonly'])
self.assertEqual(False, bool_flag)

View File

@ -32,9 +32,9 @@ class VolumesV2ExtendTest(base.BaseVolumeTest):
# Extend Volume Test.
self.volume = self.create_volume()
extend_size = int(self.volume['size']) + 1
_, body = self.client.extend_volume(self.volume['id'], extend_size)
self.client.extend_volume(self.volume['id'], extend_size)
self.client.wait_for_volume_status(self.volume['id'], 'available')
_, volume = self.client.get_volume(self.volume['id'])
volume = self.client.get_volume(self.volume['id'])
self.assertEqual(int(volume['size']), extend_size)

View File

@ -54,7 +54,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)
self.assertIn('id', volume)
self.addCleanup(self._delete_volume, volume['id'])
self.client.wait_for_volume_status(volume['id'], 'available')
@ -65,7 +65,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.get_volume(volume['id'])
fetched_volume = self.client.get_volume(volume['id'])
self.assertEqual(v_name,
fetched_volume[self.name_field],
'The fetched Volume name is different '
@ -90,18 +90,18 @@ class VolumesV2GetTest(base.BaseVolumeTest):
# Update Volume
# Test volume update when display_name is same with original value
params = {self.name_field: v_name}
_, update_volume = self.client.update_volume(volume['id'], **params)
self.client.update_volume(volume['id'], **params)
# Test volume update when display_name is new
new_v_name = data_utils.rand_name('new-Volume')
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)
# 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 get_volume method
_, updated_volume = self.client.get_volume(volume['id'])
updated_volume = self.client.get_volume(volume['id'])
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])
@ -116,15 +116,14 @@ 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(size=1, **params)
new_volume = self.client.create_volume(size=1, **params)
self.assertIn('id', new_volume)
self.addCleanup(self._delete_volume, new_volume['id'])
self.client.wait_for_volume_status(new_volume['id'], 'available')
params = {self.name_field: volume[self.name_field],
self.descrip_field: volume[self.descrip_field]}
_, update_volume = self.client.update_volume(new_volume['id'],
**params)
self.client.update_volume(new_volume['id'], **params)
# NOTE(jdg): Revert back to strict true/false checking
# after fix for bug #1227837 merges

View File

@ -66,7 +66,7 @@ class VolumesV2ListTestJSON(base.BaseVolumeTest):
cls.metadata = {'Type': 'work'}
for i in range(3):
volume = cls.create_volume(metadata=cls.metadata)
_, volume = cls.client.get_volume(volume['id'])
volume = cls.client.get_volume(volume['id'])
cls.volume_list.append(volume)
cls.volume_id_list.append(volume['id'])
@ -84,10 +84,10 @@ class VolumesV2ListTestJSON(base.BaseVolumeTest):
and validates result.
"""
if with_detail:
_, fetched_vol_list = \
fetched_vol_list = \
self.client.list_volumes_with_detail(params=params)
else:
_, fetched_vol_list = self.client.list_volumes(params=params)
fetched_vol_list = self.client.list_volumes(params=params)
# Validating params of fetched volumes
# In v2, only list detail view includes items in params.
@ -111,7 +111,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()
self.assertVolumesIn(fetched_list, self.volume_list,
fields=self.VOLUME_FIELDS)
@ -119,14 +119,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_with_detail()
fetched_list = self.client.list_volumes_with_detail()
self.assertVolumesIn(fetched_list, self.volume_list)
@test.attr(type='gate')
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)
fetched_vol = self.client.list_volumes(params)
self.assertEqual(1, len(fetched_vol), str(fetched_vol))
self.assertEqual(fetched_vol[0][self.name],
volume[self.name])
@ -135,7 +135,7 @@ 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_with_detail(params)
fetched_vol = self.client.list_volumes_with_detail(params)
self.assertEqual(1, len(fetched_vol), str(fetched_vol))
self.assertEqual(fetched_vol[0][self.name],
volume[self.name])
@ -143,7 +143,7 @@ class VolumesV2ListTestJSON(base.BaseVolumeTest):
@test.attr(type='gate')
def test_volumes_list_by_status(self):
params = {'status': 'available'}
_, fetched_list = self.client.list_volumes(params)
fetched_list = self.client.list_volumes(params)
self._list_by_param_value_and_assert(params)
self.assertVolumesIn(fetched_list, self.volume_list,
fields=self.VOLUME_FIELDS)
@ -151,7 +151,7 @@ class VolumesV2ListTestJSON(base.BaseVolumeTest):
@test.attr(type='gate')
def test_volumes_list_details_by_status(self):
params = {'status': 'available'}
_, fetched_list = self.client.list_volumes_with_detail(params)
fetched_list = self.client.list_volumes_with_detail(params)
for volume in fetched_list:
self.assertEqual('available', volume['status'])
self.assertVolumesIn(fetched_list, self.volume_list)
@ -161,7 +161,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)
fetched_list = self.client.list_volumes(params)
self._list_by_param_value_and_assert(params)
self.assertVolumesIn(fetched_list, self.volume_list,
fields=self.VOLUME_FIELDS)
@ -171,7 +171,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_with_detail(params)
fetched_list = self.client.list_volumes_with_detail(params)
for volume in fetched_list:
self.assertEqual(zone, volume['availability_zone'])
self.assertVolumesIn(fetched_list, self.volume_list)

View File

@ -224,38 +224,40 @@ class VolumesV2NegativeTest(base.BaseVolumeTest):
@test.attr(type=['negative', 'gate'])
def test_reserve_volume_with_negative_volume_status(self):
# Mark volume as reserved.
_, body = self.client.reserve_volume(self.volume['id'])
self.client.reserve_volume(self.volume['id'])
# Mark volume which is marked as reserved before
self.assertRaises(exceptions.BadRequest,
self.client.reserve_volume,
self.volume['id'])
# Unmark volume as reserved.
_, body = self.client.unreserve_volume(self.volume['id'])
self.client.unreserve_volume(self.volume['id'])
@test.attr(type=['negative', 'gate'])
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)
fetched_volume = self.client.list_volumes(params)
self.assertEqual(0, len(fetched_volume))
@test.attr(type=['negative', 'gate'])
def test_list_volumes_detail_with_nonexistent_name(self):
v_name = data_utils.rand_name('Volume-')
params = {self.name_field: v_name}
_, fetched_volume = self.client.list_volumes_with_detail(params)
fetched_volume = \
self.client.list_volumes_with_detail(params)
self.assertEqual(0, len(fetched_volume))
@test.attr(type=['negative', 'gate'])
def test_list_volumes_with_invalid_status(self):
params = {'status': 'null'}
_, fetched_volume = self.client.list_volumes(params)
fetched_volume = self.client.list_volumes(params)
self.assertEqual(0, len(fetched_volume))
@test.attr(type=['negative', 'gate'])
def test_list_volumes_detail_with_invalid_status(self):
params = {'status': 'null'}
_, fetched_volume = self.client.list_volumes_with_detail(params)
fetched_volume = \
self.client.list_volumes_with_detail(params)
self.assertEqual(0, len(fetched_volume))

View File

@ -44,11 +44,11 @@ class VolumesV2SnapshotTestJSON(base.BaseVolumeTest):
and validates result.
"""
if with_detail:
_, fetched_snap_list = \
fetched_snap_list = \
self.snapshots_client.\
list_snapshots_with_detail(params=params)
else:
_, fetched_snap_list = \
fetched_snap_list = \
self.snapshots_client.list_snapshots(params=params)
# Validating params of fetched snapshots
@ -94,14 +94,14 @@ class VolumesV2SnapshotTestJSON(base.BaseVolumeTest):
snapshot = self.create_snapshot(self.volume_origin['id'], **params)
# Get the snap and check for some of its details
_, snap_get = self.snapshots_client.get_snapshot(snapshot['id'])
snap_get = self.snapshots_client.get_snapshot(snapshot['id'])
self.assertEqual(self.volume_origin['id'],
snap_get['volume_id'],
"Referred volume origin mismatch")
# Compare also with the output from the list action
tracking_data = (snapshot['id'], snapshot[self.name_field])
_, snaps_list = self.snapshots_client.list_snapshots()
snaps_list = self.snapshots_client.list_snapshots()
snaps_data = [(f['id'], f[self.name_field]) for f in snaps_list]
self.assertIn(tracking_data, snaps_data)
@ -110,13 +110,13 @@ class VolumesV2SnapshotTestJSON(base.BaseVolumeTest):
new_desc = 'This is the new description of snapshot.'
params = {self.name_field: new_s_name,
self.descrip_field: new_desc}
_, update_snapshot = \
update_snapshot = \
self.snapshots_client.update_snapshot(snapshot['id'], **params)
# Assert response body for update_snapshot method
self.assertEqual(new_s_name, update_snapshot[self.name_field])
self.assertEqual(new_desc, update_snapshot[self.descrip_field])
# Assert response body for get_snapshot method
_, updated_snapshot = \
updated_snapshot = \
self.snapshots_client.get_snapshot(snapshot['id'])
self.assertEqual(new_s_name, updated_snapshot[self.name_field])
self.assertEqual(new_desc, updated_snapshot[self.descrip_field])
@ -172,7 +172,7 @@ class VolumesV2SnapshotTestJSON(base.BaseVolumeTest):
# create a snap based volume and deletes it
snapshot = self.create_snapshot(self.volume_origin['id'])
# NOTE(gfidente): size is required also when passing snapshot_id
_, volume = self.volumes_client.create_volume(
volume = self.volumes_client.create_volume(
size=1,
snapshot_id=snapshot['id'])
self.volumes_client.wait_for_volume_status(volume['id'], 'available')

View File

@ -41,7 +41,7 @@ class VolumesV2ListTestJSON(base.BaseVolumeTest):
cls.metadata = {'Type': 'work'}
for i in range(3):
volume = cls.create_volume(metadata=cls.metadata)
_, volume = cls.client.get_volume(volume['id'])
volume = cls.client.get_volume(volume['id'])
cls.volume_list.append(volume)
cls.volume_id_list.append(volume['id'])
@ -65,7 +65,7 @@ class VolumesV2ListTestJSON(base.BaseVolumeTest):
'sort_dir': sort_dir,
'sort_key': sort_key
}
_, fetched_volume = self.client.list_volumes_with_detail(params)
fetched_volume = self.client.list_volumes_with_detail(params)
self.assertEqual(limit, len(fetched_volume),
"The count of volumes is %s, expected:%s " %
(len(fetched_volume), limit))

View File

@ -142,7 +142,7 @@ class SnapshotService(BaseService):
def list(self):
client = self.client
__, snaps = client.list_snapshots()
snaps = client.list_snapshots()
LOG.debug("List count, %s Snapshots" % len(snaps))
return snaps
@ -323,7 +323,7 @@ class VolumeService(BaseService):
def list(self):
client = self.client
_, vols = client.list_volumes()
vols = client.list_volumes()
LOG.debug("List count, %s Volumes" % len(vols))
return vols

View File

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

View File

@ -154,7 +154,7 @@ def get_enabled_extensions(service):
def verify_extensions(os, service, results):
extensions_client = get_extension_client(os, service)
if service == 'neutron':
if service == 'neutron' or service == 'cinder':
resp = extensions_client.list_extensions()
else:
__, resp = extensions_client.list_extensions()

View File

@ -210,7 +210,7 @@ class ScenarioTest(tempest.test.BaseTestCase):
imageRef=None, volume_type=None, wait_on_delete=True):
if name is None:
name = data_utils.rand_name(self.__class__.__name__)
_, volume = self.volumes_client.create_volume(
volume = self.volumes_client.create_volume(
size=size, display_name=name, snapshot_id=snapshot_id,
imageRef=imageRef, volume_type=volume_type)
@ -230,7 +230,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.get_volume(volume['id'])
volume = self.volumes_client.get_volume(volume['id'])
return volume
def _create_loginable_secgroup_rule(self, secgroup_id=None):
@ -416,19 +416,19 @@ class ScenarioTest(tempest.test.BaseTestCase):
def nova_volume_attach(self):
# TODO(andreaf) Device should be here CONF.compute.volume_device_name
_, volume = self.servers_client.attach_volume(
self.server['id'], self.volume['id'], '/dev/vdb')
volume = self.servers_client.attach_volume(
self.server['id'], self.volume['id'], '/dev/vdb')[1]
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.get_volume(volume['id'])
self.volume = self.volumes_client.get_volume(volume['id'])
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.get_volume(self.volume['id'])
volume = self.volumes_client.get_volume(self.volume['id'])
self.assertEqual('available', volume['status'])
def rebuild_server(self, server_id, image=None,
@ -1216,7 +1216,7 @@ class EncryptionScenarioTest(ScenarioTest):
name = 'generic'
randomized_name = data_utils.rand_name('scenario-type-' + name + '-')
LOG.debug("Creating a volume type: %s", randomized_name)
_, body = client.create_volume_type(
body = client.create_volume_type(
randomized_name)
self.assertIn('id', body)
self.addCleanup(client.delete_volume_type, body['id'])

View File

@ -68,21 +68,21 @@ 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()
self.assertIn(self.volume['id'], [x['id'] for x in volumes])
def cinder_show(self):
_, volume = self.volumes_client.get_volume(self.volume['id'])
volume = self.volumes_client.get_volume(self.volume['id'])
self.assertEqual(self.volume, volume)
def nova_volume_attach(self):
volume_device_path = '/dev/' + CONF.compute.volume_device_name
_, volume = self.servers_client.attach_volume(
self.server['id'], self.volume['id'], volume_device_path)
volume = self.servers_client.attach_volume(
self.server['id'], self.volume['id'], volume_device_path)[1]
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.get_volume(volume['id'])
self.volume = self.volumes_client.get_volume(volume['id'])
def nova_reboot(self):
self.servers_client.reboot(self.server['id'], 'SOFT')
@ -98,7 +98,7 @@ class TestMinimumBasicScenario(manager.ScenarioTest):
self.volumes_client.wait_for_volume_status(self.volume['id'],
'available')
_, volume = self.volumes_client.get_volume(self.volume['id'])
volume = self.volumes_client.get_volume(self.volume['id'])
self.assertEqual('available', volume['status'])
def create_and_add_security_group(self):

View File

@ -16,6 +16,7 @@
import json
import urllib
from tempest.common import service_client
from tempest.services.volume.json import base
@ -34,7 +35,7 @@ class BaseVolumeHostsClientJSON(base.VolumeClient):
resp, body = self.get(url)
body = json.loads(body)
self.expected_success(200, resp.status)
return resp, body['hosts']
return service_client.ResponseBodyList(resp, body['hosts'])
class VolumeHostsClientJSON(BaseVolumeHostsClientJSON):

View File

@ -16,6 +16,7 @@
import urllib
from tempest.common import service_client
from tempest.openstack.common import jsonutils
from tempest.services.volume.json import base
@ -33,7 +34,7 @@ class BaseVolumeQuotasClientJSON(base.VolumeClient):
url = 'os-quota-sets/%s/defaults' % tenant_id
resp, body = self.get(url)
self.expected_success(200, resp.status)
return resp, self._parse_resp(body)
return service_client.ResponseBody(resp, self._parse_resp(body))
def get_quota_set(self, tenant_id, params=None):
"""List the quota set for a tenant."""
@ -44,14 +45,13 @@ class BaseVolumeQuotasClientJSON(base.VolumeClient):
resp, body = self.get(url)
self.expected_success(200, resp.status)
return resp, self._parse_resp(body)
return service_client.ResponseBody(resp, self._parse_resp(body))
def get_quota_usage(self, tenant_id):
"""List the quota set for a tenant."""
resp, body = self.get_quota_set(tenant_id, params={'usage': True})
self.expected_success(200, resp.status)
return resp, body
body = self.get_quota_set(tenant_id, params={'usage': True})
return body
def update_quota_set(self, tenant_id, gigabytes=None, volumes=None,
snapshots=None):
@ -69,7 +69,7 @@ class BaseVolumeQuotasClientJSON(base.VolumeClient):
post_body = jsonutils.dumps({'quota_set': post_body})
resp, body = self.put('os-quota-sets/%s' % tenant_id, post_body)
self.expected_success(200, resp.status)
return resp, self._parse_resp(body)
return service_client.ResponseBody(resp, self._parse_resp(body))
def delete_quota_set(self, tenant_id):
"""Delete the tenant's quota set."""

View File

@ -16,6 +16,7 @@
import json
import urllib
from tempest.common import service_client
from tempest.services.volume.json import base
@ -29,7 +30,7 @@ class BaseVolumesServicesClientJSON(base.VolumeClient):
resp, body = self.get(url)
body = json.loads(body)
self.expected_success(200, resp.status)
return resp, body['services']
return service_client.ResponseBodyList(resp, body['services'])
class VolumesServicesClientJSON(BaseVolumesServicesClientJSON):

View File

@ -16,6 +16,7 @@
import json
import urllib
from tempest.common import service_client
from tempest import exceptions
from tempest.services.volume.json import base
@ -34,8 +35,7 @@ class BaseVolumeTypesClientJSON(base.VolumeClient):
if resource['type'] == "volume-type":
self.get_volume_type(resource['id'])
elif resource['type'] == "encryption-type":
resp, body = self.get_encryption_type(resource['id'])
assert 200 == resp.status
body = self.get_encryption_type(resource['id'])
if not body:
return True
else:
@ -59,7 +59,7 @@ class BaseVolumeTypesClientJSON(base.VolumeClient):
resp, body = self.get(url)
body = json.loads(body)
self.expected_success(200, resp.status)
return resp, body['volume_types']
return service_client.ResponseBodyList(resp, body['volume_types'])
def get_volume_type(self, volume_id):
"""Returns the details of a single volume_type."""
@ -67,7 +67,7 @@ class BaseVolumeTypesClientJSON(base.VolumeClient):
resp, body = self.get(url)
body = json.loads(body)
self.expected_success(200, resp.status)
return resp, body['volume_type']
return service_client.ResponseBody(resp, body['volume_type'])
def create_volume_type(self, name, **kwargs):
"""
@ -85,7 +85,7 @@ class BaseVolumeTypesClientJSON(base.VolumeClient):
resp, body = self.post('types', post_body)
body = json.loads(body)
self.expected_success(200, resp.status)
return resp, body['volume_type']
return service_client.ResponseBody(resp, body['volume_type'])
def delete_volume_type(self, volume_id):
"""Deletes the Specified Volume_type."""
@ -101,7 +101,7 @@ class BaseVolumeTypesClientJSON(base.VolumeClient):
resp, body = self.get(url)
body = json.loads(body)
self.expected_success(200, resp.status)
return resp, body['extra_specs']
return service_client.ResponseBody(resp, body['extra_specs'])
def get_volume_type_extra_specs(self, vol_type_id, extra_spec_name):
"""Returns the details of a single volume_type extra spec."""
@ -110,7 +110,7 @@ class BaseVolumeTypesClientJSON(base.VolumeClient):
resp, body = self.get(url)
body = json.loads(body)
self.expected_success(200, resp.status)
return resp, body
return service_client.ResponseBody(resp, body)
def create_volume_type_extra_specs(self, vol_type_id, extra_spec):
"""
@ -123,7 +123,7 @@ class BaseVolumeTypesClientJSON(base.VolumeClient):
resp, body = self.post(url, post_body)
body = json.loads(body)
self.expected_success(200, resp.status)
return resp, body['extra_specs']
return service_client.ResponseBody(resp, body['extra_specs'])
def delete_volume_type_extra_specs(self, vol_id, extra_spec_name):
"""Deletes the Specified Volume_type extra spec."""
@ -146,7 +146,7 @@ class BaseVolumeTypesClientJSON(base.VolumeClient):
resp, body = self.put(url, put_body)
body = json.loads(body)
self.expected_success(200, resp.status)
return resp, body
return service_client.ResponseBody(resp, body)
def get_encryption_type(self, vol_type_id):
"""
@ -157,7 +157,7 @@ class BaseVolumeTypesClientJSON(base.VolumeClient):
resp, body = self.get(url)
body = json.loads(body)
self.expected_success(200, resp.status)
return resp, body
return service_client.ResponseBody(resp, body)
def create_encryption_type(self, vol_type_id, **kwargs):
"""
@ -176,7 +176,7 @@ class BaseVolumeTypesClientJSON(base.VolumeClient):
resp, body = self.post(url, post_body)
body = json.loads(body)
self.expected_success(200, resp.status)
return resp, body['encryption']
return service_client.ResponseBody(resp, body['encryption'])
def delete_encryption_type(self, vol_type_id):
"""Delete the encryption type for the specified volume-type."""

View File

@ -15,6 +15,7 @@
import json
from tempest.common import service_client
from tempest.services.volume.json import base
@ -24,7 +25,7 @@ class BaseVolumeAvailabilityZoneClientJSON(base.VolumeClient):
resp, body = self.get('os-availability-zone')
body = json.loads(body)
self.expected_success(200, resp.status)
return resp, body['availabilityZoneInfo']
return service_client.ResponseBody(resp, body['availabilityZoneInfo'])
class VolumeAvailabilityZoneClientJSON(BaseVolumeAvailabilityZoneClientJSON):

View File

@ -16,6 +16,7 @@
import json
import time
from tempest.common import service_client
from tempest import exceptions
from tempest.services.volume.json import base
@ -39,7 +40,7 @@ class BaseBackupsClientJSON(base.VolumeClient):
resp, body = self.post('backups', post_body)
body = json.loads(body)
self.expected_success(202, resp.status)
return resp, body['backup']
return service_client.ResponseBody(resp, body['backup'])
def restore_backup(self, backup_id, volume_id=None):
"""Restore volume from backup."""
@ -48,13 +49,13 @@ class BaseBackupsClientJSON(base.VolumeClient):
resp, body = self.post('backups/%s/restore' % (backup_id), post_body)
body = json.loads(body)
self.expected_success(202, resp.status)
return resp, body['restore']
return service_client.ResponseBody(resp, body['restore'])
def delete_backup(self, backup_id):
"""Delete a backup of volume."""
resp, body = self.delete('backups/%s' % (str(backup_id)))
self.expected_success(202, resp.status)
return resp, body
return service_client.ResponseBody(resp, body)
def get_backup(self, backup_id):
"""Returns the details of a single backup."""
@ -62,7 +63,7 @@ class BaseBackupsClientJSON(base.VolumeClient):
resp, body = self.get(url)
body = json.loads(body)
self.expected_success(200, resp.status)
return resp, body['backup']
return service_client.ResponseBody(resp, body['backup'])
def list_backups_with_detail(self):
"""Information for all the tenant's backups."""
@ -70,17 +71,17 @@ class BaseBackupsClientJSON(base.VolumeClient):
resp, body = self.get(url)
body = json.loads(body)
self.expected_success(200, resp.status)
return resp, body['backups']
return service_client.ResponseBodyList(resp, body['backups'])
def wait_for_backup_status(self, backup_id, status):
"""Waits for a Backup to reach a given status."""
resp, body = self.get_backup(backup_id)
body = self.get_backup(backup_id)
backup_status = body['status']
start = int(time.time())
while backup_status != status:
time.sleep(self.build_interval)
resp, body = self.get_backup(backup_id)
body = self.get_backup(backup_id)
backup_status = body['status']
if backup_status == 'error':
raise exceptions.VolumeBackupException(backup_id=backup_id)

View File

@ -15,6 +15,7 @@
import json
from tempest.common import service_client
from tempest.services.volume.json import base
@ -25,7 +26,7 @@ class BaseExtensionsClientJSON(base.VolumeClient):
resp, body = self.get(url)
body = json.loads(body)
self.expected_success(200, resp.status)
return resp, body['extensions']
return service_client.ResponseBodyList(resp, body['extensions'])
class ExtensionsClientJSON(BaseExtensionsClientJSON):

View File

@ -15,6 +15,7 @@
import json
import time
from tempest.common import service_client
from tempest import exceptions
from tempest.services.volume.json import base
@ -46,18 +47,15 @@ class BaseQosSpecsClientJSON(base.VolumeClient):
start_time = int(time.time())
while True:
if operation == 'qos-key-unset':
resp, body = self.get_qos(qos_id)
self.expected_success(200, resp.status)
body = self.get_qos(qos_id)
if not any(key in body['specs'] for key in args):
return
elif operation == 'disassociate':
resp, body = self.get_association_qos(qos_id)
self.expected_success(200, resp.status)
body = self.get_association_qos(qos_id)
if not any(args in body[i]['id'] for i in range(0, len(body))):
return
elif operation == 'disassociate-all':
resp, body = self.get_association_qos(qos_id)
self.expected_success(200, resp.status)
body = self.get_association_qos(qos_id)
if not body:
return
else:
@ -80,7 +78,7 @@ class BaseQosSpecsClientJSON(base.VolumeClient):
resp, body = self.post('qos-specs', post_body)
self.expected_success(200, resp.status)
body = json.loads(body)
return resp, body['qos_specs']
return service_client.ResponseBody(resp, body['qos_specs'])
def delete_qos(self, qos_id, force=False):
"""Delete the specified QoS specification."""
@ -94,7 +92,7 @@ class BaseQosSpecsClientJSON(base.VolumeClient):
resp, body = self.get(url)
body = json.loads(body)
self.expected_success(200, resp.status)
return resp, body['qos_specs']
return service_client.ResponseBodyList(resp, body['qos_specs'])
def get_qos(self, qos_id):
"""Get the specified QoS specification."""
@ -102,7 +100,7 @@ class BaseQosSpecsClientJSON(base.VolumeClient):
resp, body = self.get(url)
body = json.loads(body)
self.expected_success(200, resp.status)
return resp, body['qos_specs']
return service_client.ResponseBody(resp, body['qos_specs'])
def set_qos_key(self, qos_id, **kwargs):
"""Set the specified keys/values of QoS specification.
@ -113,7 +111,7 @@ class BaseQosSpecsClientJSON(base.VolumeClient):
resp, body = self.put('qos-specs/%s' % qos_id, put_body)
body = json.loads(body)
self.expected_success(200, resp.status)
return resp, body['qos_specs']
return service_client.ResponseBody(resp, body['qos_specs'])
def unset_qos_key(self, qos_id, keys):
"""Unset the specified keys of QoS specification.
@ -137,7 +135,7 @@ class BaseQosSpecsClientJSON(base.VolumeClient):
resp, body = self.get(url)
body = json.loads(body)
self.expected_success(200, resp.status)
return resp, body['qos_associations']
return service_client.ResponseBodyList(resp, body['qos_associations'])
def disassociate_qos(self, qos_id, vol_type_id):
"""Disassociate the specified QoS with specified volume-type."""

View File

@ -14,6 +14,7 @@ import json
import time
import urllib
from tempest.common import service_client
from tempest import exceptions
from tempest.openstack.common import log as logging
from tempest.services.volume.json import base
@ -36,7 +37,7 @@ class BaseSnapshotsClientJSON(base.VolumeClient):
resp, body = self.get(url)
body = json.loads(body)
self.expected_success(200, resp.status)
return resp, body['snapshots']
return service_client.ResponseBodyList(resp, body['snapshots'])
def list_snapshots_with_detail(self, params=None):
"""List the details of all snapshots."""
@ -47,7 +48,7 @@ class BaseSnapshotsClientJSON(base.VolumeClient):
resp, body = self.get(url)
body = json.loads(body)
self.expected_success(200, resp.status)
return resp, body['snapshots']
return service_client.ResponseBodyList(resp, body['snapshots'])
def get_snapshot(self, snapshot_id):
"""Returns the details of a single snapshot."""
@ -55,7 +56,7 @@ class BaseSnapshotsClientJSON(base.VolumeClient):
resp, body = self.get(url)
body = json.loads(body)
self.expected_success(200, resp.status)
return resp, body['snapshot']
return service_client.ResponseBody(resp, body['snapshot'])
def create_snapshot(self, volume_id, **kwargs):
"""
@ -71,7 +72,7 @@ class BaseSnapshotsClientJSON(base.VolumeClient):
resp, body = self.post('snapshots', post_body)
body = json.loads(body)
self.expected_success(self.create_resp, resp.status)
return resp, body['snapshot']
return service_client.ResponseBody(resp, body['snapshot'])
def update_snapshot(self, snapshot_id, **kwargs):
"""Updates a snapshot."""
@ -79,11 +80,11 @@ class BaseSnapshotsClientJSON(base.VolumeClient):
resp, body = self.put('snapshots/%s' % snapshot_id, put_body)
body = json.loads(body)
self.expected_success(200, resp.status)
return resp, body['snapshot']
return service_client.ResponseBody(resp, body['snapshot'])
# NOTE(afazekas): just for the wait function
def _get_snapshot_status(self, snapshot_id):
resp, body = self.get_snapshot(snapshot_id)
body = self.get_snapshot(snapshot_id)
status = body['status']
# NOTE(afazekas): snapshot can reach an "error"
# state in a "normal" lifecycle
@ -140,7 +141,7 @@ class BaseSnapshotsClientJSON(base.VolumeClient):
post_body = json.dumps({'os-reset_status': {"status": status}})
resp, body = self.post('snapshots/%s/action' % snapshot_id, post_body)
self.expected_success(202, resp.status)
return resp, body
return service_client.ResponseBody(resp, body)
def update_snapshot_status(self, snapshot_id, status, progress):
"""Update the specified snapshot's status."""
@ -152,7 +153,7 @@ class BaseSnapshotsClientJSON(base.VolumeClient):
url = 'snapshots/%s/action' % str(snapshot_id)
resp, body = self.post(url, post_body)
self.expected_success(202, resp.status)
return resp, body
return service_client.ResponseBody(resp, body)
def create_snapshot_metadata(self, snapshot_id, metadata):
"""Create metadata for the snapshot."""
@ -161,7 +162,7 @@ class BaseSnapshotsClientJSON(base.VolumeClient):
resp, body = self.post(url, put_body)
body = json.loads(body)
self.expected_success(200, resp.status)
return resp, body['metadata']
return service_client.ResponseBody(resp, body['metadata'])
def get_snapshot_metadata(self, snapshot_id):
"""Get metadata of the snapshot."""
@ -169,7 +170,7 @@ class BaseSnapshotsClientJSON(base.VolumeClient):
resp, body = self.get(url)
body = json.loads(body)
self.expected_success(200, resp.status)
return resp, body['metadata']
return service_client.ResponseBody(resp, body['metadata'])
def update_snapshot_metadata(self, snapshot_id, metadata):
"""Update metadata for the snapshot."""
@ -178,7 +179,7 @@ class BaseSnapshotsClientJSON(base.VolumeClient):
resp, body = self.put(url, put_body)
body = json.loads(body)
self.expected_success(200, resp.status)
return resp, body['metadata']
return service_client.ResponseBody(resp, body['metadata'])
def update_snapshot_metadata_item(self, snapshot_id, id, meta_item):
"""Update metadata item for the snapshot."""
@ -187,7 +188,7 @@ class BaseSnapshotsClientJSON(base.VolumeClient):
resp, body = self.put(url, put_body)
body = json.loads(body)
self.expected_success(200, resp.status)
return resp, body['meta']
return service_client.ResponseBody(resp, body['meta'])
def delete_snapshot_metadata_item(self, snapshot_id, id):
"""Delete metadata item for the snapshot."""
@ -200,7 +201,7 @@ class BaseSnapshotsClientJSON(base.VolumeClient):
post_body = json.dumps({'os-force_delete': {}})
resp, body = self.post('snapshots/%s/action' % snapshot_id, post_body)
self.expected_success(202, resp.status)
return resp, body
return service_client.ResponseBody(resp, body)
class SnapshotsClientJSON(BaseSnapshotsClientJSON):

View File

@ -17,6 +17,7 @@ import json
import time
import urllib
from tempest.common import service_client
from tempest import config
from tempest import exceptions
from tempest.services.volume.json import base
@ -44,7 +45,7 @@ class BaseVolumesClientJSON(base.VolumeClient):
resp, body = self.get(url)
body = json.loads(body)
self.expected_success(200, resp.status)
return resp, body['volumes']
return service_client.ResponseBodyList(resp, body['volumes'])
def list_volumes_with_detail(self, params=None):
"""List the details of all volumes."""
@ -55,7 +56,7 @@ class BaseVolumesClientJSON(base.VolumeClient):
resp, body = self.get(url)
body = json.loads(body)
self.expected_success(200, resp.status)
return resp, body['volumes']
return service_client.ResponseBodyList(resp, body['volumes'])
def get_volume(self, volume_id):
"""Returns the details of a single volume."""
@ -63,7 +64,7 @@ class BaseVolumesClientJSON(base.VolumeClient):
resp, body = self.get(url)
body = json.loads(body)
self.expected_success(200, resp.status)
return resp, body['volume']
return service_client.ResponseBody(resp, body['volume'])
def create_volume(self, size=None, **kwargs):
"""
@ -87,7 +88,7 @@ class BaseVolumesClientJSON(base.VolumeClient):
resp, body = self.post('volumes', post_body)
body = json.loads(body)
self.expected_success(self.create_resp, resp.status)
return resp, body['volume']
return service_client.ResponseBody(resp, body['volume'])
def update_volume(self, volume_id, **kwargs):
"""Updates the Specified Volume."""
@ -95,7 +96,7 @@ class BaseVolumesClientJSON(base.VolumeClient):
resp, body = self.put('volumes/%s' % volume_id, put_body)
body = json.loads(body)
self.expected_success(200, resp.status)
return resp, body['volume']
return service_client.ResponseBody(resp, body['volume'])
def delete_volume(self, volume_id):
"""Deletes the Specified Volume."""
@ -113,7 +114,8 @@ class BaseVolumesClientJSON(base.VolumeClient):
resp, body = self.post(url, post_body)
body = json.loads(body)
self.expected_success(202, resp.status)
return resp, body['os-volume_upload_image']
return service_client.ResponseBody(resp,
body['os-volume_upload_image'])
def attach_volume(self, volume_id, instance_uuid, mountpoint):
"""Attaches a volume to a given instance on a given mountpoint."""
@ -125,7 +127,7 @@ class BaseVolumesClientJSON(base.VolumeClient):
url = 'volumes/%s/action' % (volume_id)
resp, body = self.post(url, post_body)
self.expected_success(202, resp.status)
return resp, body
return service_client.ResponseBody(resp, body)
def detach_volume(self, volume_id):
"""Detaches a volume from an instance."""
@ -134,7 +136,7 @@ class BaseVolumesClientJSON(base.VolumeClient):
url = 'volumes/%s/action' % (volume_id)
resp, body = self.post(url, post_body)
self.expected_success(202, resp.status)
return resp, body
return service_client.ResponseBody(resp, body)
def reserve_volume(self, volume_id):
"""Reserves a volume."""
@ -143,7 +145,7 @@ class BaseVolumesClientJSON(base.VolumeClient):
url = 'volumes/%s/action' % (volume_id)
resp, body = self.post(url, post_body)
self.expected_success(202, resp.status)
return resp, body
return service_client.ResponseBody(resp, body)
def unreserve_volume(self, volume_id):
"""Restore a reserved volume ."""
@ -152,17 +154,17 @@ class BaseVolumesClientJSON(base.VolumeClient):
url = 'volumes/%s/action' % (volume_id)
resp, body = self.post(url, post_body)
self.expected_success(202, resp.status)
return resp, body
return service_client.ResponseBody(resp, body)
def wait_for_volume_status(self, volume_id, status):
"""Waits for a Volume to reach a given status."""
resp, body = self.get_volume(volume_id)
body = self.get_volume(volume_id)
volume_status = body['status']
start = int(time.time())
while volume_status != status:
time.sleep(self.build_interval)
resp, body = self.get_volume(volume_id)
body = self.get_volume(volume_id)
volume_status = body['status']
if volume_status == 'error':
raise exceptions.VolumeBuildErrorException(volume_id=volume_id)
@ -197,14 +199,14 @@ class BaseVolumesClientJSON(base.VolumeClient):
url = 'volumes/%s/action' % (volume_id)
resp, body = self.post(url, post_body)
self.expected_success(202, resp.status)
return resp, body
return service_client.ResponseBody(resp, body)
def reset_volume_status(self, volume_id, status):
"""Reset the Specified Volume's Status."""
post_body = json.dumps({'os-reset_status': {"status": status}})
resp, body = self.post('volumes/%s/action' % volume_id, post_body)
self.expected_success(202, resp.status)
return resp, body
return service_client.ResponseBody(resp, body)
def volume_begin_detaching(self, volume_id):
"""Volume Begin Detaching."""
@ -212,7 +214,7 @@ class BaseVolumesClientJSON(base.VolumeClient):
post_body = json.dumps({'os-begin_detaching': {}})
resp, body = self.post('volumes/%s/action' % volume_id, post_body)
self.expected_success(202, resp.status)
return resp, body
return service_client.ResponseBody(resp, body)
def volume_roll_detaching(self, volume_id):
"""Volume Roll Detaching."""
@ -220,7 +222,7 @@ class BaseVolumesClientJSON(base.VolumeClient):
post_body = json.dumps({'os-roll_detaching': {}})
resp, body = self.post('volumes/%s/action' % volume_id, post_body)
self.expected_success(202, resp.status)
return resp, body
return service_client.ResponseBody(resp, body)
def create_volume_transfer(self, vol_id, display_name=None):
"""Create a volume transfer."""
@ -233,7 +235,7 @@ class BaseVolumesClientJSON(base.VolumeClient):
resp, body = self.post('os-volume-transfer', post_body)
body = json.loads(body)
self.expected_success(202, resp.status)
return resp, body['transfer']
return service_client.ResponseBody(resp, body['transfer'])
def get_volume_transfer(self, transfer_id):
"""Returns the details of a volume transfer."""
@ -241,7 +243,7 @@ class BaseVolumesClientJSON(base.VolumeClient):
resp, body = self.get(url)
body = json.loads(body)
self.expected_success(200, resp.status)
return resp, body['transfer']
return service_client.ResponseBody(resp, body['transfer'])
def list_volume_transfers(self, params=None):
"""List all the volume transfers created."""
@ -251,7 +253,7 @@ class BaseVolumesClientJSON(base.VolumeClient):
resp, body = self.get(url)
body = json.loads(body)
self.expected_success(200, resp.status)
return resp, body['transfers']
return service_client.ResponseBodyList(resp, body['transfers'])
def delete_volume_transfer(self, transfer_id):
"""Delete a volume transfer."""
@ -268,7 +270,7 @@ class BaseVolumesClientJSON(base.VolumeClient):
resp, body = self.post(url, post_body)
body = json.loads(body)
self.expected_success(202, resp.status)
return resp, body['transfer']
return service_client.ResponseBody(resp, body['transfer'])
def update_volume_readonly(self, volume_id, readonly):
"""Update the Specified Volume readonly."""
@ -279,14 +281,14 @@ class BaseVolumesClientJSON(base.VolumeClient):
url = 'volumes/%s/action' % (volume_id)
resp, body = self.post(url, post_body)
self.expected_success(202, resp.status)
return resp, body
return service_client.ResponseBody(resp, body)
def force_delete_volume(self, volume_id):
"""Force Delete Volume."""
post_body = json.dumps({'os-force_delete': {}})
resp, body = self.post('volumes/%s/action' % volume_id, post_body)
self.expected_success(202, resp.status)
return resp, body
return service_client.ResponseBody(resp, body)
def create_volume_metadata(self, volume_id, metadata):
"""Create metadata for the volume."""
@ -295,7 +297,7 @@ class BaseVolumesClientJSON(base.VolumeClient):
resp, body = self.post(url, put_body)
body = json.loads(body)
self.expected_success(200, resp.status)
return resp, body['metadata']
return service_client.ResponseBody(resp, body['metadata'])
def get_volume_metadata(self, volume_id):
"""Get metadata of the volume."""
@ -303,7 +305,7 @@ class BaseVolumesClientJSON(base.VolumeClient):
resp, body = self.get(url)
body = json.loads(body)
self.expected_success(200, resp.status)
return resp, body['metadata']
return service_client.ResponseBody(resp, body['metadata'])
def update_volume_metadata(self, volume_id, metadata):
"""Update metadata for the volume."""
@ -312,7 +314,7 @@ class BaseVolumesClientJSON(base.VolumeClient):
resp, body = self.put(url, put_body)
body = json.loads(body)
self.expected_success(200, resp.status)
return resp, body['metadata']
return service_client.ResponseBody(resp, body['metadata'])
def update_volume_metadata_item(self, volume_id, id, meta_item):
"""Update metadata item for the volume."""
@ -321,7 +323,7 @@ class BaseVolumesClientJSON(base.VolumeClient):
resp, body = self.put(url, put_body)
body = json.loads(body)
self.expected_success(200, resp.status)
return resp, body['meta']
return service_client.ResponseBody(resp, body['meta'])
def delete_volume_metadata_item(self, volume_id, id):
"""Delete metadata item for the volume."""

View File

@ -243,9 +243,9 @@ class TestDiscovery(base.TestCase):
def test_verify_extensions_cinder(self):
def fake_list_extensions():
return (None, {'extensions': [{'alias': 'fake1'},
{'alias': 'fake2'},
{'alias': 'not_fake'}]})
return {'extensions': [{'alias': 'fake1'},
{'alias': 'fake2'},
{'alias': 'not_fake'}]}
fake_os = mock.MagicMock()
fake_os.volumes_extension_client.list_extensions = fake_list_extensions
self.useFixture(mockpatch.PatchObject(
@ -265,9 +265,9 @@ class TestDiscovery(base.TestCase):
def test_verify_extensions_cinder_all(self):
def fake_list_extensions():
return (None, {'extensions': [{'alias': 'fake1'},
{'alias': 'fake2'},
{'alias': 'not_fake'}]})
return {'extensions': [{'alias': 'fake1'},
{'alias': 'fake2'},
{'alias': 'not_fake'}]}
fake_os = mock.MagicMock()
fake_os.volumes_extension_client.list_extensions = fake_list_extensions
self.useFixture(mockpatch.PatchObject(