Merge "Remove os-image-create API extension"

This commit is contained in:
Zuul 2018-09-20 19:01:41 +00:00 committed by Gerrit Code Review
commit 31a885c046
5 changed files with 13 additions and 55 deletions

View File

@ -1,28 +0,0 @@
# Copyright (c) 2012 NTT.
# Copyright (c) 2012 OpenStack Foundation
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
"""The Create Volume from Image extension."""
from cinder.api import extensions
class Image_create(extensions.ExtensionDescriptor):
"""Allow creating a volume from an image in the Create Volume v1 API."""
name = "CreateVolumeExtension"
alias = "os-image-create"
updated = "2012-08-13T00:00:00+00:00"

View File

@ -246,11 +246,10 @@ class VolumeController(wsgi.Controller):
LOG.info("Create volume of %s GB", size)
if self.ext_mgr.is_loaded('os-image-create'):
image_ref = volume.get('imageRef')
if image_ref is not None:
image_uuid = self._image_uuid_from_ref(image_ref, context)
kwargs['image_id'] = image_uuid
image_ref = volume.get('imageRef')
if image_ref is not None:
image_uuid = self._image_uuid_from_ref(image_ref, context)
kwargs['image_id'] = image_uuid
kwargs['availability_zone'] = volume.get('availability_zone', None)
kwargs['scheduler_hints'] = volume.get('scheduler_hints', None)

View File

@ -309,16 +309,15 @@ class VolumeController(volumes_v2.VolumeController):
# Not found exception will be handled at the wsgi level
kwargs['group'] = self.group_api.get(context, group_id)
if self.ext_mgr.is_loaded('os-image-create'):
image_ref = volume.get('imageRef')
if image_ref is not None:
image_uuid = self._image_uuid_from_ref(image_ref, context)
image_snapshot = self._get_image_snapshot(context, image_uuid)
if (req_version.matches(mv.get_api_version(
mv.SUPPORT_NOVA_IMAGE)) and image_snapshot):
kwargs['snapshot'] = image_snapshot
else:
kwargs['image_id'] = image_uuid
image_ref = volume.get('imageRef')
if image_ref is not None:
image_uuid = self._image_uuid_from_ref(image_ref, context)
image_snapshot = self._get_image_snapshot(context, image_uuid)
if (req_version.matches(mv.get_api_version(
mv.SUPPORT_NOVA_IMAGE)) and image_snapshot):
kwargs['snapshot'] = image_snapshot
else:
kwargs['image_id'] = image_uuid
backup_id = volume.get('backup_id')
if backup_id:

View File

@ -392,7 +392,6 @@ class VolumeApiTest(test.TestCase):
self.mock_object(db.sqlalchemy.api, '_volume_type_get_full',
v2_fakes.fake_volume_type_get)
self.ext_mgr.extensions = {'os-image-create': 'fake'}
vol = self._vol_in_request_body(
availability_zone="nova",
image_ref="c905cedb-7281-47e4-8a62-f26bc5fc4c77")
@ -405,7 +404,6 @@ class VolumeApiTest(test.TestCase):
def test_volume_create_with_image_ref_is_integer(self):
self.mock_object(volume_api.API, "create", v2_fakes.fake_volume_create)
self.ext_mgr.extensions = {'os-image-create': 'fake'}
vol = self._vol_in_request_body(availability_zone="cinder",
image_ref=1234)
body = {"volume": vol}
@ -420,7 +418,6 @@ class VolumeApiTest(test.TestCase):
self.mock_object(fake_image._FakeImageService,
"detail",
v2_fakes.fake_image_service_detail)
self.ext_mgr.extensions = {'os-image-create': 'fake'}
vol = self._vol_in_request_body(availability_zone="cinder",
image_ref="12345")
body = {"volume": vol}
@ -435,7 +432,6 @@ class VolumeApiTest(test.TestCase):
self.mock_object(fake_image._FakeImageService,
"detail",
v2_fakes.fake_image_service_detail)
self.ext_mgr.extensions = {'os-image-create': 'fake'}
vol = self._vol_in_request_body(availability_zone="cinder",
image_ref="")
body = {"volume": vol}
@ -453,7 +449,6 @@ class VolumeApiTest(test.TestCase):
self.mock_object(db.sqlalchemy.api, '_volume_type_get_full',
v2_fakes.fake_volume_type_get)
self.ext_mgr.extensions = {'os-image-create': 'fake'}
vol = self._vol_in_request_body(
availability_zone="nova",
image_id="c905cedb-7281-47e4-8a62-f26bc5fc4c77")
@ -466,7 +461,6 @@ class VolumeApiTest(test.TestCase):
def test_volume_create_with_image_id_is_integer(self):
self.mock_object(volume_api.API, "create", v2_fakes.fake_volume_create)
self.ext_mgr.extensions = {'os-image-create': 'fake'}
vol = self._vol_in_request_body(availability_zone="cinder",
image_id=1234)
body = {"volume": vol}
@ -481,7 +475,6 @@ class VolumeApiTest(test.TestCase):
self.mock_object(fake_image._FakeImageService,
"detail",
v2_fakes.fake_image_service_detail)
self.ext_mgr.extensions = {'os-image-create': 'fake'}
vol = self._vol_in_request_body(availability_zone="cinder",
image_id="12345")
body = {"volume": vol}
@ -496,7 +489,6 @@ class VolumeApiTest(test.TestCase):
self.mock_object(fake_image._FakeImageService,
"detail",
v2_fakes.fake_image_service_detail)
self.ext_mgr.extensions = {'os-image-create': 'fake'}
vol = self._vol_in_request_body(availability_zone="cinder",
image_id="")
body = {"volume": vol}
@ -518,7 +510,6 @@ class VolumeApiTest(test.TestCase):
v2_fakes.fake_image_service_detail)
test_id = "Fedora-x86_64-20-20140618-sda"
self.ext_mgr.extensions = {'os-image-create': 'fake'}
vol = self._vol_in_request_body(availability_zone="nova",
image_ref=test_id)
ex = self._expected_vol_from_controller(availability_zone="nova")
@ -535,7 +526,6 @@ class VolumeApiTest(test.TestCase):
v2_fakes.fake_image_service_detail)
test_id = "multi"
self.ext_mgr.extensions = {'os-image-create': 'fake'}
vol = self._vol_in_request_body(availability_zone="nova",
image_ref=test_id)
body = {"volume": vol}
@ -553,7 +543,6 @@ class VolumeApiTest(test.TestCase):
v2_fakes.fake_image_service_detail)
test_id = "MissingName"
self.ext_mgr.extensions = {'os-image-create': 'fake'}
vol = self._vol_in_request_body(availability_zone="nova",
image_ref=test_id)
body = {"volume": vol}

View File

@ -277,7 +277,6 @@ class VolumeApiTest(test.TestCase):
get_snapshot.side_effect = v2_fakes.fake_snapshot_get
volume_type_get.side_effect = v2_fakes.fake_volume_type_get
self.ext_mgr.extensions = {'os-image-create': 'fake'}
vol = self._vol_in_request_body(
image_id="b0a599e0-41d7-3582-b260-769f443c862a")