From c080f5a2afc4485cfc16c0e51c730043db2e3ec5 Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Wed, 24 Oct 2018 20:59:55 +0200 Subject: [PATCH] Don't pass disk_format or container_format to image task upload In task upload we update the image properties after importing the image. Attempting to set disk_format/container_format at that point is not the right choice in life. Depends-On: https://review.openstack.org/613438 Change-Id: I3b086e83514a71cea0bb4119d75c48c153099141 --- openstack/cloud/openstackcloud.py | 5 +++-- openstack/tests/unit/cloud/test_image.py | 1 + releasenotes/notes/fix-image-task-ae79502dd5c7ecba.yaml | 6 ++++++ 3 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 releasenotes/notes/fix-image-task-ae79502dd5c7ecba.yaml diff --git a/openstack/cloud/openstackcloud.py b/openstack/cloud/openstackcloud.py index 518f3788c..86d914c84 100755 --- a/openstack/cloud/openstackcloud.py +++ b/openstack/cloud/openstackcloud.py @@ -4973,12 +4973,13 @@ class _OpenStackCloudMixin(_normalize.Normalizer): self, name, filename, wait, timeout, meta, **image_kwargs): - properties = image_kwargs['properties'] + properties = image_kwargs.pop('properties', {}) md5 = properties[self._IMAGE_MD5_KEY] sha256 = properties[self._IMAGE_SHA256_KEY] container = properties[self._IMAGE_OBJECT_KEY].split('/', 1)[0] - properties = image_kwargs.pop('properties', {}) image_kwargs.update(properties) + image_kwargs.pop('disk_format', None) + image_kwargs.pop('container_format', None) self.create_container(container) self.create_object( diff --git a/openstack/tests/unit/cloud/test_image.py b/openstack/tests/unit/cloud/test_image.py index e6927a516..feba4d2c3 100644 --- a/openstack/tests/unit/cloud/test_image.py +++ b/openstack/tests/unit/cloud/test_image.py @@ -487,6 +487,7 @@ class TestImage(BaseTestImage): self.cloud.create_image( self.image_name, self.imagefile.name, wait=True, timeout=1, + disk_format='vhd', container_format='ovf', is_public=False, container=self.container_name) self.assert_calls() diff --git a/releasenotes/notes/fix-image-task-ae79502dd5c7ecba.yaml b/releasenotes/notes/fix-image-task-ae79502dd5c7ecba.yaml new file mode 100644 index 000000000..8a6513b3c --- /dev/null +++ b/releasenotes/notes/fix-image-task-ae79502dd5c7ecba.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - | + Fixed a regression in image upload when the cloud uses the task + upload method. A refactor led to attempting to update the disk_format + and container_format values after the image had been imported.