libcloud.common.xmlrpc module

Base classes for working with xmlrpc APIs

class libcloud.common.xmlrpc.ErrorCodeMixin[source]

Bases: object

This is a helper for API’s that have a well defined collection of error codes that are easily parsed out of error messages. It acts as a factory: it finds the right exception for the error code, fetches any parameters it needs from the context and raises it.

exceptions: Dict[str, Type[LibcloudError]] = {}
raise_exception_for_error(error_code, message)[source]
exception libcloud.common.xmlrpc.ProtocolError[source]

Bases: Exception

class libcloud.common.xmlrpc.XMLRPCConnection(secure=True, host=None, port=None, url=None, timeout=None, proxy_url=None, retry_delay=None, backoff=None)[source]

Bases: Connection

Connection class which can call XMLRPC based API’s.

This class uses the xmlrpclib marshalling and demarshalling code but uses the http transports provided by libcloud giving it better certificate validation and debugging helpers than the core client library.

add_default_headers(headers)[source]

Adds default headers (such as Authorization, X-Foo-Bar) to the passed headers

Should return a dictionary.

endpoint: str = None
request(method_name, *args, **kwargs)[source]

Call a given method_name.

Parameters:
  • method_name (str) – A method exposed by the xmlrpc endpoint that you are connecting to.

  • args (tuple) – Arguments to invoke with method with.

responseCls

alias of XMLRPCResponse

class libcloud.common.xmlrpc.XMLRPCResponse(response, connection)[source]

Bases: ErrorCodeMixin, Response

Parameters:
  • response (httplib.HTTPResponse) – HTTP response object. (optional)

  • connection (Connection) – Parent connection object.

defaultExceptionCls

alias of Exception

parse_body()[source]

Parse response body.

Override in a provider’s subclass.

Returns:

Parsed body.

Return type:

str

parse_error()[source]

Parse the error messages.

Override in a provider’s subclass.

Returns:

Parsed error.

Return type:

str

success()[source]

Determine if our request was successful.

The meaning of this can be arbitrary; did we receive OK status? Did the node get created? Were we authenticated?

Return type:

bool

Returns:

True or False