Please explain what request, action and resource extension all are?

Asked by David Olshefski

Hi,

Trying to get a quantum extension working. Can someone explain what an action, resource, and request extension are?
And how they relate to the URI and/or json body? How does each fit into the processing flow for a HTTP request?

I see 'No route' errors...my guess is that when the request comes in, it gets routed to the proper extension...so either my get_actions() and get_resources() is wrong or the URI is wrong.

I see my request extension is called with the request and a response that says 'Page not found'.

FoxinSocks hasn't helped...

Thanks,
Dave

Question information

Language:
English Edit question
Status:
Answered
For:
neutron Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
dan wendlandt (danwent) said :
#1

Hi David,

Sorry, got behind on Quantum questions during the summit.

Resources introduce a new "entity" to the API. In Quantum, current entities are are "networks" and "ports".

Action extensions tend to be "verbs" that act on a resource. For example, in Nova, there is a "server" resources, and a "rebuild" action on that server resource: http://docs.openstack.org/cactus/openstack-compute/developer/openstack-compute-api-1.1/content/Rebuild_Server-d1e3538.html#d2278e1430 . Core Quantum API doesn't really use "actions" as part of the core API, but extensions certainly could.

Request extensions allow one to add new values to existing requests objects. For example, if you were doing a POST to create a server, but wanted to add a new 'widgetType' attribute for the server object.

Looking at Foxinsox, along with the tests that use it can be helpful here:
- quantum/tests/unit/extensions/foxinsocks.py
- quantum/tests/unit/test_extensions.py

You can also look at other extensions in quantum/extensions, or even nova extensions in nova/api/openstack/compute/contrib/ (these are documented here: http://nova.openstack.org/api_ext/index.html)

Usually the best thing to do is find another extension that does something similar to what you are doing, then use it as a template.

Revision history for this message
David Olshefski (olshef) said :
#2

Thanks, yeah, I have been using other extensions as templates....I don't understand how URI's map to resource and action
extensions - how/when/where the resource & action code is executed?

For example, what is the URI and/or json that will cause the resource & action extension to be executed?

Revision history for this message
dan wendlandt (danwent) said :
#3

the best suggestion I can give you is to look at the examples I mentioned above.

Look at quantum/tests/unit/test_extensions.py, which defines and then calls fake extensions.

If you look at the nova extensions mentioned above, then look at the client code here in https://github.com/openstack/python-novaclient/tree/master/novaclient/v1_1 to see how the client calls match up.

If you're looking to hack on openstack, in its current state reading the existing python code is often the only way to learn how to make your own changes.

Can you help with this problem?

Provide an answer of your own, or ask David Olshefski for more information if necessary.

To post a message you must log in.