Merge "Full response for Volume BackupsClient methods"
diff --git a/tempest/api/volume/admin/test_volumes_backup.py b/tempest/api/volume/admin/test_volumes_backup.py
index 8015c35..86fa668 100644
--- a/tempest/api/volume/admin/test_volumes_backup.py
+++ b/tempest/api/volume/admin/test_volumes_backup.py
@@ -48,7 +48,7 @@
backup_name = data_utils.rand_name('Backup')
create_backup = self.backups_adm_client.create_backup
backup = create_backup(self.volume['id'],
- name=backup_name)
+ name=backup_name)['backup']
self.addCleanup(self.backups_adm_client.delete_backup,
backup['id'])
self.assertEqual(backup_name, backup['name'])
@@ -58,16 +58,17 @@
'available')
# Get a given backup
- backup = self.backups_adm_client.show_backup(backup['id'])
+ backup = self.backups_adm_client.show_backup(backup['id'])['backup']
self.assertEqual(backup_name, backup['name'])
# Get all backups with detail
- backups = self.backups_adm_client.list_backups(detail=True)
+ backups = self.backups_adm_client.list_backups(detail=True)['backups']
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'])['restore']
# Delete backup
self.addCleanup(self.admin_volume_client.delete_volume,
@@ -82,15 +83,17 @@
def test_volume_backup_export_import(self):
# Create backup
backup_name = data_utils.rand_name('Backup')
- backup = self.backups_adm_client.create_backup(self.volume['id'],
- name=backup_name)
+ backup = (self.backups_adm_client.create_backup(self.volume['id'],
+ name=backup_name)
+ ['backup'])
self.addCleanup(self._delete_backup, backup['id'])
self.assertEqual(backup_name, backup['name'])
self.backups_adm_client.wait_for_backup_status(backup['id'],
'available')
# Export Backup
- export_backup = self.backups_adm_client.export_backup(backup['id'])
+ export_backup = (self.backups_adm_client.export_backup(backup['id'])
+ ['backup-record'])
self.assertIn('backup_service', export_backup)
self.assertIn('backup_url', export_backup)
self.assertTrue(export_backup['backup_service'].startswith(
@@ -100,18 +103,19 @@
# Import Backup
import_backup = self.backups_adm_client.import_backup(
backup_service=export_backup['backup_service'],
- backup_url=export_backup['backup_url'])
+ backup_url=export_backup['backup_url'])['backup']
self.addCleanup(self._delete_backup, import_backup['id'])
self.assertIn("id", import_backup)
self.backups_adm_client.wait_for_backup_status(import_backup['id'],
'available')
# Verify Import Backup
- backups = self.backups_adm_client.list_backups(detail=True)
+ backups = self.backups_adm_client.list_backups(detail=True)['backups']
self.assertIn(import_backup['id'], [b['id'] for b in backups])
# Restore backup
- restore = self.backups_adm_client.restore_backup(import_backup['id'])
+ restore = (self.backups_adm_client.restore_backup(import_backup['id'])
+ ['restore'])
self.addCleanup(self.admin_volume_client.delete_volume,
restore['volume_id'])
self.assertEqual(import_backup['id'], restore['backup_id'])
diff --git a/tempest/services/volume/json/backups_client.py b/tempest/services/volume/json/backups_client.py
index 8d34230..6827c93 100644
--- a/tempest/services/volume/json/backups_client.py
+++ b/tempest/services/volume/json/backups_client.py
@@ -42,7 +42,7 @@
resp, body = self.post('backups', post_body)
body = json.loads(body)
self.expected_success(202, resp.status)
- return service_client.ResponseBody(resp, body['backup'])
+ return service_client.ResponseBody(resp, body)
def restore_backup(self, backup_id, volume_id=None):
"""Restore volume from backup."""
@@ -51,7 +51,7 @@
resp, body = self.post('backups/%s/restore' % (backup_id), post_body)
body = json.loads(body)
self.expected_success(202, resp.status)
- return service_client.ResponseBody(resp, body['restore'])
+ return service_client.ResponseBody(resp, body)
def delete_backup(self, backup_id):
"""Delete a backup of volume."""
@@ -65,7 +65,7 @@
resp, body = self.get(url)
body = json.loads(body)
self.expected_success(200, resp.status)
- return service_client.ResponseBody(resp, body['backup'])
+ return service_client.ResponseBody(resp, body)
def list_backups(self, detail=False):
"""Information for all the tenant's backups."""
@@ -75,7 +75,7 @@
resp, body = self.get(url)
body = json.loads(body)
self.expected_success(200, resp.status)
- return service_client.ResponseBodyList(resp, body['backups'])
+ return service_client.ResponseBody(resp, body)
def export_backup(self, backup_id):
"""Export backup metadata record."""
@@ -83,7 +83,7 @@
resp, body = self.get(url)
body = json.loads(body)
self.expected_success(200, resp.status)
- return service_client.ResponseBody(resp, body['backup-record'])
+ return service_client.ResponseBody(resp, body)
def import_backup(self, backup_service, backup_url):
"""Import backup metadata record."""
@@ -93,17 +93,17 @@
resp, body = self.post("backups/import_record", post_body)
body = json.loads(body)
self.expected_success(201, resp.status)
- return service_client.ResponseBody(resp, body['backup'])
+ return service_client.ResponseBody(resp, body)
def wait_for_backup_status(self, backup_id, status):
"""Waits for a Backup to reach a given status."""
- body = self.show_backup(backup_id)
+ body = self.show_backup(backup_id)['backup']
backup_status = body['status']
start = int(time.time())
while backup_status != status:
time.sleep(self.build_interval)
- body = self.show_backup(backup_id)
+ body = self.show_backup(backup_id)['backup']
backup_status = body['status']
if backup_status == 'error':
raise exceptions.VolumeBackupException(backup_id=backup_id)