diff options
author | Stephen Finucane <sfinucan@redhat.com> | 2021-11-03 11:31:04 +0000 |
---|---|---|
committer | Stephen Finucane <sfinucan@redhat.com> | 2021-11-03 11:57:31 +0000 |
commit | 163cb01e46fc3f906154a7045fdbe9342cd446c7 (patch) | |
tree | 4b041f2d5d023250f2fe2a70307568909f116847 /openstackclient/compute | |
parent | f824e13bc5754d3de108d39d62de3d6cfae2670c (diff) | |
download | python-openstackclient-163cb01e46fc3f906154a7045fdbe9342cd446c7.tar.gz |
compute: Return details of attached volumes5.7.0
The API behind the 'server add volume' command returns details of the
created volume attachment, however, we were dropping these results
rather than displaying them to the user. Correct this.
Change-Id: I3f7e121220d29422ccf4e6940de2f28bb8496c83
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
Diffstat (limited to 'openstackclient/compute')
-rw-r--r-- | openstackclient/compute/v2/server.py | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/openstackclient/compute/v2/server.py b/openstackclient/compute/v2/server.py index c11f4b57..80bdc612 100644 --- a/openstackclient/compute/v2/server.py +++ b/openstackclient/compute/v2/server.py @@ -496,7 +496,7 @@ class AddServerSecurityGroup(command.Command): server.add_security_group(security_group['id']) -class AddServerVolume(command.Command): +class AddServerVolume(command.ShowOne): _description = _( "Add volume to server. " "Specify ``--os-compute-api-version 2.20`` or higher to add a volume " @@ -595,12 +595,30 @@ class AddServerVolume(command.Command): kwargs['delete_on_termination'] = False - compute_client.volumes.create_server_volume( + volume_attachment = compute_client.volumes.create_server_volume( server.id, volume.id, **kwargs ) + columns = ('id', 'serverId', 'volumeId', 'device') + column_headers = ('ID', 'Server ID', 'Volume ID', 'Device') + if compute_client.api_version >= api_versions.APIVersion('2.49'): + columns += ('tag',) + column_headers += ('Tag',) + if compute_client.api_version >= api_versions.APIVersion('2.79'): + columns += ('delete_on_termination',) + column_headers += ('Delete On Termination',) + + return ( + column_headers, + utils.get_item_properties( + volume_attachment, + columns, + mixed_case_fields=('serverId', 'volumeId'), + ) + ) + # TODO(stephenfin): Replace with 'MultiKeyValueAction' when we no longer # support '--nic=auto' and '--nic=none' |