Skip to content

Commit

Permalink
Remove os-image-create API extension
Browse files Browse the repository at this point in the history
This was a dummy extension and only used by the v1 API. This is now a
standard part of the API and does not need any extra checks to see if it
should be enabled or not. This removes the dummy extensions and checks
in the code for its presence.

Change-Id: Ia0a3fa41aa06fbbe9d2ed67a1273226ee47429f9
  • Loading branch information
zhangjun-inspur authored and stmcginnis committed Aug 21, 2018
1 parent c54fc62 commit 3541146
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 55 deletions.
28 changes: 0 additions & 28 deletions cinder/api/contrib/image_create.py

This file was deleted.

9 changes: 4 additions & 5 deletions cinder/api/v2/volumes.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,11 +246,10 @@ def create(self, req, body):

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)
Expand Down
19 changes: 9 additions & 10 deletions cinder/api/v3/volumes.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,16 +309,15 @@ def create(self, req, body):
# 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:
Expand Down
11 changes: 0 additions & 11 deletions cinder/tests/unit/api/v2/test_volumes.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,6 @@ def test_volume_create_with_image_ref(self, mock_validate):
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")
Expand All @@ -405,7 +404,6 @@ def test_volume_create_with_image_ref(self, mock_validate):

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}
Expand All @@ -420,7 +418,6 @@ def test_volume_create_with_image_ref_not_uuid_format(self):
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}
Expand All @@ -435,7 +432,6 @@ def test_volume_create_with_image_ref_with_empty_string(self):
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}
Expand All @@ -453,7 +449,6 @@ def test_volume_create_with_image_id(self, mock_validate):
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")
Expand All @@ -466,7 +461,6 @@ def test_volume_create_with_image_id(self, mock_validate):

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}
Expand All @@ -481,7 +475,6 @@ def test_volume_create_with_image_id_not_uuid_format(self):
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}
Expand All @@ -496,7 +489,6 @@ def test_volume_create_with_image_id_with_empty_string(self):
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}
Expand All @@ -518,7 +510,6 @@ def test_volume_create_with_image_name(self, mock_validate):
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")
Expand All @@ -535,7 +526,6 @@ def test_volume_create_with_image_name_has_multiple(self):
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}
Expand All @@ -553,7 +543,6 @@ def test_volume_create_with_image_name_no_match(self):
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}
Expand Down
1 change: 0 additions & 1 deletion cinder/tests/unit/api/v3/test_volumes.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,6 @@ def test_volume_create_with_snapshot_image(self, mock_validate, create,
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")

Expand Down

0 comments on commit 3541146

Please sign in to comment.