Hi Kevin-<div><br></div><div>Thanks for the reply,</div><div><br></div><div>I have a doubt here,</div><div><br></div><div>[1] What are these member_actions and controller_actions</div><div><br></div><div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
I have written the extension, for listing the servers based on the Metadata. </div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)"><br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
I have written a client, which sends the URL, </div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">GET <font color="#1155cc"><a href="http://10.232.90.82:8774/v2/">http://10.232.90.82:8774/v2/</a></font><font color="#1155cc">e216fcb54dc944a8ab16e4e3252996</font><font color="#1155cc">43/servers/metadetail?</font><font color="#1155cc">instance_metadata.key=Server+</font><font color="#1155cc">Group&instance_metadata.value=</font><font color="#1155cc">DOM1</font></div>
<div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)"><br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
Also, after writing the extension in nova api, I get the following debug logs which confirm that, the extension is flawless.</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
<br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">INFO nova.api.openstack.wsgi [-]  Trinath LOG [ControllerMetaClass :: __new__] CLS_dict  =>  {'__module__': 'nova.api.openstack.compute.contrib.server_groupby_metadata', <b><u>'wsgi_extensions': [('metadetail', None)],</u></b> 'metadetail': <function metadetail at 0x3828f50>, '__init__': <function __init__ at 0x3828ed8>, 'wsgi_actions': {}}</div>
<div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)"> DEBUG nova.api.openstack [-]   _setup_ext_routes() ==> {'member': {'metadetail': 'GET'}, 'controller': <nova.api.openstack.wsgi.Resource object at 0x4a33d90>, 'collection': {'metadetail': 'GET'}} from (pid=29146) _setup_ext_routes /usr/lib/python2.7/dist-packages/nova/api/openstack/__init__.py:118</div>
<div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">2012-09-24 12:34:22 DEBUG nova.api.openstack [-]ProjectMapper :: resource :: Member Name = OS-SRVR-GRPBY-METADATA, Collection Name = OS-SRVR-GRPBY-METADATA, kwargs = {'member': {'metadetail': 'GET'}, 'controller': <nova.api.openstack.wsgi.Resource object at 0x4a33d90>, 'collection': {'metadetail': 'GET'}, 'path_prefix': '{project_id}/'} from (pid=29146) resource /usr/lib/python2.7/dist-packages/nova/api/openstack/__init__.py:74</div>
<div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)"><br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
<br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">When I run the client program, I see the following info in the logs,</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
<br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">DEBUG nova.api.openstack.wsgi [req-320da182-509c-4a42-811a-16fdb42c9d2d 9e4a57c9e6a944de9404b963f260b464 e216fcb54dc944a8ab16e4e325299643] WSGI :: request_environment :: {'HTTP_X_TENANT_NAME': u'admin', 'routes.route': <routes.route.Route object at 0x4644e50>, 'HTTP_X_ROLE': u'admin', 'SCRIPT_NAME': '/v2', 'webob.adhoc_attrs': {'response': <Response at 0x51e8d50 200 OK>}, 'REQUEST_METHOD': 'GET', 'PATH_INFO': '/e216fcb54dc944a8ab16e4e325299643/servers/metadetail', 'SERVER_PROTOCOL': 'HTTP/1.0', 'QUERY_STRING': 'instance_metadata.key=Server+Group&instance_metadata.value=DOM1', 'HTTP_X_USER_ID': u'9e4a57c9e6a944de9404b963f260b464', 'HTTP_X_AUTH_TOKEN': '9c9e3f0b06854befa3fa60914b6ab302', 'HTTP_USER_AGENT': 'python-novaclient', 'eventlet.posthooks': [], 'SERVER_NAME': '10.232.90.82', 'REMOTE_ADDR': '10.232.90.82', 'eventlet.input': <eventlet.wsgi.Input object at 0x5325510>, 'HTTP_X_IDENTITY_STATUS': 'Confirmed', 'wsgi.url_scheme': 'http', 'wsgiorg.routing_args': (<routes.util.URLGenerator object at 0x36f64d0>, {<b><u>'action': u'show'</u></b>, 'controller': <nova.api.openstack.wsgi.Resource object at 0x4644750>, 'project_id': u'e216fcb54dc944a8ab16e4e325299643', 'id': u'metadetail'}), 'SERVER_PORT': '8774', 'HTTP_X_ROLES': u'admin', 'HTTP_X_TENANT_ID': u'e216fcb54dc944a8ab16e4e325299643', 'HTTP_X_USER': u'admin', 'nova.context': <nova.context.RequestContext object at 0x5325650>, 'wsgi.input': <eventlet.wsgi.Input object at 0x5325510>, 'HTTP_HOST': '<a href="http://10.232.90.82:8774/" target="_blank" style="color:rgb(17,85,204)">10.232.90.82:8774</a>', 'HTTP_X_AUTH_PROJECT_ID': 'admin', 'wsgi.multithread': True, 'routes.url': <routes.util.URLGenerator object at 0x36f64d0>, 'HTTP_ACCEPT': 'application/json', 'wsgi.version': (1, 0), 'HTTP_X_TENANT': u'admin', 'GATEWAY_INTERFACE': 'CGI/1.1', 'wsgi.run_once': False, 'wsgi.errors': <open file '<stderr>', mode 'w' at 0x7f6f11540270>, 'wsgi.multiprocess': False, 'HTTP_X_USER_NAME': u'admin', 'CONTENT_TYPE': 'text/plain', 'nova.limits': [{'regex': '.*', 'resetTime': <a href="tel:1348470337" value="+911348470337" target="_blank" style="color:rgb(17,85,204)">1348470337</a>, 'URI': '*', 'value': 10, 'verb': 'POST', 'remaining': 10, 'unit': 'MINUTE'}, {'regex': '^/servers', 'resetTime': 1348470337, 'URI': '*/servers', 'value': 50, 'verb': 'POST', 'remaining': 50, 'unit': 'DAY'}, {'regex': '.*', 'resetTime': 1348470337, 'URI': '*', 'value': 10, 'verb': 'PUT', 'remaining': 10, 'unit': 'MINUTE'}, {'regex': '.*changes-since.*', 'resetTime': 1348470337, 'URI': '*changes-since*', 'value': 3, 'verb': 'GET', 'remaining': 3, 'unit': 'MINUTE'}, {'regex': '.*', 'resetTime': 1348470337, 'URI': '*', 'value': 100, 'verb': 'DELETE', 'remaining': 100, 'unit': 'MINUTE'}], 'HTTP_ACCEPT_ENCODING': 'gzip, deflate', 'nova.best_content_type': 'application/json'} from (pid=29146) get_action_args /usr/lib/python2.7/dist-packages/nova/api/openstack/wsgi.py:681</div>
<div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)"><br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
Here, The URI, /server/metadetail? is not being mapped to the method "metadetail()" method present in the   extension.</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
<br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">Also, its that, the WSGI is mapping, the URI to "show" method rather than the "metadetail" method.</div>
<div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)"> 'wsgiorg.routing_args': (<routes.util.URLGenerator object at 0x36f64d0>, {'<b><u>action': u'show',</u></b> 'controller': <nova.api.openstack.wsgi.Resource object at 0x4644750>, 'project_id': u'e216fcb54dc944a8ab16e4e325299643', 'id': u'metadetail'})</div>
<div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)"><br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
Please guide me on how to fix the issue such that the URL with "/server/metadetail" is mapped to the "metadetail" method in the new extension.</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
<br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">Kindly, please help me in this regard.</div></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
<br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">--</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
Trinath</div><div><br></div><div><br><div class="gmail_quote">On Mon, Sep 24, 2012 at 8:30 PM, Kevin L. Mitchell <span dir="ltr"><<a href="mailto:kevin.mitchell@rackspace.com" target="_blank">kevin.mitchell@rackspace.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On Fri, 2012-09-21 at 08:46 +0530, Trinath Somanchi wrote:<br>
> I understand that the extension extend the behavior of an existing<br>
> expert class.<br>
><br>
> But I have a doubt, How the extension based definitions/methods are<br>
> mapped to the URI ?<br>
<br>
</div>You might want to take a look at nova/api/openstack/compute/contrib for<br>
existing extensions, to get an idea of how extensions are structured.<br>
In short, there are two major types of extensions: ControllerExtension,<br>
which extends existing "expert" controllers, and ResourceExtension,<br>
which adds a brand new URI endpoint.<br>
<br>
For the ControllerExtension, you specify the short name of the resource<br>
you're extending; for instance, to extend the behavior<br>
of /v2/<tenant-id>/servers/detail, you would use 'servers'.  You'll have<br>
to dig through the code a bit to verify the short names of the<br>
controllers.  As an example of this, check out admin_actions.py.<br>
<br>
For the ResourceExtension, you specify the endpoint name and an optional<br>
parent.  The underlying Routes package sets up the mapping between<br>
URI/HTTP method and the controller method name, and it is possible to<br>
add methods using the member_actions and collection_actions arguments.<br>
As an example of this, check out quotas.py.<br>
<span class="HOEnZb"><font color="#888888">--<br>
Kevin L. Mitchell <<a href="mailto:kevin.mitchell@rackspace.com">kevin.mitchell@rackspace.com</a>><br>
<br>
<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>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br>Regards,<br>----------------------------------------------<br>Trinath Somanchi,<div>+91 9866 235 130</div><br>
</div>