Skip to content

Commit 51ee17a

Browse files
committed
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
1 parent 6ce7da8 commit 51ee17a

4 files changed

Lines changed: 77 additions & 4 deletions

File tree

openstackclient/compute/v2/server_volume.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,24 @@ def take_action(self, parsed_args):
4444

4545
volumes = compute_client.volumes.get_server_volumes(server.id)
4646

47-
columns = (
48-
'id',
47+
columns = ()
48+
column_headers = ()
49+
50+
if compute_client.api_version < api_versions.APIVersion('2.89'):
51+
columns += ('id',)
52+
column_headers += ('ID',)
53+
54+
columns += (
4955
'device',
5056
'serverId',
5157
'volumeId',
5258
)
53-
column_headers = (
54-
'ID',
59+
column_headers += (
5560
'Device',
5661
'Server ID',
5762
'Volume ID',
5863
)
64+
5965
if compute_client.api_version >= api_versions.APIVersion('2.70'):
6066
columns += ('tag',)
6167
column_headers += ('Tag',)
@@ -64,6 +70,10 @@ def take_action(self, parsed_args):
6470
columns += ('delete_on_termination',)
6571
column_headers += ('Delete On Termination?',)
6672

73+
if compute_client.api_version >= api_versions.APIVersion('2.89'):
74+
columns += ('attachment_id', 'bdm_uuid')
75+
column_headers += ('Attachment ID', 'BlockDeviceMapping UUID')
76+
6777
return (
6878
column_headers,
6979
(

openstackclient/tests/unit/compute/v2/fakes.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1715,6 +1715,9 @@ def create_one_volume_attachment(attrs=None, methods=None):
17151715
"tag": "foo",
17161716
# introduced in API microversion 2.79
17171717
"delete_on_termination": True,
1718+
# introduced in API microversion 2.89
1719+
"attachment_id": uuid.uuid4().hex,
1720+
"bdm_uuid": uuid.uuid4().hex
17181721
}
17191722

17201723
# Overwrite default attributes.

openstackclient/tests/unit/compute/v2/test_server_volume.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,55 @@ def test_server_volume_list_with_delete_on_attachment(self):
167167
self.servers_volumes_mock.get_server_volumes.assert_called_once_with(
168168
self.server.id)
169169

170+
def test_server_volume_list_with_attachment_ids(self):
171+
self.app.client_manager.compute.api_version = \
172+
api_versions.APIVersion('2.89')
173+
174+
arglist = [
175+
self.server.id,
176+
]
177+
verifylist = [
178+
('server', self.server.id),
179+
]
180+
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
181+
182+
columns, data = self.cmd.take_action(parsed_args)
183+
184+
self.assertEqual(
185+
(
186+
'Device', 'Server ID', 'Volume ID', 'Tag',
187+
'Delete On Termination?', 'Attachment ID',
188+
'BlockDeviceMapping UUID',
189+
),
190+
columns,
191+
)
192+
self.assertEqual(
193+
(
194+
(
195+
self.volume_attachments[0].device,
196+
self.volume_attachments[0].serverId,
197+
self.volume_attachments[0].volumeId,
198+
self.volume_attachments[0].tag,
199+
self.volume_attachments[0].delete_on_termination,
200+
self.volume_attachments[0].attachment_id,
201+
self.volume_attachments[0].bdm_uuid
202+
203+
),
204+
(
205+
self.volume_attachments[1].device,
206+
self.volume_attachments[1].serverId,
207+
self.volume_attachments[1].volumeId,
208+
self.volume_attachments[1].tag,
209+
self.volume_attachments[1].delete_on_termination,
210+
self.volume_attachments[1].attachment_id,
211+
self.volume_attachments[1].bdm_uuid
212+
),
213+
),
214+
tuple(data),
215+
)
216+
self.servers_volumes_mock.get_server_volumes.assert_called_once_with(
217+
self.server.id)
218+
170219

171220
class TestServerVolumeUpdate(TestServerVolume):
172221

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
features:
3+
- |
4+
Added support for `microversion 2.89`_. This microversion removes the
5+
``id`` field while adding the ``attachment_id`` and ``bdm_uuid`` fields to
6+
the responses of ``GET /servers/{server_id}/os-volume_attachments`` and
7+
``GET /servers/{server_id}/os-volume_attachments/{volume_id}`` with these
8+
changes reflected in novaclient under the ``openstack server volume list``
9+
command.
10+
11+
.. _microversion 2.89: https://docs.openstack.org/nova/latest/reference/api-microversion-history.html#microversion-2-89

0 commit comments

Comments
 (0)