[openstack-dev] [Nova]Change search and servers action of hypervisor extension following REST principles

Xu He Jie xuhj at linux.vnet.ibm.com
Thu Jun 20 09:39:40 UTC 2013


Hi, guys,

When I port hypervisor extension into Nova API v3, I found some actions 
doesn't follow REST principles.
But I still have some doubt. So I send mail to here, hope I can get some 
suggestion.

Let me explain why I want to change those API.

For search action: https://review.openstack.org/#/c/33774/
The original search action works as:
'/os-hypervisors/[filters]/search'
It use part of URL as filters. So I change it as:
'/os-hypervisors/search?query=[filters]'
(I follow suggestion from 
http://www.slideshare.net/apigee/restful-api-design-second-edition#btnNext 
at 77 pages)

For servers action: https://review.openstack.org/#/c/33775/
The original servers action works as:
'/os-hypervisors/[filters]/servers'
It use part of URL as filters too.
So I change it as:
'/os-hypervisors/[hypervisor id]/servers'
And it will return all the servers that run on the specific hypervisor.

If we want to finish the same task as the old servers action we can do as:
hypervisors = GET /os-hypervisors/search?query=[filters]
for hyper in hypervisors
     servers += GET /os-hypervisors/[hyper.id]/servers

Welcome any comment!

Thanks,
Alex
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20130620/757c5532/attachment.html>


More information about the OpenStack-dev mailing list