glance.common.rpc module

RPC Controller

class glance.common.rpc.Controller(raise_exc=False)[source]

Bases: object

Base RPCController.

This is the base controller for RPC based APIs. Commands handled by this controller respect the following form:

[{
    'command': 'method_name',
    'kwargs': {...}
}]

The controller is capable of processing more than one command per request and will always return a list of results.

Parameters

raise_exc (bool) – Specifies whether to raise exceptions instead of “serializing” them.

register(resource, filtered=None, excluded=None, refiner=None)[source]

Exports methods through the RPC Api.

Parameters
  • resource – Resource’s instance to register.

  • filtered – List of methods that can be registered. Read as “Method must be in this list”.

  • excluded – List of methods to exclude.

  • refiner – Callable to use as filter for methods.

Raises

TypeError – If refiner is not callable.

class glance.common.rpc.RPCClient(*args, **kwargs)[source]

Bases: glance.common.client.BaseClient

bulk_request(commands)[source]

Execute multiple commands in a single request.

Parameters

commands – List of commands to send. Commands must respect the following form

{
    'command': 'method_name',
    'kwargs': method_kwargs
}
do_request(method, **kwargs)[source]

Simple do_request override. This method serializes the outgoing body and builds the command that will be sent.

Parameters
  • method – The remote python method to call

  • kwargs – Dynamic parameters that will be passed to the remote method.

class glance.common.rpc.RPCJSONDeserializer[source]

Bases: glance.common.wsgi.JSONRequestDeserializer

class glance.common.rpc.RPCJSONSerializer[source]

Bases: glance.common.wsgi.JSONResponseSerializer