<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:Courier;
panose-1:2 7 4 9 2 2 5 2 4 4;}
@font-face
{font-family:Courier;
panose-1:2 7 4 9 2 2 5 2 4 4;}
@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:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";}
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;}
pre
{mso-style-priority:99;
mso-style-link:"HTML Preformatted Char";
margin:0in;
margin-bottom:.0001pt;
font-size:10.0pt;
font-family:"Courier New";}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri","sans-serif";
color:windowtext;}
span.HTMLPreformattedChar
{mso-style-name:"HTML Preformatted Char";
mso-style-priority:99;
mso-style-link:"HTML Preformatted";
font-family:"Courier New";}
span.line
{mso-style-name:line;}
span.id
{mso-style-name:id;}
span.number
{mso-style-name:number;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri","sans-serif";}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
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-US link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='color:#1F497D'>Hi guys,<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></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<o:p></o:p></span></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal style='mso-line-height-alt:10.8pt;background:#F3F5F7'><span lang=EN style='font-family:Courier;color:black'>List all health monitors of a specific pool: GET /pool/pool_id/health_monitors<o:p></o:p></span></p><p class=MsoNormal style='mso-line-height-alt:10.8pt;background:#F3F5F7'><span class=id><span lang=EN style='font-family:Courier;color:black'>Associate health monitors with a pool: POST</span></span><span class=line><span lang=EN style='font-family:Courier;color:black'> /</span></span><span lang=EN style='font-family:Courier;color:black'>pool/pool_id/health_monitors<o:p></o:p></span></p><p class=MsoNormal style='mso-line-height-alt:10.8pt;background:#F3F5F7'><span lang=EN><o:p> </o:p></span></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())<o:p></o:p></span></p><p class=MsoNormal><span lang=EN><o:p> </o:p></span></p><p class=MsoNormal>member_actions = {'<span lang=EN>health_monitors</span>': 'GET',<o:p></o:p></p><p class=MsoNormal> '<span lang=EN>health_monitors</span>': 'POST'}<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>controller = base.create_resource(collection_name,<o:p></o:p></p><p class=MsoNormal> resource_name,<o:p></o:p></p><p class=MsoNormal> plugin, params,<o:p></o:p></p><p class=MsoNormal> member_actions=member_actions)<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><span style='color:#1F497D'>According to the Controller implementation it dispatches all custom member actions to its plugin attr:<o:p></o:p></span></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>def __getattr__(self, name):<o:p></o:p></p><p class=MsoNormal> if name in self._member_actions:<o:p></o:p></p><p class=MsoNormal> def _handle_action(request, id, body=None):<o:p></o:p></p><p class=MsoNormal> return getattr(self._plugin, name)(request.context, id, body)<o:p></o:p></p><p class=MsoNormal> return _handle_action<o:p></o:p></p><p class=MsoNormal> else:<o:p></o:p></p><p class=MsoNormal> raise AttributeError<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></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.<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>As a result there is no way to distinguish two custom actions in the plugin. <o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>Is it an issue in the framework?<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></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.<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>What do you think? <o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>Thanks,<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>Oleg<o:p></o:p></span></p></div></body></html>