[openstack-dev] Writing extensions to Nova API
Kevin L. Mitchell
kevin.mitchell at rackspace.com
Mon Sep 24 15:00:56 UTC 2012
On Fri, 2012-09-21 at 08:46 +0530, Trinath Somanchi wrote:
> I understand that the extension extend the behavior of an existing
> expert class.
>
> But I have a doubt, How the extension based definitions/methods are
> mapped to the URI ?
You might want to take a look at nova/api/openstack/compute/contrib for
existing extensions, to get an idea of how extensions are structured.
In short, there are two major types of extensions: ControllerExtension,
which extends existing "expert" controllers, and ResourceExtension,
which adds a brand new URI endpoint.
For the ControllerExtension, you specify the short name of the resource
you're extending; for instance, to extend the behavior
of /v2/<tenant-id>/servers/detail, you would use 'servers'. You'll have
to dig through the code a bit to verify the short names of the
controllers. As an example of this, check out admin_actions.py.
For the ResourceExtension, you specify the endpoint name and an optional
parent. The underlying Routes package sets up the mapping between
URI/HTTP method and the controller method name, and it is possible to
add methods using the member_actions and collection_actions arguments.
As an example of this, check out quotas.py.
--
Kevin L. Mitchell <kevin.mitchell at rackspace.com>
More information about the OpenStack-dev
mailing list