Skip to content

Commit 3062227

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "volume: Correct output of 'volume attachment create'"
2 parents 604ceee + 045f2e7 commit 3062227

File tree

3 files changed

+24
-8
lines changed

3 files changed

+24
-8
lines changed

openstackclient/tests/unit/volume/v3/test_volume_attachment.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,9 @@ def setUp(self):
7373

7474
self.volumes_mock.get.return_value = self.volume
7575
self.servers_mock.get.return_value = self.server
76+
# VolumeAttachmentManager.create returns a dict
7677
self.volume_attachments_mock.create.return_value = \
77-
self.volume_attachment
78+
self.volume_attachment.to_dict()
7879

7980
self.cmd = volume_attachment.CreateVolumeAttachment(self.app, None)
8081

openstackclient/volume/v3/volume_attachment.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,18 +51,27 @@ def _format_attachment(attachment):
5151
'Properties',
5252
)
5353

54-
# TODO(stephenfin): Improve output with the nested connection_info
55-
# field - cinderclient printed two things but that's equally ugly
56-
return (
57-
column_headers,
58-
utils.get_item_properties(
54+
# VolumeAttachmentManager.create returns a dict while everything else
55+
# returns a VolumeAttachment object
56+
if isinstance(attachment, dict):
57+
data = []
58+
for column in columns:
59+
if column == 'connection_info':
60+
data.append(format_columns.DictColumn(attachment[column]))
61+
continue
62+
data.append(attachment[column])
63+
else:
64+
data = utils.get_item_properties(
5965
attachment,
6066
columns,
6167
formatters={
6268
'connection_info': format_columns.DictColumn,
6369
},
64-
),
65-
)
70+
)
71+
72+
# TODO(stephenfin): Improve output with the nested connection_info
73+
# field - cinderclient printed two things but that's equally ugly
74+
return (column_headers, data)
6675

6776

6877
class CreateVolumeAttachment(command.ShowOne):
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
fixes:
3+
- |
4+
The ``volume attachment create`` command will now display information
5+
for successfully created volume attachments. Previously an empty table was
6+
returned.

0 commit comments

Comments
 (0)