summaryrefslogtreecommitdiff
path: root/nova/volume
diff options
context:
space:
mode:
authorSteve Noyes <steve.noyes@oracle.com>2017-09-22 17:13:03 -0400
committerSteve Noyes <steve.noyes@oracle.com>2017-09-22 19:41:27 -0400
commit0fe0b94a838268e020e0b129424300881be8ea0f (patch)
treec5f81b622463b5e78b953551e3ae246fff631d04 /nova/volume
parent3268ddc557ec3ffe77284f66b8c975a2c27389b4 (diff)
downloadnova-0fe0b94a838268e020e0b129424300881be8ea0f.tar.gz
Add attachment_get call to volume/cinder_api
The new cinder v3 live-migrate code will need to query cinder to get the current connection information. This call is added to support that. The new cinder v3 migration flow will be made dependent on this change (review 463987). Partially Implements: blueprint cinder-new-attach-apis Change-Id: Ia5b9def46c687249803eaeb0dd60f6e18401dbb2
Diffstat (limited to 'nova/volume')
-rw-r--r--nova/volume/cinder.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/nova/volume/cinder.py b/nova/volume/cinder.py
index 356f92db6b..7d054ae302 100644
--- a/nova/volume/cinder.py
+++ b/nova/volume/cinder.py
@@ -573,6 +573,31 @@ class API(object):
instance_uuid=instance_id)
@translate_attachment_exception
+ def attachment_get(self, context, attachment_id):
+ """Gets a volume attachment.
+
+ :param context: The nova request context.
+ :param attachment_id: UUID of the volume attachment to get.
+ :returns: a dict created from the
+ cinderclient.v3.attachments.VolumeAttachment object with a backward
+ compatible connection_info dict
+ """
+ try:
+ attachment_ref = cinderclient(
+ context, '3.44', skip_version_check=True).attachments.show(
+ attachment_id)
+ translated_attach_ref = _translate_attachment_ref(
+ attachment_ref.to_dict())
+ return translated_attach_ref
+ except cinder_exception.ClientException as ex:
+ with excutils.save_and_reraise_exception():
+ LOG.error(('Show 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_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.