[openstack-dev] Troubleshooting the nova api extension

Trinath Somanchi trinath.somanchi at gmail.com
Mon Sep 24 09:39:53 UTC 2012


Hi-

I'm trying to write an extension to the Openstack Nova API.

I have written the extension, for listing the servers based on the
Metadata.

I have written a client, which sends the URL,
GET
http://10.232.90.82:8774/v2/e216fcb54dc944a8ab16e4e325299643/servers/metadetail?instance_metadata.key=Server+Group&instance_metadata.value=DOM1

Also, after writing the extension in nova api, I get the following debug
logs which confirm that, the extension is flawless.

INFO nova.api.openstack.wsgi [-]  Trinath LOG [ControllerMetaClass ::
__new__] CLS_dict  =>  {'__module__':
'nova.api.openstack.compute.contrib.server_groupby_metadata',
'wsgi_extensions': [('metadetail', None)], 'metadetail': <function
metadetail at 0x3828f50>, '__init__': <function __init__ at 0x3828ed8>,
'wsgi_actions': {}}
 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
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


When I run the client program, I see the following info in the logs,

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>, {'action': u'show', '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': '
10.232.90.82:8774', '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': 1348470337,
'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

Here, The URI, /server/metadetail? is not being mapped to the method
"metadetail()" method present in the   extension.

Also, its that, the WSGI is mapping, the URI to "show" method rather than
the "metadetail" method.
 'wsgiorg.routing_args': (<routes.util.URLGenerator object at 0x36f64d0>,
{'action': u'show', 'controller': <nova.api.openstack.wsgi.Resource object
at 0x4644750>, 'project_id': u'e216fcb54dc944a8ab16e4e325299643', 'id':
u'metadetail'})

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.

Kindly, please help me in this regard.

Thanks in advance,


-- 
Regards,
----------------------------------------------
Trinath Somanchi,
+91 9866 235 130
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20120924/9a70e081/attachment.html>


More information about the OpenStack-dev mailing list