Merge "Fix volume upload failure with glance_api_version=2"
This commit is contained in:
commit
ae2ec9bf69
@ -412,6 +412,15 @@ class GlanceImageService(object):
|
|||||||
def _translate_to_glance(image_meta):
|
def _translate_to_glance(image_meta):
|
||||||
image_meta = _convert_to_string(image_meta)
|
image_meta = _convert_to_string(image_meta)
|
||||||
image_meta = _remove_read_only(image_meta)
|
image_meta = _remove_read_only(image_meta)
|
||||||
|
|
||||||
|
# NOTE(tsekiyama): From the Image API v2, custom properties must
|
||||||
|
# be stored in image_meta directly, instead of the 'properties' key.
|
||||||
|
if CONF.glance_api_version >= 2:
|
||||||
|
properties = image_meta.get('properties')
|
||||||
|
if properties:
|
||||||
|
image_meta.update(properties)
|
||||||
|
del image_meta['properties']
|
||||||
|
|
||||||
return image_meta
|
return image_meta
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -665,6 +665,52 @@ class TestGlanceImageService(test.TestCase):
|
|||||||
|
|
||||||
self.assertEqual(expected, actual)
|
self.assertEqual(expected, actual)
|
||||||
|
|
||||||
|
def test_translate_to_glance(self):
|
||||||
|
self.flags(glance_api_version=1)
|
||||||
|
client = glance_stubs.StubGlanceClient()
|
||||||
|
service = self._create_image_service(client)
|
||||||
|
|
||||||
|
metadata = {
|
||||||
|
'id': 1,
|
||||||
|
'size': 2,
|
||||||
|
'min_disk': 2,
|
||||||
|
'min_ram': 2,
|
||||||
|
'properties': {'kernel_id': 'foo',
|
||||||
|
'ramdisk_id': 'bar',
|
||||||
|
'x_billinginfo': '123'},
|
||||||
|
}
|
||||||
|
|
||||||
|
actual = service._translate_to_glance(metadata)
|
||||||
|
expected = metadata
|
||||||
|
self.assertEqual(expected, actual)
|
||||||
|
|
||||||
|
def test_translate_to_glance_v2(self):
|
||||||
|
self.flags(glance_api_version=2)
|
||||||
|
client = glance_stubs.StubGlanceClient()
|
||||||
|
service = self._create_image_service(client)
|
||||||
|
|
||||||
|
metadata = {
|
||||||
|
'id': 1,
|
||||||
|
'size': 2,
|
||||||
|
'min_disk': 2,
|
||||||
|
'min_ram': 2,
|
||||||
|
'properties': {'kernel_id': 'foo',
|
||||||
|
'ramdisk_id': 'bar',
|
||||||
|
'x_billinginfo': '123'},
|
||||||
|
}
|
||||||
|
|
||||||
|
actual = service._translate_to_glance(metadata)
|
||||||
|
expected = {
|
||||||
|
'id': 1,
|
||||||
|
'size': 2,
|
||||||
|
'min_disk': 2,
|
||||||
|
'min_ram': 2,
|
||||||
|
'kernel_id': 'foo',
|
||||||
|
'ramdisk_id': 'bar',
|
||||||
|
'x_billinginfo': '123',
|
||||||
|
}
|
||||||
|
self.assertEqual(expected, actual)
|
||||||
|
|
||||||
|
|
||||||
class TestGlanceClientVersion(test.TestCase):
|
class TestGlanceClientVersion(test.TestCase):
|
||||||
"""Tests the version of the glance client generated."""
|
"""Tests the version of the glance client generated."""
|
||||||
|
@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- upload-to-image using Image API v2 now correctly handles custom image properties.
|
Loading…
Reference in New Issue
Block a user