Fix image create with tags
When passing tags to image create _make_v2_image_params will cast tags to string, while those should remain list. This is required to complete switch in OSC from glanceclient to SDK. Since we use TagMixin remove tags property from resource (it's anyway there). Change-Id: I4f068dfafe4bc85ddda6dbc716dffa0c316500f6
This commit is contained in:
parent
f56d7b9a29
commit
cb240b1308
@ -26,6 +26,7 @@ from openstack import utils
|
|||||||
# Rackspace returns this for intermittent import errors
|
# Rackspace returns this for intermittent import errors
|
||||||
_IMAGE_ERROR_396 = "Image cannot be imported. Error code: '396'"
|
_IMAGE_ERROR_396 = "Image cannot be imported. Error code: '396'"
|
||||||
_INT_PROPERTIES = ('min_disk', 'min_ram', 'size', 'virtual_size')
|
_INT_PROPERTIES = ('min_disk', 'min_ram', 'size', 'virtual_size')
|
||||||
|
_RAW_PROPERTIES = ('protected', 'tags')
|
||||||
|
|
||||||
|
|
||||||
class Proxy(_base_proxy.BaseImageProxy):
|
class Proxy(_base_proxy.BaseImageProxy):
|
||||||
@ -184,7 +185,7 @@ class Proxy(_base_proxy.BaseImageProxy):
|
|||||||
for k, v in iter(properties.items()):
|
for k, v in iter(properties.items()):
|
||||||
if k in _INT_PROPERTIES:
|
if k in _INT_PROPERTIES:
|
||||||
ret[k] = int(v)
|
ret[k] = int(v)
|
||||||
elif k == 'protected':
|
elif k in _RAW_PROPERTIES:
|
||||||
ret[k] = v
|
ret[k] = v
|
||||||
else:
|
else:
|
||||||
if v is None:
|
if v is None:
|
||||||
|
@ -104,8 +104,6 @@ class Image(resource.Resource, resource.TagMixin, _download.DownloadMixin):
|
|||||||
store = resource.Body('store')
|
store = resource.Body('store')
|
||||||
#: The image status.
|
#: The image status.
|
||||||
status = resource.Body('status')
|
status = resource.Body('status')
|
||||||
#: Tags, if any, that are associated with the image.
|
|
||||||
tags = resource.Body('tags')
|
|
||||||
#: The date and time when the image was updated.
|
#: The date and time when the image was updated.
|
||||||
updated_at = resource.Body('updated_at')
|
updated_at = resource.Body('updated_at')
|
||||||
#: The virtual size of the image.
|
#: The virtual size of the image.
|
||||||
|
@ -339,7 +339,8 @@ class TestImage(BaseTestImage):
|
|||||||
u'owner_specified.openstack.sha256':
|
u'owner_specified.openstack.sha256':
|
||||||
self.fake_image_dict[
|
self.fake_image_dict[
|
||||||
'owner_specified.openstack.sha256'],
|
'owner_specified.openstack.sha256'],
|
||||||
u'visibility': u'private'})
|
u'visibility': u'private',
|
||||||
|
u'tags': [u'tag1', u'tag2']})
|
||||||
),
|
),
|
||||||
dict(method='PUT',
|
dict(method='PUT',
|
||||||
uri=self.get_mock_url(
|
uri=self.get_mock_url(
|
||||||
@ -360,6 +361,7 @@ class TestImage(BaseTestImage):
|
|||||||
|
|
||||||
self.cloud.create_image(
|
self.cloud.create_image(
|
||||||
self.image_name, self.imagefile.name, wait=True, timeout=1,
|
self.image_name, self.imagefile.name, wait=True, timeout=1,
|
||||||
|
tags=['tag1', 'tag2'],
|
||||||
is_public=False)
|
is_public=False)
|
||||||
|
|
||||||
self.assert_calls()
|
self.assert_calls()
|
||||||
|
Loading…
Reference in New Issue
Block a user