The nova.api.openstack.wsgi Module

class ActionDispatcher

Bases: object

Maps method name to local methods through action name.

default(data)
dispatch(*args, **kwargs)

Find and call local method.

class Controller(view_builder=None)

Bases: object

Default controller.

classmethod api_version(min_ver, max_ver=None)

Decorator for versioning api methods.

Add the decorator to any method which takes a request object as the first parameter and belongs to a class which inherits from wsgi.Controller.

@min_ver: string representing minimum version @max_ver: optional string representing maximum version

static is_valid_body(body, entity_name)
wsgi_actions = {}
wsgi_extensions = []
class ControllerMetaclass

Bases: type

Controller metaclass.

This metaclass automates the task of assembling a dictionary mapping action keys to method names.

exception Fault(exception)

Bases: webob.exc.HTTPException

Wrap webob.exc.HTTPException to provide API friendly response.

class JSONDeserializer

Bases: nova.api.openstack.wsgi.ActionDispatcher

default(datastring)
deserialize(datastring, action='default')
class JSONDictSerializer

Bases: nova.api.openstack.wsgi.ActionDispatcher

Default JSON request body serialization.

default(data)
serialize(data, action='default')
exception RateLimitFault(message, details, retry_time)

Bases: webob.exc.HTTPException

Rate-limited request response.

class Request(*args, **kwargs)

Bases: nova.wsgi.Request

Add some OpenStack API-specific logic to the base webob.Request.

best_match_content_type()

Determine the requested response content-type.

best_match_language()

Determine the best available language for the request.

Returns:the best language match or None if the ‘Accept-Language’ header was not available in the request.
cache_db_compute_node(compute_node)
cache_db_compute_nodes(compute_nodes)
cache_db_flavor(flavor)
cache_db_flavors(flavors)
cache_db_instance(instance)
cache_db_instances(instances)
cache_db_items(key, items, item_key='id')

Allow API methods to store objects from a DB query to be used by API extensions within the same API request.

An instance of this class only lives for the lifetime of a single API request, so there’s no need to implement full cache management.

get_content_type()

Determine content type of the request body.

Does not do any body introspection, only checks header

get_db_compute_node(id)
get_db_compute_nodes()
get_db_flavor(flavorid)
get_db_flavors()
get_db_instance(instance_uuid)
get_db_instances()
get_db_item(key, item_key)

Allow an API extension to get a previously stored object within the same API request.

Note that the object data will be slightly stale.

get_db_items(key)

Allow an API extension to get previously stored objects within the same API request.

Note that the object data will be slightly stale.

is_legacy_v2()
set_api_version_request()

Set API version request based on the request header information.

set_legacy_v2()
class Resource(controller, inherits=None)

Bases: nova.wsgi.Application

WSGI app that handles (de)serialization and controller dispatch.

WSGI app that reads routing information supplied by RoutesMiddleware and calls the requested action method upon its controller. All controller action methods must accept a ‘req’ argument, which is the incoming wsgi.Request. If the operation is a PUT or POST, the controller method must also accept a ‘body’ argument (the deserialized request body). They may raise a webob.exc exception or return a dict, which will be serialized by requested content type.

Exceptions derived from webob.exc.HTTPException will be automatically wrapped in Fault() to provide API friendly error responses.

deserialize(body)
dispatch(method, request, action_args)

Dispatch a call to the action-specific method.

get_action_args(request_environment)

Parse dictionary created by routes library.

get_body(request)
get_method(request, action, content_type, body)
post_process_extensions(extensions, resp_obj, request, action_args)
pre_process_extensions(extensions, request, action_args)
register_actions(controller)

Registers controller actions with this resource.

register_extensions(controller)

Registers controller extensions with this resource.

support_api_request_version = False
class ResourceExceptionHandler

Bases: object

Context manager to handle Resource exceptions.

Used when processing exceptions generated by API implementation methods (or their extensions). Converts most exceptions to Fault exceptions, with the appropriate logging.

class ResourceV21(controller, inherits=None)

Bases: nova.api.openstack.wsgi.Resource

support_api_request_version = True
class ResponseObject(obj, code=None, headers=None)

Bases: object

Bundles a response object

Object that app methods may return in order to allow its response to be modified by extensions in the code. Its use is optional (and should only be used if you really know what you are doing).

code

Retrieve the response status.

headers

Retrieve the headers.

serialize(request, content_type)

Serializes the wrapped object.

Utility method for serializing the wrapped object. Returns a webob.Response object.

action(name)

Mark a function as an action.

The given name will be taken as the action key in the body.

This is also overloaded to allow extensions to provide non-extending definitions of create and delete operations.

action_peek(body)

Determine action to invoke.

This looks inside the json body and fetches out the action method name.

extends(*args, **kwargs)

Indicate a function extends an operation.

Can be used as either:

@extends
def index(...):
    pass

or as:

@extends(action='resize')
def _action_resize(...):
    pass
get_media_map()
get_supported_content_types()
item_get(item, item_key)
response(code)

Attaches response code to a method.

This decorator associates a response code with a method. Note that the function attributes are directly manipulated; the method is not wrapped.

Previous topic

The nova.api.openstack.versioned_method Module

Next topic

The nova.api.opts Module

Project Source

This Page