rpc Package

rpc Package

http_provider Module

Http protocol rpc provider

class vmware.vapi.protocol.client.rpc.http_provider.GzipReader(rfile, encoding=1, read_chunk_size=512)[source]

Bases: object

Gzip reader

Gzip reader init

Parameters:
  • rfile (file) – file object to read from
  • encoding (int (GzipReader.GZIP or GzipReader.DEFLATE)) – Zip stream encoding enum
  • read_chunk_size (int) – Read chunk size
DEFLATE = 2
GZIP = 1
read(num_bytes=-1)[source]
Parameters:num_bytes (int) – Number of decompressed bytes to read
Return type:bytes
Returns:Decompressed data (len up to num_bytes)
class vmware.vapi.protocol.client.rpc.http_provider.HttpRpcProvider(ssl_args, url)[source]

Bases: vmware.vapi.protocol.client.rpc.provider.RpcProvider

http rpc provider

http rpc provider init

Parameters:
  • ssl_args (dict) – ssl arguments
  • url (str) – url to connected to
connect()[source]
Return type:vmware.vapi.protocol.client.rpc.provider.RpcProvider
Returns:http rpc provider
static disable_nagle(conn)[source]

disable nagle algorithm for a connection

Parameters:conn (http_client.HTTPConnection) – http connection
disconnect()[source]
do_request(request_ctx, request)[source]

Do rpc request

Parameters:
Return type:

tuple of (dict of str, str), str

Returns:

Tuple of (response_ctx, response_body) where response_ctx: Response context dictionary. The valid key/value pairs are:

response: The response body

static is_connection_dropped(conn)[source]

Returns True if the connection is dropped and should be closed.

Parameters:conn (http_client.HTTPConnection) – HTTP connection object
Return type:bool
Returns:True if the connection is dropped, False otherwise
class vmware.vapi.protocol.client.rpc.http_provider.HttpsConnection(*args, **kwargs)[source]

Bases: httplib.HTTPSConnection

Internal version of https connection

Internal version of https connection init

Parameters:
  • args (tuple) – position parameters to http_client.HTTPSConnection
  • kwargs (dict) – key parameters to http_client.HTTPSConnection
connect()[source]
class vmware.vapi.protocol.client.rpc.http_provider.UnixSocketConnection(path)[source]

Bases: httplib.HTTPConnection

Variant of http_client.HTTPConnection that supports HTTP connections over Unix domain sockets.

Initialize a Unix domain socket HTTP connection

The HTTPConnection __init__ method expects a single argument, which it interprets as the host to connect to. For this class, we instead interpret the parameter as the filesystem path of the Unix domain socket.

Parameters:path (str) – Unix domain socket path
connect()[source]

Override the HTTPConnection connect method to connect to a Unix domain socket. Obey the same contract as HTTPConnection.connect which puts the socket in self.sock.

vmware.vapi.protocol.client.rpc.http_provider.patch_http_response_read(func)[source]

Wrapper function to patch the http read method to return the partial data when the server doesn’t send a zero length chunk

provider Module

rpc provider interface

class vmware.vapi.protocol.client.rpc.provider.RpcProvider[source]

Bases: object

Rpc provider interface

Rpc provider interface init

connect()[source]
Return type:vmware.vapi.protocol.client.rpc.provider.RpcProvider
Returns:a rpc provider
disconnect()[source]
do_request(request_ctx, request)[source]

Do rpc request

Parameters:
Return type:

tuple of (dict of str, str), str

Returns:

Tuple of (response_ctx, response_body) where response_ctx: Response context dictionary. The valid key/value pairs are:

response: The response body

provider_factory Module

rpc provider factory

class vmware.vapi.protocol.client.rpc.provider_factory.RpcProviderFactory[source]

Bases: object

Rpc provider factory

Rpc provider factory init

get_rpc_provider(rpc_provider_name, *args, **kwargs)[source]

Create rpc provider

Parameters:
  • rpc_provider_name
  • args (tuple) – position parameters to rpc provider constructor
  • kwargs (dict) – key parameters to rpc provider constructor
Return type:

vmware.vapi.protocol.client.rpc.provider.RpcProvider

Returns:

Rpc provider object

requests_provider Module

RPC Provider using Requests Library

class vmware.vapi.protocol.client.rpc.requests_provider.RequestsRpcProvider(session, url, timeout, pool_size)[source]

Bases: vmware.vapi.protocol.client.rpc.provider.RpcProvider

vAPI RPC provider using requests library

Initialize RequestsRpcProvider

Parameters:
  • session (requests.Session) – Session object
  • msg_protocol (str) – Message protocol to be used for the connection. Valid values are ‘json’.
  • url (str) – HTTP(S) URL to be used
  • timeout (int) – Request timeout
  • pool_size (int) – Connection pool size to be used
connect()[source]
Return type:vmware.vapi.protocol.client.rpc.provider.RpcProvider
Returns:http rpc provider
disconnect()[source]
do_request(request_ctx, request)[source]

Do rpc request

Parameters:
Return type:

tuple of (dict of str, str), str

Returns:

Tuple of (response_ctx, response_body) where response_ctx: Response context dictionary. The valid key/value pairs are:

response: The response body

Table Of Contents

Previous topic

msg Package

Next topic

common Package

This Page