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
This commit is contained in:
Lee Yarwood 2021-08-12 11:27:17 +01:00
parent 6ce7da8aeb
commit 51ee17a94d
4 changed files with 77 additions and 4 deletions

View File

@ -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,
(

View File

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

View File

@ -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):

View File

@ -0,0 +1,11 @@
---
features:
- |
Added support for `microversion 2.89`_. This microversion removes the
``id`` field while adding the ``attachment_id`` and ``bdm_uuid`` fields to
the responses of ``GET /servers/{server_id}/os-volume_attachments`` and
``GET /servers/{server_id}/os-volume_attachments/{volume_id}`` with these
changes reflected in novaclient under the ``openstack server volume list``
command.
.. _microversion 2.89: https://docs.openstack.org/nova/latest/reference/api-microversion-history.html#microversion-2-89