Merge "fix creation of protected image"

This commit is contained in:
Zuul 2022-03-16 14:22:32 +00:00 committed by Gerrit Code Review
commit e329538191
3 changed files with 24 additions and 2 deletions

View File

@ -26,7 +26,7 @@ from openstack import utils
# Rackspace returns this for intermittent import errors
_IMAGE_ERROR_396 = "Image cannot be imported. Error code: '396'"
_INT_PROPERTIES = ('min_disk', 'min_ram', 'size', 'virtual_size')
_RAW_PROPERTIES = ('protected', 'tags')
_RAW_PROPERTIES = ('is_protected', 'tags')
class Proxy(_base_proxy.BaseImageProxy):

View File

@ -1295,7 +1295,7 @@ class TestImage(BaseTestImage):
self._call_create_image(
self.image_name, min_disk='0', min_ram=0,
properties={'int_v': 12345}, protected=False)
properties={'int_v': 12345}, is_protected=False)
self.assert_calls()

View File

@ -196,6 +196,28 @@ class TestImage(TestImageProxy):
container_format='fake_cformat', disk_format='fake_dformat',
name='fake', properties=mock.ANY)
def test_image_create_protected(self):
self.proxy.find_image = mock.Mock()
created_image = mock.Mock(spec=image.Image(id="id"))
self.proxy._create = mock.Mock()
self.proxy._create.return_value = created_image
self.proxy._create.return_value.image_import_methods = []
created_image.upload = mock.Mock()
created_image.upload.return_value = FakeResponse(response="",
status_code=200)
properties = {"is_protected": True}
self.proxy.create_image(
name="fake", data="data", container_format="bare",
disk_format="raw", **properties
)
args, kwargs = self.proxy._create.call_args
self.assertEqual(kwargs["is_protected"], True)
def test_image_upload_no_args(self):
# container_format and disk_format are required args
self.assertRaises(exceptions.InvalidRequest, self.proxy.upload_image)