Fix attachment_id returned by create and show volume
The attachment_ids in the volume info returned by show volume were incorrect. It was showing the volume_id, not the actual attachment_id. This fix changes the attachment_ids returned by show volume to correctly reflect the attachment_id. Also, added a unit test for this, and added an attachment_id to the fake volume so that other tests wouldn't now fail. Closes-Bug: #1713082 Change-Id: I9ec36af5dd460d03d786aeeb3cc36a869c19ff62
This commit is contained in:
parent
e3e2f4d397
commit
aab7a587b6
|
@ -28,8 +28,9 @@ REQUEST_ID = 'req-test-request-id'
|
|||
def _stub_volume(*args, **kwargs):
|
||||
volume = {
|
||||
"migration_status": None,
|
||||
"attachments": [{u'server_id': u'1234', u'id':
|
||||
u'3f88836f-adde-4296-9f6b-2c59a0bcda9a'}],
|
||||
"attachments": [{u'server_id': u'1234',
|
||||
u'id': u'3f88836f-adde-4296-9f6b-2c59a0bcda9a',
|
||||
u'attachment_id': u'5678'}],
|
||||
"links": [
|
||||
{
|
||||
"href": "http://localhost/v2/fake/volumes/1234",
|
||||
|
|
|
@ -1408,3 +1408,20 @@ class ShellTest(utils.TestCase):
|
|||
'--backup-gigabytes 1 '
|
||||
'--per-volume-gigabytes 1')
|
||||
self.assert_called('PUT', '/os-quota-class-sets/test', body=expected)
|
||||
|
||||
def test_translate_attachments(self):
|
||||
attachment_id = 'aaaa'
|
||||
server_id = 'bbbb'
|
||||
obj_id = 'cccc'
|
||||
info = {
|
||||
'attachments': [{
|
||||
'attachment_id': attachment_id,
|
||||
'id': obj_id,
|
||||
'server_id': server_id}]
|
||||
}
|
||||
|
||||
new_info = test_shell._translate_attachments(info)
|
||||
|
||||
self.assertEqual(attachment_id, new_info['attachment_ids'][0])
|
||||
self.assertEqual(server_id, new_info['attached_servers'][0])
|
||||
self.assertNotIn('id', new_info)
|
||||
|
|
|
@ -36,7 +36,7 @@ def _translate_attachments(info):
|
|||
attachments = []
|
||||
attached_servers = []
|
||||
for attachment in info['attachments']:
|
||||
attachments.append(attachment['id'])
|
||||
attachments.append(attachment['attachment_id'])
|
||||
attached_servers.append(attachment['server_id'])
|
||||
info.pop('attachments', None)
|
||||
info['attachment_ids'] = attachments
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
---
|
||||
fixes:
|
||||
- |
|
||||
The attachment_ids in the volume info returned by show volume were
|
||||
incorrect. It was showing the volume_id, not the attachment_id. This fix
|
||||
changes the attachment_ids returned by show volume to correctly reflect
|
||||
the attachment_id.
|
||||
[Bug `1713082 <https://bugs.launchpad.net/bugs/1713082>`_]
|
Loading…
Reference in New Issue