2.5. Manipulating Data and Objects

A big part of Arc is to allow easy and conviente access to the data about Jobs, Tests, Hosts and others on an Autotest RPC Server.

2.5.1. Base functions

Autotest RPC communication between client and server is based on the JSON RPC protocol. Because the protocol itself has no builtin tooling for creating stubs and skeletons, Arc makes use of some programming techiniques to compensate for that.

First, a series of functions that allow one to fetch, create, modify and delete data on the server (such as jobs and tests records) are created by specializing functions.

The arc.base module contains functions that are used py the Standard Python Library module functools to create versions of functions that operate on Jobs, Tests, Hosts, Labels, etc.

Module that has base functions to manipulate JSON data from RPC services

The functions defined here are usually not used directly, but specialized and simplified via functools.partial()

arc.base.get_by(service, method, field, connection, value=None)

Base function to fetch data from the RPC server using a single field filter

This is usually not used directly, but simplified via functools.partial()

arc.base.get_and_filter(function, field, connection, **data_filter)

Base function to fetch and filter data from the RPC server

This is usually not used directly, but simplified via functools.partial()

arc.base.delete(service, method, connection, identification)

Base function to delete an object from the RPC server

This is usually not used directly, but simplified via functools.partial()

class arc.base.Model(connection, identification=None, name=None)

Base class for modeling objects from the RPC server JSON data

get_data()

Fetch object data based on either id or name, as set on this object

load_data()

Loads this object’s data and flags if data was successfully fetched

2.5.2. Manipulating raw JSON data

The following functions manipulate JSON data directly. Some of these functions allow you to:

  • fetch only a subset of records
  • filter only some fields out of the returned records

But that is all the data massaging that will be done by their behalf.

arc.base.get_data_by_id(identification)

Get remote object data by its ID.

2.5.3. Manipulating objects

These methods return objects that wrap the data returned by the server.

arc.base.get_objs()

This function will return Host objects. By default, it will return object for all currently active Hosts on the Autotest RPC server, but it’s possible to specify a custom search filter through the :param data_filter.

This function is implemeted as a generator, so objects will be created and returned on demand.