From 0f70282b78ece51e2e18c51c15aca7c89b7ebc23 Mon Sep 17 00:00:00 2001 From: Edward Hope-Morley Date: Fri, 9 Aug 2013 13:06:46 +0100 Subject: [PATCH] Ignore purge_props for v2 Glance api and fix upload 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 | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/cinder/image/glance.py b/cinder/image/glance.py index f9315e6a8..3003f4ee7 100644 --- a/cinder/image/glance.py +++ b/cinder/image/glance.py @@ -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: -- 2.45.2