Fix bug of updating metadata for images

Glance project has a blueprint hidden-images. The commit can be
seen from https://review.openstack.org/#/c/578755/
The os_hidden is added into image metadata as bool type. From
horizon, the string value of os_hidden is passed to glanceclient.
https://github.com/openstack/python-glanceclient/blob/master/glanceclient/v2/images.py#L341
But type is not correspond so raise exception to horizon from
glanceclient.

Here to change the type of os_hidden before passing it to glanceclient.

Closes-Bug: #1789172
Change-Id: I0d4edaa4b661d2da79cdb45e4afa97d826aeb65d
This commit is contained in:
zhubx007 2018-08-29 15:37:01 +08:00 committed by Ivan Kolodyazhny
parent e03b8d9a41
commit 47ba614f19
1 changed files with 3 additions and 0 deletions

View File

@ -105,6 +105,9 @@ class ImageProperties(generic.View):
This method returns HTTP 204 (no content) on success.
"""
if "os_hidden" in request.DATA['updated']:
request.DATA['updated']['os_hidden'] = (
request.DATA['updated']['os_hidden'] == "true")
api.glance.image_update_properties(
request, image_id, request.DATA.get('removed'),
**request.DATA['updated']