Hi Devs,
I have submitted a cross-project specs [1] for returning request-id to the
caller which was approved. For implementation we have submitted patches in
python-cinderclient [2] as per design in cross-project specs. However we have
found one issue while implementing this design in python-glanceclient and
submitted a lite-spec [3] to address this issue.
As per the comments [4] on lite-specs, glance core are suggesting new approach
to use hooks and pass empty list to each of the api, so that when the hook is
executed it will append the request-id to the list.
POC code for approach suggested by glance:
------------------------------------------
# change in python-glanceclient/v2/images.py to delete api
import functools
def append_request_id(req_id_lst, response, *args, **kwargs):
req_id = response.headers.get('x-openstack-request-id')
if req_id:
req_id_lst.append(req_id)
def setup_request_id_hook(req_id_lst):
if req_id_lst is not None:
return dict(response=functools.partial(append_request_id, req_id_lst))
def delete(self, image_id, request_ids=None):
hook = setup_request_id_hook(request_ids)
url = '/v2/images/%s' % image_id
self.http_client.delete(url, hooks=hook)
# modify the do_image_delete function (glanceclient/v2/shell.py) to look as
follows:
request_ids = []
gc.images.delete(args_id, request_ids=request_ids)
print request_ids
$ glance image-delete 11887d68-7faf-4821-9a42-3ec63451067c
['req-a0892f56-2626-4069-8787-f8bf56e0c1cc']
We have tested this approach and it is working as per expectation, only thing
is that we need to make changes in every method to add hook and request_id list.
>From third-party tools, user need to pass this request-ids list as mentioned
>in above poc in order to get the request-id back.
My point here is, should we follow this new approach in all python-clients to
maintain the consistency across openstack?
Please provide your feedback for the same.
[1]
http://specs.openstack.org/openstack/openstack-specs/specs/return-request-id.html
[2] https://review.openstack.org/#/c/257170/ (base patch, followed by
dependent patches)
[3] https://bugs.launchpad.net/glance/+bug/1525259
[4] https://bugs.launchpad.net/glance/+bug/1525259/comments/1 and
https://bugs.launchpad.net/glance/+bug/1525259/comments/5
Thank you,
Abhishek Kekane
______________________________________________________________________
Disclaimer: This email and any attachments are sent in strictest confidence
for the sole use of the addressee and may contain legally privileged,
confidential, and proprietary data. If you are not the intended recipient,
please advise the sender by replying promptly to this email and then delete
and destroy this email and any attachments without any further use, copying
or forwarding.
__________________________________________________________________________
OpenStack Development Mailing List (not for usage questions)
Unsubscribe: openstack-dev-requ...@lists.openstack.org?subject:unsubscribe
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev