Hi Kevin-<div><br></div><div>I have few more doubts.</div><div><br></div><div>[1] What are Member action and Collection actions? I see them in the Source code, of the ResourceExtension. Can you shower some light on these terms, their usage and significance.</div>
<div><br></div><div>Thanking you.</div><div><br></div><div>-</div><div>Trinath</div><div><br></div><div><br><br><div class="gmail_quote">On Wed, Sep 26, 2012 at 9:53 PM, Trinath Somanchi <span dir="ltr"><<a href="mailto:trinath.somanchi@gmail.com" target="_blank">trinath.somanchi@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p>Hi Kevin</p>
<p>Thanks lot for reply..<br></p>
<p>I'll understand the code and start my new extension.</p>
<p>Thanks a lot again for this precious help.</p>
<p>-<br>
Trinath</p><div class="HOEnZb"><div class="h5">
<div class="gmail_quote">On Sep 26, 2012 9:46 PM, "Kevin L. Mitchell" <<a href="mailto:kevin.mitchell@rackspace.com" target="_blank">kevin.mitchell@rackspace.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

On Wed, 2012-09-26 at 21:00 +0530, Trinath Somanchi wrote:<br>
> 1. What are Controller and Resource extensions? How do they differ?<br>
<br>
OK, so term definition time.  Nova uses the Routes[1] software to map<br>
URI/HTTP method to a function to call.  Routes happens to provide a<br>
short-cut interface for setting up the routes for REST-style calls<br>
(which is what Nova uses); the call is resource()[2].<br>
<br>
Now, in Nova's world, a "Resource" is one of these top-level things; it<br>
has operations like index() ("GET <resource>"), show() ("GET<br>
<resource>/<id>"), update() ("PUT <resource>/<id>"), delete() ("DELETE<br>
<resource>/<id>"), etc.  (See the Routes documentation for the full<br>
list.)  A ResourceExtension is an extension that allows creation of one<br>
of these resources, and the "parent" stuff allows you to link that<br>
resource to be under another resource, i.e., "GET <parent>/<resource>"<br>
maps to index(), "GET <parent>/<resource>/<id>" maps to show(), etc.<br>
<br>
A ControllerExtension, on the other hand, allows you to extend an<br>
existing resource—usually one of the basic Nova resources<br>
(i.e., /servers).  With this kind of extension, you can add an<br>
"action" (not your current use case, but see below), or you can wrap an<br>
existing (and only an existing!) method of that resource.  This<br>
limitation is why I suggested you should try using a ResourceExtension<br>
for your use case—there's no way to add a new method to an existing<br>
resource without modifying the code that creates that existing resource.<br>
<br>
> 2. How do client requests differ for these type of extensions? Can you<br>
> give some examples on this.<br>
<br>
Client requests don't differ at all for these types of extensions; it's<br>
the semantics of what they mean.<br>
<br>
I should note that I can see a way to use a ControllerExtension to<br>
retrieve metadetails, but you wouldn't be doing GET /servers/metadetail;<br>
you would be doing POST /servers/action, and the body that you POSTed<br>
would convey the request for metadetails.  (You could also use this body<br>
to convey the query parameters.)  This is called an "action", and if you<br>
want to see examples of how this works, check out the admin_actions.py<br>
extension you've already looked at—it defines a whole bunch of actions.<br>
<br>
The Nova API system is rather complicated, and the best documentation<br>
for how to modify and extend it is still the code, unfortunately.  I<br>
hope that I've helped you understand it a bit more clearly, but keep in<br>
mind that much of what I've stated here is from memory, so it might be<br>
worth reading the code for yourself to make sure I got it right :)<br>
<br>
--<br>
<br>
[1] <a href="http://routes.readthedocs.org/en/latest/index.html" target="_blank">http://routes.readthedocs.org/en/latest/index.html</a><br>
[2] <a href="http://routes.readthedocs.org/en/latest/restful.html" target="_blank">http://routes.readthedocs.org/en/latest/restful.html</a><br>
--<br>
Kevin L. Mitchell <<a href="mailto:kevin.mitchell@rackspace.com" target="_blank">kevin.mitchell@rackspace.com</a>><br>
<br>
<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><br>
</blockquote></div>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>Regards,<br>----------------------------------------------<br>Trinath Somanchi,<div>+91 9866 235 130</div><br>
</div>