diff --git a/openstack/compute/v2/volume_attachment.py b/openstack/compute/v2/volume_attachment.py index 45fc45bc2..eee123d77 100644 --- a/openstack/compute/v2/volume_attachment.py +++ b/openstack/compute/v2/volume_attachment.py @@ -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' diff --git a/openstack/tests/unit/compute/v2/test_volume_attachment.py b/openstack/tests/unit/compute/v2/test_volume_attachment.py index 03d031c1f..d623fc523 100644 --- a/openstack/tests/unit/compute/v2/test_volume_attachment.py +++ b/openstack/tests/unit/compute/v2/test_volume_attachment.py @@ -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) diff --git a/releasenotes/notes/compute-microversion-2-89-8c5187cc3bf6bd02.yaml b/releasenotes/notes/compute-microversion-2-89-8c5187cc3bf6bd02.yaml new file mode 100644 index 000000000..e22a340dc --- /dev/null +++ b/releasenotes/notes/compute-microversion-2-89-8c5187cc3bf6bd02.yaml @@ -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.