Fix volume backup restore response
Previously the backup restore response only included ``id`` whereas the restore API returns ``backup_id``, ``volume_id`` and ``volume_name`` fields. Turns out the resource_response_key was missing in the translate response method and the has_body parameter was set to False indicating that the response doesn't return a body which is not true. This patch fixes the above stated issues. Story: 2011235 Task: 51137 Change-Id: Id5c7fd2f0fcb55474b44b688bfdebaca4c670bd2
This commit is contained in:
parent
c2470a21de
commit
a9ad50640f
@ -86,6 +86,8 @@ class Backup(resource.Resource):
|
||||
updated_at = resource.Body("updated_at")
|
||||
#: The UUID of the volume.
|
||||
volume_id = resource.Body("volume_id")
|
||||
#: The name of the volume.
|
||||
volume_name = resource.Body("volume_name")
|
||||
|
||||
def create(self, session, prepend_key=True, base_path=None, **params):
|
||||
"""Create a remote resource based on this instance.
|
||||
@ -186,7 +188,7 @@ class Backup(resource.Resource):
|
||||
'Either of `name` or `volume_id` must be specified.'
|
||||
)
|
||||
response = session.post(url, json=body)
|
||||
self._translate_response(response, has_body=False)
|
||||
self._translate_response(response, resource_response_key='restore')
|
||||
return self
|
||||
|
||||
def force_delete(self, session):
|
||||
|
@ -100,6 +100,8 @@ class Backup(resource.Resource):
|
||||
user_id = resource.Body('user_id')
|
||||
#: The UUID of the volume.
|
||||
volume_id = resource.Body("volume_id")
|
||||
#: The name of the volume.
|
||||
volume_name = resource.Body("volume_name")
|
||||
|
||||
_max_microversion = "3.64"
|
||||
|
||||
@ -202,7 +204,7 @@ class Backup(resource.Resource):
|
||||
'Either of `name` or `volume_id` must be specified.'
|
||||
)
|
||||
response = session.post(url, json=body)
|
||||
self._translate_response(response, has_body=False)
|
||||
self._translate_response(response, resource_response_key='restore')
|
||||
return self
|
||||
|
||||
def force_delete(self, session):
|
||||
|
@ -137,6 +137,18 @@ class TestBackup(base.TestCase):
|
||||
def test_restore(self):
|
||||
sot = backup.Backup(**BACKUP)
|
||||
|
||||
restore_response = mock.Mock()
|
||||
restore_response.status_code = 202
|
||||
restore_response.json.return_value = {
|
||||
"restore": {
|
||||
"backup_id": "back",
|
||||
"volume_id": "vol",
|
||||
"volume_name": "name",
|
||||
}
|
||||
}
|
||||
restore_response.headers = {}
|
||||
self.sess.post.return_value = restore_response
|
||||
|
||||
self.assertEqual(sot, sot.restore(self.sess, 'vol', 'name'))
|
||||
|
||||
url = 'backups/%s/restore' % FAKE_ID
|
||||
@ -146,6 +158,18 @@ class TestBackup(base.TestCase):
|
||||
def test_restore_name(self):
|
||||
sot = backup.Backup(**BACKUP)
|
||||
|
||||
restore_response = mock.Mock()
|
||||
restore_response.status_code = 202
|
||||
restore_response.json.return_value = {
|
||||
"restore": {
|
||||
"backup_id": "back",
|
||||
"volume_id": "vol",
|
||||
"volume_name": "name",
|
||||
}
|
||||
}
|
||||
restore_response.headers = {}
|
||||
self.sess.post.return_value = restore_response
|
||||
|
||||
self.assertEqual(sot, sot.restore(self.sess, name='name'))
|
||||
|
||||
url = 'backups/%s/restore' % FAKE_ID
|
||||
@ -155,6 +179,18 @@ class TestBackup(base.TestCase):
|
||||
def test_restore_vol_id(self):
|
||||
sot = backup.Backup(**BACKUP)
|
||||
|
||||
restore_response = mock.Mock()
|
||||
restore_response.status_code = 202
|
||||
restore_response.json.return_value = {
|
||||
"restore": {
|
||||
"backup_id": "back",
|
||||
"volume_id": "vol",
|
||||
"volume_name": "name",
|
||||
}
|
||||
}
|
||||
restore_response.headers = {}
|
||||
self.sess.post.return_value = restore_response
|
||||
|
||||
self.assertEqual(sot, sot.restore(self.sess, volume_id='vol'))
|
||||
|
||||
url = 'backups/%s/restore' % FAKE_ID
|
||||
|
@ -150,6 +150,18 @@ class TestBackup(base.TestCase):
|
||||
def test_restore(self):
|
||||
sot = backup.Backup(**BACKUP)
|
||||
|
||||
restore_response = mock.Mock()
|
||||
restore_response.status_code = 202
|
||||
restore_response.json.return_value = {
|
||||
"restore": {
|
||||
"backup_id": "back",
|
||||
"volume_id": "vol",
|
||||
"volume_name": "name",
|
||||
}
|
||||
}
|
||||
restore_response.headers = {}
|
||||
self.sess.post.return_value = restore_response
|
||||
|
||||
self.assertEqual(sot, sot.restore(self.sess, 'vol', 'name'))
|
||||
|
||||
url = 'backups/%s/restore' % FAKE_ID
|
||||
@ -159,6 +171,18 @@ class TestBackup(base.TestCase):
|
||||
def test_restore_name(self):
|
||||
sot = backup.Backup(**BACKUP)
|
||||
|
||||
restore_response = mock.Mock()
|
||||
restore_response.status_code = 202
|
||||
restore_response.json.return_value = {
|
||||
"restore": {
|
||||
"backup_id": "back",
|
||||
"volume_id": "vol",
|
||||
"volume_name": "name",
|
||||
}
|
||||
}
|
||||
restore_response.headers = {}
|
||||
self.sess.post.return_value = restore_response
|
||||
|
||||
self.assertEqual(sot, sot.restore(self.sess, name='name'))
|
||||
|
||||
url = 'backups/%s/restore' % FAKE_ID
|
||||
@ -168,6 +192,18 @@ class TestBackup(base.TestCase):
|
||||
def test_restore_vol_id(self):
|
||||
sot = backup.Backup(**BACKUP)
|
||||
|
||||
restore_response = mock.Mock()
|
||||
restore_response.status_code = 202
|
||||
restore_response.json.return_value = {
|
||||
"restore": {
|
||||
"backup_id": "back",
|
||||
"volume_id": "vol",
|
||||
"volume_name": "name",
|
||||
}
|
||||
}
|
||||
restore_response.headers = {}
|
||||
self.sess.post.return_value = restore_response
|
||||
|
||||
self.assertEqual(sot, sot.restore(self.sess, volume_id='vol'))
|
||||
|
||||
url = 'backups/%s/restore' % FAKE_ID
|
||||
|
@ -0,0 +1,6 @@
|
||||
---
|
||||
fixes:
|
||||
- |
|
||||
Previously the volume backup restore response only
|
||||
returned ``id`` and now it also returns ``volume_id``
|
||||
and ``volume_name`` fields.
|
Loading…
Reference in New Issue
Block a user