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.

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.

class DictSerializer

Bases: nova.api.openstack.wsgi.ActionDispatcher

Default request body serialization.

default(data)
serialize(data, action='default')
exception Fault(exception)

Bases: webob.exc.HTTPException

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

class JSONDeserializer

Bases: nova.api.openstack.wsgi.TextDeserializer

default(datastring)
class JSONDictSerializer

Bases: nova.api.openstack.wsgi.DictSerializer

Default JSON request body serialization.

default(data)
class MetadataXMLDeserializer(metadata=None)

Bases: nova.api.openstack.wsgi.XMLDeserializer

extract_metadata(metadata_node)

Marshal the metadata attribute of a parsed request.

exception OverLimitFault(message, details, retry_time)

Bases: webob.exc.HTTPException

Rate-limited request response.

class Request(*args, **kwargs)

Bases: webob.request.Request

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

best_match_content_type()

Determine the requested response content-type.

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_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.

class Resource(controller, action_peek=None, inherits=None, **deserializers)

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(meth, content_type, 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.

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 ResponseObject(obj, code=None, headers=None, **serializers)

Bases: object

Bundles a response object with appropriate serializers.

Object that app methods may return in order to bind alternate serializers with a response object to be serialized. Its use is optional.

attach(**kwargs)

Attach slave templates to serializers.

code

Retrieve the response status.

get_serializer(content_type, default_serializers=None)

Returns the serializer for the wrapped object.

Returns the serializer for the wrapped object subject to the indicated content type. If no serializer matching the content type is attached, an appropriate serializer drawn from the default serializers will be used. If no appropriate serializer is available, raises InvalidContentType.

headers

Retrieve the headers.

preserialize(content_type, default_serializers=None)

Prepares the serializer that will be used to serialize.

Determines the serializer that will be used and prepares an instance of it for later call. This allows the serializer to be accessed by extensions for, e.g., template extension.

serialize(request, content_type, default_serializers=None)

Serializes the wrapped object.

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

class TextDeserializer

Bases: nova.api.openstack.wsgi.ActionDispatcher

Default request body deserialization.

default(datastring)
deserialize(datastring, action='default')
class XMLDeserializer(metadata=None)

Bases: nova.api.openstack.wsgi.TextDeserializer

default(datastring)
extract_elements(node)

Get only Element type childs from node.

extract_text(node)

Get the text field contained by the given node.

find_attribute_or_element(parent, name)

Get an attribute value; fallback to an element if not found.

find_children_named(parent, name)

Return all of a nodes children who have the given name.

find_first_child_named(parent, name)

Search a nodes children for the first child with a given name.

find_first_child_named_in_namespace(parent, namespace, name)

Search a nodes children for the first child with a given name.

class XMLDictSerializer(metadata=None, xmlns=None)

Bases: nova.api.openstack.wsgi.DictSerializer

default(data)
to_xml_string(node, has_atom=False)
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_json(body)

Determine action to invoke.

action_peek_xml(body)

Determine action to invoke.

deserializers(**deserializers)

Attaches deserializers to a method.

This decorator associates a dictionary of deserializers with a method. Note that the function attributes are directly manipulated; the method is not wrapped.

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
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.

serializers(**serializers)

Attaches serializers to a method.

This decorator associates a dictionary of serializers with a method. Note that the function attributes are directly manipulated; the method is not wrapped.

Previous topic

The nova.api.openstack.urlmap Module

Next topic

The nova.api.openstack.xmlutil Module

This Page