compute: Add support for microversion 2.89

The volume attachments API now returns the attachment ID and internal
BDM ID in responses.

Change-Id: Ie1482dcffc534893c5d922910afe1c9b40c54fbb
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
Stephen Finucane 2021-11-02 17:04:31 +00:00
parent 770a3c3ed8
commit ef587c9a02
3 changed files with 37 additions and 14 deletions

View File

@ -27,19 +27,26 @@ class VolumeAttachment(resource.Resource):
_query_mapping = resource.QueryParameters("limit", "offset")
#: The ID for the server.
server_id = resource.URI('server_id')
#: Name of the device such as, /dev/vdb.
device = resource.Body('device')
#: The ID of the attachment.
id = resource.Body('id')
#: The ID for the server.
server_id = resource.URI('server_id')
# FIXME(stephenfin): This conflicts since there is a server ID in the URI
# *and* in the body. We need a field that handles both or we need to use
# different names.
# #: The UUID of the server
# server_id = resource.Body('server_uuid')
#: The ID of the attached volume.
volume_id = resource.Body('volumeId')
#: The ID of the attachment you want to delete or update.
#: The UUID of the associated volume attachment in Cinder.
attachment_id = resource.Body('attachment_id', alternate_id=True)
#: The ID of the block device mapping record for the attachment
bdm_id = resource.Body('bdm_uuid')
#: Virtual device tags for the attachment.
tag = resource.Body('tag')
#: Indicates whether to delete the volume when server is destroyed
delete_on_termination = resource.Body('delete_on_termination')
# delete_on_termination introduced in 2.79
_max_microversion = '2.79'
# attachment_id (in responses) and bdm_id introduced in 2.89
_max_microversion = '2.89'

View File

@ -15,11 +15,13 @@ from openstack.tests.unit import base
EXAMPLE = {
'device': '1',
'id': '2',
'volume_id': '3',
'tag': '4',
'delete_on_termination': 'true',
'attachment_id': '979ce4f8-033a-409d-85e6-6b5c0f6a6302',
'delete_on_termination': False,
'device': '/dev/sdc',
'serverId': '7696780b-3f53-4688-ab25-019bfcbbd806',
'tag': 'foo',
'volumeId': 'a07f71dc-8151-4e7d-a0cc-cd24a3f11113',
'bdm_uuid': 'c088db45-92b8-49e8-81e2-a1b77a144b3b',
}
@ -43,9 +45,16 @@ class TestServerInterface(base.TestCase):
def test_make_it(self):
sot = volume_attachment.VolumeAttachment(**EXAMPLE)
self.assertEqual(EXAMPLE['attachment_id'], sot.attachment_id)
self.assertEqual(EXAMPLE['attachment_id'], sot.id)
self.assertEqual(
EXAMPLE['delete_on_termination'], sot.delete_on_termination,
)
self.assertEqual(EXAMPLE['device'], sot.device)
self.assertEqual(EXAMPLE['id'], sot.id)
self.assertEqual(EXAMPLE['volume_id'], sot.volume_id)
# FIXME(stephenfin): This conflicts since there is a server ID in the
# URI *and* in the body. We need a field that handles both or we need
# to use different names.
# self.assertEqual(EXAMPLE['serverId'], sot.server_id)
self.assertEqual(EXAMPLE['tag'], sot.tag)
self.assertEqual(EXAMPLE['delete_on_termination'],
sot.delete_on_termination)
self.assertEqual(EXAMPLE['volumeId'], sot.volume_id)
self.assertEqual(EXAMPLE['bdm_uuid'], sot.bdm_id)

View File

@ -0,0 +1,7 @@
---
features:
- |
The 2.89 API microversion is now supported for the compute service. This
adds additional fields to the ``os-volume_attachments`` API, represented
by the ``openstack.compute.v2.volume_attachment.VolumeAttachment``
resource.