This Page

Psst... hey. You're reading the latest content, but it might be out of sync with code. You can read Nova 2011.2 docs or all OpenStack docs too.

The nova.api.openstack.wsgi Module

class nova.api.openstack.wsgi.ActionDispatcher

Bases: object

Maps method name to local methods through action name.

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

Find and call local method.

class nova.api.openstack.wsgi.DictSerializer

Bases: nova.api.openstack.wsgi.ActionDispatcher

Default request body serialization

default(data)
serialize(data, action='default')
class nova.api.openstack.wsgi.JSONDeserializer

Bases: nova.api.openstack.wsgi.TextDeserializer

default(datastring)
class nova.api.openstack.wsgi.JSONDictSerializer

Bases: nova.api.openstack.wsgi.DictSerializer

Default JSON request body serialization

default(data)
class nova.api.openstack.wsgi.MetadataXMLDeserializer(metadata=None)

Bases: nova.api.openstack.wsgi.XMLDeserializer

extract_metadata(metadata_node)

Marshal the metadata attribute of a parsed request

class nova.api.openstack.wsgi.Request(environ, charset=(No Default), unicode_errors=(No Default), decode_param_names=(No Default), **kw)

Bases: webob.request.Request

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

best_match_content_type(supported_content_types=None)

Determine the requested response content-type.

Based on the query extension then the Accept header.

get_content_type()

Determine content type of the request body.

Does not do any body introspection, only checks header

class nova.api.openstack.wsgi.RequestDeserializer(body_deserializers=None, headers_deserializer=None, supported_content_types=None)

Bases: object

Break up a Request object into more useful pieces.

deserialize(request)

Extract necessary pieces of the request.

Parameters:request – Request object
:returns tuple of expected controller action name, dictionary of
keyword arguments to pass to the controller, the expected content type of the response
deserialize_body(request, action)
deserialize_headers(request, action)
get_action_args(request_environment)

Parse dictionary created by routes library.

get_body_deserializer(content_type)
get_expected_content_type(request)
class nova.api.openstack.wsgi.RequestHeadersDeserializer

Bases: nova.api.openstack.wsgi.ActionDispatcher

Default request headers deserializer

default(request)
deserialize(request, action)
class nova.api.openstack.wsgi.Resource(controller, deserializer=None, serializer=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.

dispatch(request, action, action_args)

Find action-spefic method on controller and call it.

class nova.api.openstack.wsgi.ResponseHeadersSerializer

Bases: nova.api.openstack.wsgi.ActionDispatcher

Default response headers serialization

default(response, data)
serialize(response, data, action)
class nova.api.openstack.wsgi.ResponseSerializer(body_serializers=None, headers_serializer=None)

Bases: object

Encode the necessary pieces into a response object

get_body_serializer(content_type)
serialize(response_data, content_type, action='default')

Serialize a dict into a string and wrap in a wsgi.Request object.

Parameters:
  • response_data – dict produced by the Controller
  • content_type – expected mimetype of serialized response body
serialize_body(response, data, content_type, action)
serialize_headers(response, data, action)
class nova.api.openstack.wsgi.TextDeserializer

Bases: nova.api.openstack.wsgi.ActionDispatcher

Default request body deserialization

default(datastring)
deserialize(datastring, action='default')
class nova.api.openstack.wsgi.XMLDeserializer(metadata=None)

Bases: nova.api.openstack.wsgi.TextDeserializer

default(datastring)
extract_text(node)

Get the text field contained by the given node

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

class nova.api.openstack.wsgi.XMLDictSerializer(metadata=None, xmlns=None)

Bases: nova.api.openstack.wsgi.DictSerializer

default(data)
to_xml_string(node, has_atom=False)