]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Applied patch from Mike Perez <thingee@gmail.com> to be able to create volume from...
authorThomas Goirand <thomas@goirand.fr>
Sat, 26 Apr 2014 15:12:57 +0000 (23:12 +0800)
committerThomas Goirand <thomas@goirand.fr>
Sat, 26 Apr 2014 15:12:57 +0000 (23:12 +0800)
Rewritten-From: 90770dccc197e1f1c43982e2aaec286593aa0c27

xenial/debian/changelog
xenial/debian/patches/fallback-to-None-on-missing-Glance-image-attrs.patch [new file with mode: 0644]
xenial/debian/patches/series

index ffff55fe0109203b105d783c24536f74d6bfcf62..62de46ab01e09cf8104b9c69a50f5730a6c16d9b 100644 (file)
@@ -1,3 +1,10 @@
+cinder (2014.1-2) unstable; urgency=medium
+
+  * Applied patch from Mike Perez <thingee@gmail.com> to be able to create
+    volume from glance image without checksum.
+
+ -- Thomas Goirand <zigo@debian.org>  Sat, 26 Apr 2014 23:12:30 +0800
+
 cinder (2014.1-1) unstable; urgency=medium
 
   * New upstream release.
diff --git a/xenial/debian/patches/fallback-to-None-on-missing-Glance-image-attrs.patch b/xenial/debian/patches/fallback-to-None-on-missing-Glance-image-attrs.patch
new file mode 100644 (file)
index 0000000..fc7c947
--- /dev/null
@@ -0,0 +1,103 @@
+Description: Fallback to None on missing Glance image attrs
+ It's possible for glance images to be missing attributes like name and
+ checksum. We'll just set those to None by default to avoid missing key
+ exceptions being raised.
+Author: Mike Perez <thingee@gmail.com>
+Origin: upstream, https://review.openstack.org/#/c/88089/
+Bug-Ubuntu: https://launchpad.net/bugs/1308058
+Forwarded: not-needed
+Reviewed-By: Sebastien Badia <seb@sebian.fr>
+Last-Update: 2014-04-25
+
+diff --git a/cinder/image/glance.py b/cinder/image/glance.py
+index 0c15ba0..e0e6ab2 100644
+--- a/cinder/image/glance.py
++++ b/cinder/image/glance.py
+@@ -431,7 +431,7 @@ def _extract_attributes(image):
+         elif attr == 'checksum' and output['status'] != 'active':
+             output[attr] = None
+         else:
+-            output[attr] = getattr(image, attr)
++            output[attr] = getattr(image, attr, None)
+     output['properties'] = getattr(image, 'properties', {})
+diff --git a/cinder/tests/image/test_glance.py b/cinder/tests/image/test_glance.py
+index 3be3568..7374372 100644
+--- a/cinder/tests/image/test_glance.py
++++ b/cinder/tests/image/test_glance.py
+@@ -17,8 +17,7 @@
+ import datetime
+ import glanceclient.exc
+-import glanceclient.v2.client
+-from glanceclient.v2.client import Client as glanceclient_v2
++from glanceclient.v2 import client as glance_client_v2
+ from oslo.config import cfg
+ from cinder import context
+@@ -542,6 +541,50 @@ class TestGlanceImageService(test.TestCase):
+             self.assertEqual(same_id, image_id)
+             self.assertEqual(service._client.netloc, ipv6_url)
++    def test_extracting_missing_attributes(self):
++        """Verify behavior from glance objects that are missing attributes
++
++        This fakes the image class and is missing the checksum and name
++        attribute as the client would return if they're not set in the
++        database. Regression test for bug #1308058.
++        """
++        class MyFakeGlanceImage(glance_stubs.FakeImage):
++            def __init__(self, metadata):
++                IMAGE_ATTRIBUTES = ['size', 'disk_format', 'owner',
++                                    'container_format', 'id', 'created_at',
++                                    'updated_at', 'deleted', 'status',
++                                    'min_disk', 'min_ram', 'is_public']
++                raw = dict.fromkeys(IMAGE_ATTRIBUTES)
++                raw.update(metadata)
++                self.__dict__['raw'] = raw
++
++        metadata = {
++            'id': 1,
++            'created_at': self.NOW_DATETIME,
++            'updated_at': self.NOW_DATETIME,
++        }
++        image = MyFakeGlanceImage(metadata)
++        actual = glance._extract_attributes(image)
++        expected = {
++            'id': 1,
++            'name': None,
++            'is_public': None,
++            'size': None,
++            'min_disk': None,
++            'min_ram': None,
++            'disk_format': None,
++            'container_format': None,
++            'checksum': None,
++            'created_at': self.NOW_DATETIME,
++            'updated_at': self.NOW_DATETIME,
++            'deleted_at': None,
++            'deleted': None,
++            'status': None,
++            'properties': {},
++            'owner': None,
++        }
++        self.assertEqual(actual, expected)
++
+ class TestGlanceClientVersion(test.TestCase):
+     """Tests the version of the glance client generated."""
+@@ -551,11 +594,11 @@ class TestGlanceClientVersion(test.TestCase):
+         def fake_get_model(self):
+             return
+-        self.stubs.Set(glanceclient_v2, '_get_image_model',
++        self.stubs.Set(glance_client_v2.Client, '_get_image_model',
+                        fake_get_model)
+         try:
+-            self.stubs.Set(glanceclient_v2, '_get_member_model',
++            self.stubs.Set(glance_client_v2.Client, '_get_member_model',
+                            fake_get_model)
+         except AttributeError:
+             # method requires stubbing only with newer glanceclients.
index ebd33f1a9bbe79d2bc3df546dab9f05f630c6b86..69f34a7a46eff9aaa12b331f041ec83d5f5b507a 100644 (file)
@@ -1,2 +1,3 @@
 install-missing-files.patch
 re-add-filter-authtoken.patch
+fallback-to-None-on-missing-Glance-image-attrs.patch