summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2022-06-27 15:54:20 +0000
committerGerrit Code Review <review@openstack.org>2022-06-27 15:54:20 +0000
commit30622272e39c5feaba6f04b21ffd09b8f21e290b (patch)
tree9988abddab5f11b438be1ed0abf529e2f8c8e3ab
parent604ceeedf98e06a07f861a628b931033f5509c79 (diff)
parent045f2e7e0618fdf22c260625d64554382afefde1 (diff)
downloadpython-openstackclient-30622272e39c5feaba6f04b21ffd09b8f21e290b.tar.gz
Merge "volume: Correct output of 'volume attachment create'"
-rw-r--r--openstackclient/tests/unit/volume/v3/test_volume_attachment.py3
-rw-r--r--openstackclient/volume/v3/volume_attachment.py23
-rw-r--r--releasenotes/notes/volume-attachment-create-output-fix-56515b8fcdd260b9.yaml6
3 files changed, 24 insertions, 8 deletions
diff --git a/openstackclient/tests/unit/volume/v3/test_volume_attachment.py b/openstackclient/tests/unit/volume/v3/test_volume_attachment.py
index 09f698e7..44fac6c5 100644
--- a/openstackclient/tests/unit/volume/v3/test_volume_attachment.py
+++ b/openstackclient/tests/unit/volume/v3/test_volume_attachment.py
@@ -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)
diff --git a/openstackclient/volume/v3/volume_attachment.py b/openstackclient/volume/v3/volume_attachment.py
index 39a9c37f..c7401837 100644
--- a/openstackclient/volume/v3/volume_attachment.py
+++ b/openstackclient/volume/v3/volume_attachment.py
@@ -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):
diff --git a/releasenotes/notes/volume-attachment-create-output-fix-56515b8fcdd260b9.yaml b/releasenotes/notes/volume-attachment-create-output-fix-56515b8fcdd260b9.yaml
new file mode 100644
index 00000000..b8bd06e1
--- /dev/null
+++ b/releasenotes/notes/volume-attachment-create-output-fix-56515b8fcdd260b9.yaml
@@ -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.