summaryrefslogtreecommitdiff
path: root/openstackclient
diff options
context:
space:
mode:
authorLee Yarwood <lyarwood@redhat.com>2021-08-12 11:27:17 +0100
committerLee Yarwood <lyarwood@redhat.com>2021-09-02 14:35:17 +0100
commit51ee17a94dccd297101725593b223f01c4f9b906 (patch)
tree0fca6a2e240b6e98fc619fdce6f12fc1060d9c43 /openstackclient
parent6ce7da8aeb7e5d1347940433e087036e8e43eaa6 (diff)
downloadpython-openstackclient-51ee17a94dccd297101725593b223f01c4f9b906.tar.gz
compute: Add support for microversion 2.89
This microversion drops the duplicate ``id`` field while adding ``attachment_id`` and ``bdm_uuid`` to the output of the os-volume_attachments API reflected within osc by the ``openstack server volume list $server``command. Depends-On: https://review.opendev.org/c/openstack/nova/+/804275 Change-Id: I8a7002d8d65d7795e106b768df868198ab8b8143
Diffstat (limited to 'openstackclient')
-rw-r--r--openstackclient/compute/v2/server_volume.py18
-rw-r--r--openstackclient/tests/unit/compute/v2/fakes.py3
-rw-r--r--openstackclient/tests/unit/compute/v2/test_server_volume.py49
3 files changed, 66 insertions, 4 deletions
diff --git a/openstackclient/compute/v2/server_volume.py b/openstackclient/compute/v2/server_volume.py
index b53c92fe..d53cec93 100644
--- a/openstackclient/compute/v2/server_volume.py
+++ b/openstackclient/compute/v2/server_volume.py
@@ -44,18 +44,24 @@ class ListServerVolume(command.Lister):
volumes = compute_client.volumes.get_server_volumes(server.id)
- columns = (
- 'id',
+ columns = ()
+ column_headers = ()
+
+ if compute_client.api_version < api_versions.APIVersion('2.89'):
+ columns += ('id',)
+ column_headers += ('ID',)
+
+ columns += (
'device',
'serverId',
'volumeId',
)
- column_headers = (
- 'ID',
+ column_headers += (
'Device',
'Server ID',
'Volume ID',
)
+
if compute_client.api_version >= api_versions.APIVersion('2.70'):
columns += ('tag',)
column_headers += ('Tag',)
@@ -64,6 +70,10 @@ class ListServerVolume(command.Lister):
columns += ('delete_on_termination',)
column_headers += ('Delete On Termination?',)
+ if compute_client.api_version >= api_versions.APIVersion('2.89'):
+ columns += ('attachment_id', 'bdm_uuid')
+ column_headers += ('Attachment ID', 'BlockDeviceMapping UUID')
+
return (
column_headers,
(
diff --git a/openstackclient/tests/unit/compute/v2/fakes.py b/openstackclient/tests/unit/compute/v2/fakes.py
index 05a14e16..3142a244 100644
--- a/openstackclient/tests/unit/compute/v2/fakes.py
+++ b/openstackclient/tests/unit/compute/v2/fakes.py
@@ -1715,6 +1715,9 @@ class FakeVolumeAttachment(object):
"tag": "foo",
# introduced in API microversion 2.79
"delete_on_termination": True,
+ # introduced in API microversion 2.89
+ "attachment_id": uuid.uuid4().hex,
+ "bdm_uuid": uuid.uuid4().hex
}
# Overwrite default attributes.
diff --git a/openstackclient/tests/unit/compute/v2/test_server_volume.py b/openstackclient/tests/unit/compute/v2/test_server_volume.py
index 4d4916b7..02d378f8 100644
--- a/openstackclient/tests/unit/compute/v2/test_server_volume.py
+++ b/openstackclient/tests/unit/compute/v2/test_server_volume.py
@@ -167,6 +167,55 @@ class TestServerVolumeList(TestServerVolume):
self.servers_volumes_mock.get_server_volumes.assert_called_once_with(
self.server.id)
+ def test_server_volume_list_with_attachment_ids(self):
+ self.app.client_manager.compute.api_version = \
+ api_versions.APIVersion('2.89')
+
+ arglist = [
+ self.server.id,
+ ]
+ verifylist = [
+ ('server', self.server.id),
+ ]
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
+
+ columns, data = self.cmd.take_action(parsed_args)
+
+ self.assertEqual(
+ (
+ 'Device', 'Server ID', 'Volume ID', 'Tag',
+ 'Delete On Termination?', 'Attachment ID',
+ 'BlockDeviceMapping UUID',
+ ),
+ columns,
+ )
+ self.assertEqual(
+ (
+ (
+ self.volume_attachments[0].device,
+ self.volume_attachments[0].serverId,
+ self.volume_attachments[0].volumeId,
+ self.volume_attachments[0].tag,
+ self.volume_attachments[0].delete_on_termination,
+ self.volume_attachments[0].attachment_id,
+ self.volume_attachments[0].bdm_uuid
+
+ ),
+ (
+ self.volume_attachments[1].device,
+ self.volume_attachments[1].serverId,
+ self.volume_attachments[1].volumeId,
+ self.volume_attachments[1].tag,
+ self.volume_attachments[1].delete_on_termination,
+ self.volume_attachments[1].attachment_id,
+ self.volume_attachments[1].bdm_uuid
+ ),
+ ),
+ tuple(data),
+ )
+ self.servers_volumes_mock.get_server_volumes.assert_called_once_with(
+ self.server.id)
+
class TestServerVolumeUpdate(TestServerVolume):