yahoo-eng-team team mailing list archive
-
yahoo-eng-team team
-
Mailing list archive
-
Message #14125
[Bug 1315981] Re: v2 image-update does not accept --tags parameters
** Also affects: glance
Importance: Undecided
Status: New
--
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to Glance.
https://bugs.launchpad.net/bugs/1315981
Title:
v2 image-update does not accept --tags parameters
Status in OpenStack Image Registry and Delivery Service (Glance):
New
Status in Python client library for Glance:
New
Bug description:
When I want to update an image via the following command:
glance --debug image-update beb6cf7d-8215-4de2-a5c4-626bc0ac81c2 --tags 2
I get the following error message:
400 Bad Request
Invalid JSON pointer for this resource: '/tags/0'
(HTTP 400)
And the rest request sended to server is as follow:
curl -i -X PATCH -H 'X-Auth-Token:$token" -H 'Content-Type: application/openstack-images-v2.1-json-patch' -H 'User-Agent: python-glanceclient' -d '[{"path": "/tags/0", "value": "2", "op": "add"}]' http://127.0.0.1:9292/v2/images/beb6cf7d-8215-4de2-a5c4-626bc0ac81c2
This is because the client uses jsonpatch to produce the request body directly, and the jsonpatch deals with array value specially:
>>> import jsonpatch
>>> origiral={"tags":[]}
>>> new={"tags":[1,2]}
>>> print jsonpatch.make_patch(origiral, new)
[{"path": "/tags/0", "value": 1, "op": "add"}, {"path": "/tags/1", "value": 2, "op": "add"}]
>>>
>>> origiral={"tags":[1]}
>>> new={"tags":[1,2]}
>>> print jsonpatch.make_patch(origiral, new)
[{"path": "/tags/1", "value": 2, "op": "add"}]
>>> origiral={"tags":[1]}
>>> new={"tags":[2,1]}
>>> print jsonpatch.make_patch(origiral, new)
[{"path": "/tags/0", "value": 2, "op": "replace"}, {"path": "/tags/1", "value": 1, "op": "add"}]
To manage notifications about this bug go to:
https://bugs.launchpad.net/glance/+bug/1315981/+subscriptions