← Back to team overview

openstack team mailing list archive

Adding new method to nova API throws exception

 

Hi Stackers-

I'm working on currently adding an additional method to the NOVA API.

The new method groups the servers based on the metadata. It returns a group
of server UUIDs based on the Metadata information in the URL from client.

For the same I have modified the following files.

[1] update the nova.api.openstack.compute.__init__.py with the following
mapper.resource.

      mapper.resource("server","servers",
                        controller = self.resources['servers'],
                        collection={'metadetail':'GET'},
                        member={'action':'POST'})

[2] Update the nova.api.openstack.compute.servers.py with the following
function

     @wsgi.serializers(xml=ServerTemplate)
     def metadetail(self,req):
        """ Return the servers UUIDs based on the META data infortmation """
        return;

Being a newbee to understand the code well, I have updated the novaclient
api, to redirect the request to /server/metadetail/{metadata_details}

But the approach was unsuccessful.

2012-09-17 13:27:11 INFO nova.api.openstack.wsgi
[req-e9c7c50e-6f71-4757-bb69-7971ab81a8a7 9e4a57c9e6a944de9404b963f260b464
e216fcb54dc944a8ab16e4e325299643] GET
http://10.232.90.82:8774/v2/e216fcb54dc944a8ab16e4e325299643/servers/metadetail?instance_metadata.key=Server+Group&instance_metadata.value=DOM1


Trinath> My request went, good


2012-09-17 13:27:11 DEBUG nova.api.openstack.wsgi
[req-e9c7c50e-6f71-4757-bb69-7971ab81a8a7 9e4a57c9e6a944de9404b963f260b464
e216fcb54dc944a8ab16e4e325299643]  WSGI :: get_action_args :: {'action':
u'show', 'project_id': u'e216fcb54dc944a8ab16e4e325299643', 'id':
u'metadetail'} from (pid=24295) get_action_args
/usr/lib/python2.7/dist-packages/nova/api/openstack/wsgi.py:700

Trinath>> Why is that the actions in "show" here with a ID "metadetail".?
Where did I go wrong.

2012-09-17 13:27:11 DEBUG nova.api.openstack.wsgi
[req-e9c7c50e-6f71-4757-bb69-7971ab81a8a7 9e4a57c9e6a944de9404b963f260b464
e216fcb54dc944a8ab16e4e325299643] Unrecognized Content-Type provided in
request from (pid=24295) get_body
/usr/lib/python2.7/dist-packages/nova/api/openstack/wsgi.py:708
2012-09-17 13:27:11 INFO nova.api.openstack.wsgi
[req-e9c7c50e-6f71-4757-bb69-7971ab81a8a7 9e4a57c9e6a944de9404b963f260b464
e216fcb54dc944a8ab16e4e325299643]  Trinath LOG ****** [_process_stack]
contents =>  {}
2012-09-17 13:27:11 INFO nova.api.openstack.wsgi
[req-e9c7c50e-6f71-4757-bb69-7971ab81a8a7 9e4a57c9e6a944de9404b963f260b464
e216fcb54dc944a8ab16e4e325299643]  Trinath LOG ****** [_process_stack]
action_args => {'project_id': u'e216fcb54dc944a8ab16e4e325299643', 'id':
u'metadetail'}
2012-09-17 13:27:11 INFO nova.api.openstack.wsgi
[req-e9c7c50e-6f71-4757-bb69-7971ab81a8a7 9e4a57c9e6a944de9404b963f260b464
e216fcb54dc944a8ab16e4e325299643]  Trinath LOG ******
[pre_process_extension] extensions => [<bound method
ServerDiskConfigController.show of
<nova.api.openstack.compute.contrib.disk_config.ServerDiskConfigController
object at 0x3836890>>, <bound method ExtendedStatusController.show of
<nova.api.openstack.compute.contrib.extended_status.ExtendedStatusController
object at 0x39d3f10>>, <bound method
ExtendedServerAttributesController.show of
<nova.api.openstack.compute.contrib.extended_server_attributes.ExtendedServerAttributesController
object at 0x3d0bf50>>]
2012-09-17 13:27:11 INFO nova.api.openstack.wsgi
[req-e9c7c50e-6f71-4757-bb69-7971ab81a8a7 9e4a57c9e6a944de9404b963f260b464
e216fcb54dc944a8ab16e4e325299643] HTTP exception thrown: The resource could
not be found.
2012-09-17 13:27:11 INFO nova.api.openstack.wsgi
[req-e9c7c50e-6f71-4757-bb69-7971ab81a8a7 9e4a57c9e6a944de9404b963f260b464
e216fcb54dc944a8ab16e4e325299643]
http://10.232.90.82:8774/v2/e216fcb54dc944a8ab16e4e325299643/servers/metadetail?instance_metadata.key=Server+Group&instance_metadata.value=DOM1returned
with HTTP 404


Can any one help me on Where did I go wrong?

How to integrate new methods into the API (I know via Extensions we can
make it but Now testing this kind of approach)?

Please help me find a solution / path way to integrate new methods into the
API.

Thanks in advance.

-- 
Regards,
----------------------------------------------
Trinath Somanchi,
+91 9866 235 130

Follow ups