<div>Hi Oleg,</div><div><br></div>When I read your first email, I had the same impression as Dan.<div>health_monitors look more like a subresource than an action. </div><div><br></div><div>The WSGI framework at the moment is not able to manage subresources; this does not mean we cannot improve it though. Nevertheless, in this case the route mapping is not performed by the API classes in quantum/api, but by the extension manager. I think there should already be a way for specifying parent resources with extensions, but that needs to be explored.</div>
<div><br></div><div>It seems however that you are now trying to map operations on health monitors using distinct member actions (add_health_monitor, get_health_monitors). This is similar to what happens with the L3 API for router interfaces.</div>
<div>However, it seems the original idea behind the API design was to treat health_monitors as an explicit collection, which would also be probably a more 'restful' way of doing it. I think ultimately the question should be directed to Youcef and the team which contributed to the design of the LBaaS API.<br>
<br><div class="gmail_quote">On 14 November 2012 17:18, Oleg Bondarev <span dir="ltr"><<a href="mailto:obondarev@mirantis.com" target="_blank">obondarev@mirantis.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div lang="EN-US" link="blue" vlink="purple"><div><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Hi Dan,<u></u><u></u></span></p><p class="MsoNormal">
<span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Thanks for your comment here. <u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Just wanted to correct a mistake in my first email: of course there can’t be a dict with duplicate keys. The idea was to use list of pairs, like:<u></u><u></u></span></p>
<div class="im"><p class="MsoNormal" style="text-indent:.5in"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">member_actions = [{“health_monitors”: “GET”}, <u></u><u></u></span></p>
</div><p class="MsoNormal" style="text-indent:.5in"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> {“health_monitors”: “POST”}]<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">to have an ability of using same function name with different request actions. Initially I thought that the framework provides such ability but does not dispatch requests correctly. I was wrong.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Actually there is no issue with the framework as it assumes using unique action names for different request methods. <u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">I believe we should update LBaaS REST API doc and use “get_health_monitors”, “add_health_monitors”, etc. to fit in the framework.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Thanks,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Oleg<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> Dan Wendlandt [mailto:<a href="mailto:dan@nicira.com" target="_blank">dan@nicira.com</a>] <br>
<b>Sent:</b> Wednesday, November 14, 2012 7:27 PM<br><b>To:</b> OpenStack Development Mailing List<br><b>Subject:</b> Re: [openstack-dev] [quantum] Quantum extension framework issue<u></u><u></u></span></p><div><div class="h5">
<p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">Hi Oleg,<u></u><u></u></p><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal">Folks from the API-subteam can correct me, but I believe this use model is outside of what the API framework was trying to enable with "actions". The idea is that you use POST/DELETE to create an delete API "resources" (which actually have UUIDs, for example, the "pool" in your example below) and then do a PUT to an "action" to cause some kind of change that you can affect on a resource (e.g., "add_health_monitor" or "remove_health_monitor"). It sounds like what you are proposing is more treating "health_monitors" almost as a "sub-resource", which is not really what the "actions" stuff was designed for. <u></u><u></u></p>
</div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal">I haven't been deeply involved in the LBaaS api design discussion though, so I'd also like to hear from Salvatore, et al. on the API sub-team.<u></u><u></u></p>
</div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal">Dan<u></u><u></u></p></div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><div>
<p class="MsoNormal">On Wed, Nov 14, 2012 at 6:05 AM, Oleg Bondarev <<a href="mailto:obondarev@mirantis.com" target="_blank">obondarev@mirantis.com</a>> wrote:<u></u><u></u></p><div><div><p class="MsoNormal"><span style="color:#1f497d">Hi guys,</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:#1f497d"> </span><u></u><u></u></p><p class="MsoNormal"><span style="color:#1f497d">While working on the API extension for LBaaS I didn’t find a way to use custom member actions if they have the same name and differ only by request method, for example</span><u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p><p class="MsoNormal" style="background:#f3f5f7"><span lang="EN" style="font-family:Courier">List all health monitors of a specific pool: GET /pool/pool_id/health_monitors</span><u></u><u></u></p>
<p class="MsoNormal" style="background:#f3f5f7"><span lang="EN" style="font-family:Courier">Associate health monitors with a pool: POST /pool/pool_id/health_monitors</span><u></u><u></u></p><p class="MsoNormal" style="background:#f3f5f7">
<span lang="EN"> </span><u></u><u></u></p><p class="MsoNormal"><span style="color:#1f497d">In quantum extension framework we pass </span><span lang="EN" style="color:#1f497d">“health_monitors” as member actions for a controller (quantum.api.v2.base.create_resource())</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN"> </span><u></u><u></u></p><p class="MsoNormal">member_actions = {'<span lang="EN">health_monitors</span>': 'GET',<u></u><u></u></p><p class="MsoNormal"> '<span lang="EN">health_monitors</span>': 'POST'}<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p><p class="MsoNormal">controller = base.create_resource(collection_name,<u></u><u></u></p><p class="MsoNormal"> resource_name,<u></u><u></u></p><p class="MsoNormal">
plugin, params,<u></u><u></u></p><p class="MsoNormal"> member_actions=member_actions)<u></u><u></u></p><p class="MsoNormal"> <u></u><u></u></p><p class="MsoNormal">
<span style="color:#1f497d">According to the Controller implementation it dispatches all custom member actions to its plugin attr:</span><u></u><u></u></p><p class="MsoNormal"> <u></u><u></u></p><p class="MsoNormal">def __getattr__(self, name):<u></u><u></u></p>
<p class="MsoNormal"> if name in self._member_actions:<u></u><u></u></p><p class="MsoNormal"> def _handle_action(request, id, body=None):<u></u><u></u></p><p class="MsoNormal"> return getattr(self._plugin, name)(request.context, id, body)<u></u><u></u></p>
<p class="MsoNormal"> return _handle_action<u></u><u></u></p><p class="MsoNormal"> else:<u></u><u></u></p><p class="MsoNormal"> raise AttributeError<u></u><u></u></p><p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal"><span style="color:#1f497d">Where request.context is of type quantum.context.Context and does not contain info about request method.</span><u></u><u></u></p><p class="MsoNormal"><span style="color:#1f497d">As a result there is no way to distinguish two custom actions in the plugin. </span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:#1f497d">Is it an issue in the framework?</span><u></u><u></u></p><p class="MsoNormal"><span style="color:#1f497d"> </span><u></u><u></u></p><p class="MsoNormal"><span style="color:#1f497d">Possible solution may be in concatenation of request method and action name (“get_health_monitors”, “post_health_monitors”) in a controller before dispatching them to a plugin.</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:#1f497d">What do you think? </span><u></u><u></u></p><p class="MsoNormal"><span style="color:#1f497d"> </span><u></u><u></u></p><p class="MsoNormal"><span style="color:#1f497d">Thanks,</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:#1f497d">Oleg</span><u></u><u></u></p></div></div><p class="MsoNormal" style="margin-bottom:12.0pt"><br>_______________________________________________<br>OpenStack-dev mailing list<br>
<a href="mailto:OpenStack-dev@lists.openstack.org" target="_blank">OpenStack-dev@lists.openstack.org</a><br><a href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev" target="_blank">http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev</a><u></u><u></u></p>
</div><p class="MsoNormal"><br><br clear="all"><u></u><u></u></p><div><p class="MsoNormal"><u></u> <u></u></p></div><p class="MsoNormal">-- <br>~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>Dan Wendlandt <u></u><u></u></p><div><p class="MsoNormal">
Nicira, Inc: <a href="http://www.nicira.com" target="_blank">www.nicira.com</a><u></u><u></u></p><div><p class="MsoNormal">twitter: danwendlandt<br>~~~~~~~~~~~~~~~~~~~~~~~~~~~<u></u><u></u></p></div></div><p class="MsoNormal">
<u></u> <u></u></p></div></div></div></div></div><br>_______________________________________________<br>
OpenStack-dev mailing list<br>
<a href="mailto:OpenStack-dev@lists.openstack.org">OpenStack-dev@lists.openstack.org</a><br>
<a href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev" target="_blank">http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev</a><br>
<br></blockquote></div><br></div>