Merge "volume: Correct output of 'volume attachment create'"

This commit is contained in:
Zuul 2022-06-27 15:54:20 +00:00 committed by Gerrit Code Review
commit 30622272e3
3 changed files with 24 additions and 8 deletions

View File

@ -73,8 +73,9 @@ class TestVolumeAttachmentCreate(TestVolumeAttachment):
self.volumes_mock.get.return_value = self.volume self.volumes_mock.get.return_value = self.volume
self.servers_mock.get.return_value = self.server self.servers_mock.get.return_value = self.server
# VolumeAttachmentManager.create returns a dict
self.volume_attachments_mock.create.return_value = \ self.volume_attachments_mock.create.return_value = \
self.volume_attachment self.volume_attachment.to_dict()
self.cmd = volume_attachment.CreateVolumeAttachment(self.app, None) self.cmd = volume_attachment.CreateVolumeAttachment(self.app, None)

View File

@ -51,18 +51,27 @@ def _format_attachment(attachment):
'Properties', 'Properties',
) )
# TODO(stephenfin): Improve output with the nested connection_info # VolumeAttachmentManager.create returns a dict while everything else
# field - cinderclient printed two things but that's equally ugly # returns a VolumeAttachment object
return ( if isinstance(attachment, dict):
column_headers, data = []
utils.get_item_properties( 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, attachment,
columns, columns,
formatters={ formatters={
'connection_info': format_columns.DictColumn, '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): class CreateVolumeAttachment(command.ShowOne):

View File

@ -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.