[openstack-dev] [nova] proper way to extend index() and add a new property?

Chris Friesen chris.friesen at windriver.com
Thu Mar 12 14:47:52 UTC 2015

I'm looking for some technical advice on API extensions.

I want to add a new field to the output of the "nova service-list" command, 
which currently maps to ServiceController.index().

For the v2 API this seems straightforward, I can add a new extension and in the 
existing function I can call self.ext_mgr.is_loaded() to see if my extension is 
loaded, similar to the existing code that checks for 'os-extended-services-delete'.

For v2.1 (ie the plugins in the v3 directory) the extension management seems to 
be different though.  As far as I can tell I can only extend the controller and 
create a new index() that takes as arguments the request and the output of the 
existing index() function.

The problem I have with this is that the existing index() function returns a 
dict with one key per service in the cluster, which could be quite a few.  It 
seems highly inefficient to look up all the services *again* and extract the 
single value from each that I care about and add it to the output of the 
original index() function.  The best I can do for efficiency is O(n + n * log(n)).

Is there a better way to handle this?  Maybe a way to modify the existing v2.1 
index() function to check whether the new extension is loaded and add in the new 
field based on that (similar to how it's done in v2)?


More information about the OpenStack-dev mailing list