]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Ignore purge_props for v2 Glance api and fix upload
authorEdward Hope-Morley <edward.hope-morley@canonical.com>
Fri, 9 Aug 2013 12:06:46 +0000 (13:06 +0100)
committerEdward Hope-Morley <edward.hope-morley@canonical.com>
Fri, 9 Aug 2013 13:10:04 +0000 (14:10 +0100)
The V2 Glance API image schema does not contain
purge_props. While this may be a bug in Glance,
we will ignore this property in cinder when
glance_api_version=2. This will not change behaviour
since Glance defaults this property to True, Cinder
never sets it to False and the v2 client appears to
ignore it anyway.

Also fixed image upload which is a seperate client
call to update in v2 (v1 update does both).

Change-Id: I0ba1d7d920984cface57795ace160ec300ff75e2
Fixes: bug #1210467
cinder/image/glance.py

index f9315e6a88c6bb1f9341868959e872d78f4a5b28..3003f4ee7d3e62405f4b6079aeccb3b550c16a10 100644 (file)
@@ -263,15 +263,22 @@ class GlanceImageService(object):
                image_meta, data=None, purge_props=True):
         """Modify the given image with the new data."""
         image_meta = self._translate_to_glance(image_meta)
-        image_meta['purge_props'] = purge_props
+        #NOTE(dosaboy): see comment in bug 1210467
+        if CONF.glance_api_version == 1:
+            image_meta['purge_props'] = purge_props
         #NOTE(bcwaldon): id is not an editable field, but it is likely to be
         # passed in by calling code. Let's be nice and ignore it.
         image_meta.pop('id', None)
         if data:
             image_meta['data'] = data
         try:
-            image_meta = self._client.call(context, 'update', image_id,
-                                           **image_meta)
+            #NOTE(dosaboy): the v2 api separates update from upload
+            if data and CONF.glance_api_version > 1:
+                image_meta = self._client.call(context, 'upload', image_id,
+                                               image_meta['data'])
+            else:
+                image_meta = self._client.call(context, 'update', image_id,
+                                               **image_meta)
         except Exception:
             _reraise_translated_image_exception(image_id)
         else: