volume: Correct output of 'volume attachment create'
When adding these, we missed that the underlying cinder library call actually returns a dictionary and not a Resource-based object. This requires slightly different handling. Fix this. Change-Id: Ie065fe4198ae1238830cb619220e856390d4cb6e Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
This commit is contained in:
parent
ccd877dd40
commit
045f2e7e06
@ -73,8 +73,9 @@ class TestVolumeAttachmentCreate(TestVolumeAttachment):
|
||||
|
||||
self.volumes_mock.get.return_value = self.volume
|
||||
self.servers_mock.get.return_value = self.server
|
||||
# VolumeAttachmentManager.create returns a dict
|
||||
self.volume_attachments_mock.create.return_value = \
|
||||
self.volume_attachment
|
||||
self.volume_attachment.to_dict()
|
||||
|
||||
self.cmd = volume_attachment.CreateVolumeAttachment(self.app, None)
|
||||
|
||||
|
@ -51,18 +51,27 @@ def _format_attachment(attachment):
|
||||
'Properties',
|
||||
)
|
||||
|
||||
# TODO(stephenfin): Improve output with the nested connection_info
|
||||
# field - cinderclient printed two things but that's equally ugly
|
||||
return (
|
||||
column_headers,
|
||||
utils.get_item_properties(
|
||||
# VolumeAttachmentManager.create returns a dict while everything else
|
||||
# returns a VolumeAttachment object
|
||||
if isinstance(attachment, dict):
|
||||
data = []
|
||||
for column in columns:
|
||||
if column == 'connection_info':
|
||||
data.append(format_columns.DictColumn(attachment[column]))
|
||||
continue
|
||||
data.append(attachment[column])
|
||||
else:
|
||||
data = utils.get_item_properties(
|
||||
attachment,
|
||||
columns,
|
||||
formatters={
|
||||
'connection_info': format_columns.DictColumn,
|
||||
},
|
||||
),
|
||||
)
|
||||
)
|
||||
|
||||
# TODO(stephenfin): Improve output with the nested connection_info
|
||||
# field - cinderclient printed two things but that's equally ugly
|
||||
return (column_headers, data)
|
||||
|
||||
|
||||
class CreateVolumeAttachment(command.ShowOne):
|
||||
|
@ -0,0 +1,6 @@
|
||||
---
|
||||
fixes:
|
||||
- |
|
||||
The ``volume attachment create`` command will now display information
|
||||
for successfully created volume attachments. Previously an empty table was
|
||||
returned.
|
Loading…
Reference in New Issue
Block a user