Merge "Add shared_targets and service_uuid to volumes"

This commit is contained in:
Zuul 2017-12-02 13:05:52 +00:00 committed by Gerrit Code Review
commit af06ceb2c5
6 changed files with 30 additions and 5 deletions

View File

@ -133,6 +133,8 @@ SUPPORT_NOVA_IMAGE = '3.46'
VOLUME_CREATE_FROM_BACKUP = '3.47'
VOLUME_SHARED_TARGETS_AND_SERVICE_FIELDS = '3.48'
def get_mv_header(version):
"""Gets a formatted HTTP microversion header.

View File

@ -111,6 +111,7 @@ REST_API_VERSION_HISTORY = """
detail APIs.
* 3.46 - Support create volume by Nova specific image (0 size image).
* 3.47 - Support create volume from backup.
* 3.48 - Add ``shared_targets`` and ``service_uuid`` fields to volume.
"""
# The minimum and maximum versions of the API supported
@ -118,7 +119,7 @@ REST_API_VERSION_HISTORY = """
# minimum version of the API supported.
# Explicitly using /v2 endpoints will still work
_MIN_API_VERSION = "3.0"
_MAX_API_VERSION = "3.47"
_MAX_API_VERSION = "3.48"
_LEGACY_API_VERSION2 = "2.0"
UPDATED = "2017-09-19T20:18:14Z"

View File

@ -385,3 +385,7 @@ user documentation.
3.47
----
Support create volume from backup.
3.48
----
Add ``shared_targets`` and ``service_uuid`` fields to volume.

View File

@ -54,6 +54,13 @@ class ViewBuilder(views_v2.ViewBuilder):
req_version.matches(mv.VOLUME_DETAIL_PROVIDER_ID, None)):
volume_ref['volume']['provider_id'] = volume.get('provider_id')
if req_version.matches(
mv.VOLUME_SHARED_TARGETS_AND_SERVICE_FIELDS, None):
volume_ref['volume']['shared_targets'] = volume.get(
'shared_targets', None)
volume_ref['volume']['service_uuid'] = volume.get(
'service_uuid', None)
return volume_ref
def _list_view(self, func, request, volumes, volume_count,

View File

@ -946,7 +946,9 @@ class VolumeTestCase(base.BaseVolumeTestCase):
self.volume.delete_volume(self.context, volume_src)
@mock.patch('cinder.volume.flows.api.create_volume.get_flow')
def test_create_volume_from_snapshot_with_types(self, _get_flow):
@mock.patch('cinder.objects.volume.Volume.get_by_id')
def test_create_volume_from_snapshot_with_types(
self, _get_by_id, _get_flow):
"""Test volume create from snapshot with types including mistmatch."""
volume_api = cinder.volume.api.API()
@ -1008,7 +1010,9 @@ class VolumeTestCase(base.BaseVolumeTestCase):
snapshot=snapshot_obj)
@mock.patch('cinder.volume.flows.api.create_volume.get_flow')
def test_create_volume_from_source_with_types(self, _get_flow):
@mock.patch('cinder.objects.volume.Volume.get_by_id')
def test_create_volume_from_source_with_types(
self, _get_by_id, _get_flow):
"""Test volume create from source with types including mistmatch."""
volume_api = cinder.volume.api.API()
foo_type = fake_volume.fake_volume_type_obj(
@ -1060,7 +1064,9 @@ class VolumeTestCase(base.BaseVolumeTestCase):
source_volume=source_vol)
@mock.patch('cinder.volume.flows.api.create_volume.get_flow')
def test_create_volume_from_source_with_same_backend(self, _get_flow):
@mock.patch('cinder.objects.volume.Volume.get_by_id')
def test_create_volume_from_source_with_same_backend(
self, _get_by_id, _get_flow):
"""Test volume create from source with type mismatch same backend."""
volume_api = cinder.volume.api.API()
@ -1105,7 +1111,9 @@ class VolumeTestCase(base.BaseVolumeTestCase):
source_volume=source_vol)
@mock.patch('cinder.volume.flows.api.create_volume.get_flow')
def test_create_from_source_and_snap_only_one_backend(self, _get_flow):
@mock.patch('cinder.objects.volume.Volume.get_by_id')
def test_create_from_source_and_snap_only_one_backend(
self, _get_by_id, _get_flow):
"""Test create from source and snap with type mismatch one backend."""
volume_api = cinder.volume.api.API()

View File

@ -334,6 +334,9 @@ class API(base.Base):
if flow_engine.storage.fetch('refresh_az'):
self.list_availability_zones(enable_cache=True,
refresh_cache=True)
# Refresh the object here, otherwise things ain't right
vref = objects.Volume.get_by_id(
context, vref['id'])
LOG.info("Create volume request issued successfully.",
resource=vref)
return vref