<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";
        mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";
        mso-fareast-language:EN-US;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-IN" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal">Hi Devs,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">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.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">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.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">POC code for approach suggested by glance:<o:p></o:p></p>
<p class="MsoNormal">------------------------------------------<o:p></o:p></p>
<p class="MsoNormal"># change in python-glanceclient/v2/images.py to delete api<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">import functools<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">def append_request_id(req_id_lst, response, *args, **kwargs):<o:p></o:p></p>
<p class="MsoNormal">    req_id = response.headers.get('x-openstack-request-id')<o:p></o:p></p>
<p class="MsoNormal">    if req_id:<o:p></o:p></p>
<p class="MsoNormal">        req_id_lst.append(req_id)<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">def setup_request_id_hook(req_id_lst):<o:p></o:p></p>
<p class="MsoNormal">    if req_id_lst is not None:<o:p></o:p></p>
<p class="MsoNormal">        return dict(response=functools.partial(append_request_id, req_id_lst))<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">def delete(self, image_id, request_ids=None):<o:p></o:p></p>
<p class="MsoNormal">                hook = setup_request_id_hook(request_ids)<o:p></o:p></p>
<p class="MsoNormal">                url = '/v2/images/%s' % image_id<o:p></o:p></p>
<p class="MsoNormal">                self.http_client.delete(url, hooks=hook)<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"># modify the do_image_delete function (glanceclient/v2/shell.py) to look as follows:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">request_ids = []<o:p></o:p></p>
<p class="MsoNormal">gc.images.delete(args_id, request_ids=request_ids)<o:p></o:p></p>
<p class="MsoNormal">print request_ids<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">$ glance image-delete 11887d68-7faf-4821-9a42-3ec63451067c<o:p></o:p></p>
<p class="MsoNormal">['req-a0892f56-2626-4069-8787-f8bf56e0c1cc']<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">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.<o:p></o:p></p>
<p class="MsoNormal">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.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">My point here is, should we follow this new approach in all python-clients to maintain the consistency across openstack?<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Please provide your feedback for the same.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">[1] <a href="http://specs.openstack.org/openstack/openstack-specs/specs/return-request-id.html">
http://specs.openstack.org/openstack/openstack-specs/specs/return-request-id.html</a><o:p></o:p></p>
<p class="MsoNormal">[2] <a href="https://review.openstack.org/#/c/257170/">https://review.openstack.org/#/c/257170/</a>  (base patch, followed by dependent patches)<o:p></o:p></p>
<p class="MsoNormal">[3] <a href="https://bugs.launchpad.net/glance/+bug/1525259">
https://bugs.launchpad.net/glance/+bug/1525259</a><o:p></o:p></p>
<p class="MsoNormal">[4] <a href="https://bugs.launchpad.net/glance/+bug/1525259/comments/1">
https://bugs.launchpad.net/glance/+bug/1525259/comments/1</a> and <a href="https://bugs.launchpad.net/glance/+bug/1525259/comments/5">
https://bugs.launchpad.net/glance/+bug/1525259/comments/5</a><o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thank you,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Abhishek Kekane<o:p></o:p></p>
</div>
<br clear="both">
______________________________________________________________________<BR>
Disclaimer: This email and any attachments are sent in strictest confidence<BR>
for the sole use of the addressee and may contain legally privileged,<BR>
confidential, and proprietary data. If you are not the intended recipient,<BR>
please advise the sender by replying promptly to this email and then delete<BR>
and destroy this email and any attachments without any further use, copying<BR>
or forwarding.<BR>
</body>
</html>