diff options
author | Matt Riedemann <mriedem.os@gmail.com> | 2017-04-23 11:07:54 -0400 |
---|---|---|
committer | John Griffith <john.griffith8@gmail.com> | 2017-05-26 18:08:36 +0000 |
commit | a6921bee74ce761017b50aa2b79f48c430f92e29 (patch) | |
tree | c603cb858382d9541c8868506db1b6835abfb358 /nova/volume/cinder.py | |
parent | 05c4b7b9daab1e8a0d91a7e1c6547e75ba1661d7 (diff) | |
download | nova-a6921bee74ce761017b50aa2b79f48c430f92e29.tar.gz |
cinder: add attachment_update method
This adds the attachment_update method to the internal
cinder volume API.
With the new style volume attachments (cinder microversion 3.27),
when attaching a volume to an instance, the API will create
an attachment without a connector which puts the attachment and
volume into 'reserved' status. Once we're on the compute host
and get the connector, we update the attachment which effectively
initializes the connection to the volume backend and marks the
volume as attached to the instance.
Part of blueprint cinder-new-attach-apis
Change-Id: I3f5eb47b15a814291694f20e5b13bcbc16e8a3c0
Diffstat (limited to 'nova/volume/cinder.py')
-rw-r--r-- | nova/volume/cinder.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/nova/volume/cinder.py b/nova/volume/cinder.py index 6843e1ad93..11ba16b20c 100644 --- a/nova/volume/cinder.py +++ b/nova/volume/cinder.py @@ -531,6 +531,30 @@ class API(object): instance_uuid=instance_id) @translate_attachment_exception + def attachment_update(self, context, attachment_id, connector): + """Updates the connector on the volume attachment. An attachment + without a connector is considered reserved but not fully attached. + + :param context: The nova request context. + :param attachment_id: UUID of the volume attachment to update. + :param connector: host connector dict. This is required when updating + a volume attachment. To terminate a connection, the volume + attachment for that connection must be deleted. + :returns: cinderclient.v3.attachments.VolumeAttachment object + representing the updated volume attachment. + """ + try: + return cinderclient(context).attachments.update( + attachment_id, connector) + except cinder_exception.ClientException as ex: + with excutils.save_and_reraise_exception(): + LOG.error(('Update attachment failed for attachment ' + '%(id)s. Error: %(msg)s Code: %(code)s'), + {'id': attachment_id, + 'msg': six.text_type(ex), + 'code': getattr(ex, 'code', None)}) + + @translate_attachment_exception def attachment_delete(self, context, attachment_id): try: cinderclient( |