2.3. connection — Connecting to an Autotest RPC Server

The connection module provides the means to actually talk to the services hosted on an Autotest Server.

2.3.1. Default Connection

Most users of the connection module will only be interested in the AFE service, and also will only be interested in getting a connection to it that is:

  • Ready to use
  • Global
  • Respect default settings

For those users, the arc.connection.get_default() does just that:

arc.connection.get_default()

Returns the global, default connection to an AFE service

Returns:an arc.connection.Connection instance

2.3.2. BaseConnection

class arc.connection.BaseConnection(hostname=None, port=None, path=None)

Base RPC connection

Initializes a connection to an empty path

This empty path does not exist on a default Autotest server

add_service(name, path)

Add a service to a connection

Parameters:
  • name – a descriptive name to the service
  • path – the path in the URI that hosts the service
check_min_rpc_interface_version(service_name)

Checks the minimum required RPC interface version

Parameters:service_name – the registered name of the service
ping()

Tests connectivity to the RPC server

run(service, operation, *args, **data)

Runs a method using the rpc proxy

This method is heavily used by upper level API methods, and more often than not, those upper level API methods should be used instead.

Parameters:
  • operation – the name of the RPC method on the Autotest server
  • args – positional arguments to be passed to the RPC method
  • data – keyword arguments to be passed to the RPC method

2.3.3. Connection

This is the class that actually powers the connection return by arc.connection.get_default().

class arc.connection.Connection(hostname=None, port=None)

The default connection that allows access to both AFE and TKO services

Parameters:
  • hostname – the IP address or hostname of the server that will be contacted upon RPC method execution.
  • port – the port number where the RPC server is running

By default, instances of this classes register access to both the AFE and TKO serviceces (by means of running arc.connection.BaseConnection.add_service()).