diff options
author | Matt Riedemann <mriedem.os@gmail.com> | 2017-12-21 12:22:42 -0500 |
---|---|---|
committer | Ildiko Vancsa <ildiko.vancsa@gmail.com> | 2018-01-02 15:34:05 +0100 |
commit | de0386ad1376fb6d1b1f2bca9fcd81c2364a3126 (patch) | |
tree | e9887c6038f19708bc79abf4de630467fea89f4d /nova/volume | |
parent | afd45295f44c51fbd7ac543a82cee8f383054f00 (diff) | |
download | nova-de0386ad1376fb6d1b1f2bca9fcd81c2364a3126.tar.gz |
Add support for getting volume details with a specified microversion
This allows us to get volume details and pass through a microversion.
This will be used to get a volume with microversion 3.48 where
the shared_targets and service_uuid parameters are in the response.
We will then use that information to determine if we should lock
attach/detach operations on that volume.
Part of blueprint multi-attach-volume
Change-Id: Ief30adfef35eefe03e5a3d3d9623cd48e4d334a4
Diffstat (limited to 'nova/volume')
-rw-r--r-- | nova/volume/cinder.py | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/nova/volume/cinder.py b/nova/volume/cinder.py index d2de9efbd5..8c9a6f0ebb 100644 --- a/nova/volume/cinder.py +++ b/nova/volume/cinder.py @@ -199,6 +199,13 @@ def _untranslate_volume_summary_view(context, vol): if hasattr(vol, 'volume_image_metadata'): d['volume_image_metadata'] = copy.deepcopy(vol.volume_image_metadata) + # The 3.48 microversion exposes a shared_targets boolean and service_uuid + # string parameter which can be used with locks during volume attach + # and detach. + if hasattr(vol, 'shared_targets'): + d['shared_targets'] = vol.shared_targets + d['service_uuid'] = vol.service_uuid + return d @@ -332,8 +339,17 @@ class API(object): """API for interacting with the volume manager.""" @translate_volume_exception - def get(self, context, volume_id): - item = cinderclient(context).volumes.get(volume_id) + def get(self, context, volume_id, microversion=None): + """Get the details about a volume given it's ID. + + :param context: the nova request context + :param volume_id: the id of the volume to get + :param microversion: optional string microversion value + :raises: CinderAPIVersionNotAvailable if the specified microversion is + not available. + """ + item = cinderclient( + context, microversion=microversion).volumes.get(volume_id) return _untranslate_volume_summary_view(context, item) @translate_cinder_exception |