ironic_inspector_client.v1 module

Client for V1 API.

class ironic_inspector_client.v1.ClientV1(**kwargs)[source]

Bases: ironic_inspector_client.common.http.BaseClient

Client for API v1.

Create this object to use Python API, for example:

import ironic_inspector_client
client = ironic_inspector_client.ClientV1(session=keystone_session)

This code creates a client with API version 1.0 and a given Keystone session. The service URL is fetched from the service catalog in this case. Optional arguments service_type, interface and region_name can be provided to modify how the URL is looked up.

If the catalog lookup fails, the local host with port 5050 is tried. However, this behaviour is deprecated and should not be relied on. Also an explicit inspector_url can be passed to bypass service catalog.

Optional api_version argument is a minimum API version that a server must support. It can be a tuple (MAJ, MIN), string “MAJ.MIN” or integer (only major, minimum supported minor version is assumed).

Variables

rules – Reference to the introspection rules API. Instance of ironic_inspector_client.v1.RulesAPI.

abort(node_id=None, uuid=None)[source]

Abort running introspection for a node.

Parameters
  • uuid – node UUID or name, deprecated

  • node_id – node node_id or name

Raises

ironic_inspector_client.ClientError on error reported from a server

Raises

ironic_inspector_client.VersionNotSupported if requested api_version is not supported

Raises

requests library exception on connection problems.

Raises

TypeError if uuid is not a string.

get_all_interface_data(node_ident, field_sel, vlan=None)[source]

Get interface data for all of the interfaces on this node

Parameters
  • node_ident – node UUID or name

  • field_sel – list of all fields for which to get data

  • vlan – list of vlans used to filter the lists returned

Returns

list of interface data, each interface in a list

get_data(node_id=None, raw=False, uuid=None, processed=True)[source]

Get introspection data from the last introspection of a node.

If swift support is disabled, introspection data won’t be stored, this request will return error response with 404 code.

Parameters
  • uuid – node UUID or name, deprecated

  • node_id – node node_id or name

  • raw – whether to return raw binary data or parsed JSON data

  • processed – whether to return the final processed data or the raw unprocessed data received from the ramdisk.

Returns

bytes or a dict depending on the ‘raw’ argument

Raises

ironic_inspector_client.ClientError on error reported from a server

Raises

ironic_inspector_client.VersionNotSupported if requested api_version is not supported

Raises

requests library exception on connection problems.

Raises

TypeError if uuid is not a string

get_interface_data(node_ident, interface, field_sel)[source]

Get interface data for the input node and interface

To get LLDP data, collection must be enabled by the kernel parameter ipa-collect-lldp=1, and the inspector plugin basic_lldp must be enabled.

Parameters
  • node_ident – node UUID or name

  • interface – interface name

  • field_sel – list of all fields for which to get data

Returns

interface data in OrderedDict

Raises

ValueError if interface is not found.

get_status(node_id=None, uuid=None)[source]

Get introspection status for a node.

Parameters
  • uuid – node UUID or name, deprecated

  • node_id – node node_id or name

Raises

ironic_inspector_client.ClientError on error reported from a server

Raises

ironic_inspector_client.VersionNotSupported if requested api_version is not supported

Raises

requests library exception on connection problems.

Returns

dictionary with the keys:

  • error an error string or None,

  • finished whether introspection was finished,

  • finished_at an ISO8601 timestamp or None,

  • links with a self-link URL,

  • started_at an ISO8601 timestamp,

  • uuid the node UUID

introspect(node_id=None, manage_boot=None, uuid=None)[source]

Start introspection for a node.

Parameters
  • uuid – node UUID or name, deprecated

  • node_id – node node_id or name

  • manage_boot – whether to manage boot during introspection of this node. If it is None (the default), then this argument is not passed to API and the server default is used instead.

Raises

ironic_inspector_client.ClientError on error reported from a server

Raises

ironic_inspector_client.VersionNotSupported if requested api_version is not supported

Raises

requests library exception on connection problems.

list_statuses(marker=None, limit=None)[source]

List introspection statuses.

Supports pagination via the marker and limit params. The items are sorted by the server according to the started_at attribute, newer items first.

Parameters
  • marker – pagination maker, UUID or None

  • limit – pagination limit, int or None

Raises

ironic_inspector_client.ClientError on error reported from a server

Raises

ironic_inspector_client.VersionNotSupported if requested api_version is not supported

Raises

requests library exception on connection problems.

Returns

a list of status dictionaries with the keys:

  • error an error string or None,

  • finished whether introspection was finished,

  • finished_at an ISO8601 timestamp or None,

  • links with a self-link URL,

  • started_at an ISO8601 timestamp,

  • uuid the node UUID

reprocess(node_id=None, uuid=None)[source]

Reprocess stored introspection data.

If swift support is disabled, introspection data won’t be stored, this request will return error response with 404 code.

Parameters
  • uuid – node UUID or name, deprecated

  • node_id – node node_id or name

Raises

ironic_inspector_client.ClientError on error reported from a server

Raises

ironic_inspector_client.VersionNotSupported if requested api_version is not supported

Raises

requests library exception on connection problems.

Raises

TypeError if uuid is not a string.

wait_for_finish(node_ids=None, retry_interval=10, max_retries=3600, sleep_function=<built-in function sleep>, uuids=None)[source]

Wait for introspection finishing for given nodes.

Parameters
  • uuids – collection of node UUIDs or names, deprecated

  • node_ids – collection of node node_ids or names

  • retry_interval – sleep interval between retries.

  • max_retries – maximum number of retries.

  • sleep_function – function used for sleeping between retries.

Raises

ironic_inspector_client.WaitTimeoutError on timeout

Raises

ironic_inspector_client.ClientError on error reported from a server

Raises

ironic_inspector_client.VersionNotSupported if requested api_version is not supported

Raises

requests library exception on connection problems.

Returns

dictionary UUID -> status (the same as in get_status).

ironic_inspector_client.v1.DEFAULT_API_VERSION = (1, 0)

Server API version used by default.

ironic_inspector_client.v1.DEFAULT_MAX_RETRIES = 3600

Default number of retries when waiting for introspection to finish.

ironic_inspector_client.v1.DEFAULT_RETRY_INTERVAL = 10

Default interval (in seconds) between retries when waiting for introspection to finish.

ironic_inspector_client.v1.MAX_API_VERSION = (1, 13)

Maximum API version this client was designed to work with.

This does not mean that other versions won’t work at all - the server might still support them.

class ironic_inspector_client.v1.RulesAPI(requester)[source]

Bases: object

Introspection rules API.

Do not create instances of this class directly, use ironic_inspector_client.v1.ClientV1.rules instead.

create(conditions, actions, uuid=None, description=None)[source]

Create a new introspection rule.

Parameters
  • conditions – list of rule conditions

  • actions – list of rule actions

  • uuid – rule UUID, will be generated if not specified

  • description – optional rule description

Returns

rule representation

Raises

ironic_inspector_client.ClientError on error reported from a server

Raises

ironic_inspector_client.VersionNotSupported if requested api_version is not supported

delete(uuid)[source]

Delete an introspection rule.

Parameters

uuid – rule UUID

Raises

ironic_inspector_client.ClientError on error reported from a server

Raises

ironic_inspector_client.VersionNotSupported if requested api_version is not supported

delete_all()[source]

Delete all introspection rules.

Raises

ironic_inspector_client.ClientError on error reported from a server

Raises

ironic_inspector_client.VersionNotSupported if requested api_version is not supported

from_json(json_rule)[source]

Import an introspection rule from JSON data.

Parameters

json_rule – rule information as a dict with keys matching arguments of RulesAPI.create().

Returns

rule representation

Raises

ironic_inspector_client.ClientError on error reported from a server

Raises

ironic_inspector_client.VersionNotSupported if requested api_version is not supported

get(uuid)[source]

Get detailed information about an introspection rule.

Parameters

uuid – rule UUID

Returns

rule representation

Raises

ironic_inspector_client.ClientError on error reported from a server

Raises

ironic_inspector_client.VersionNotSupported if requested api_version is not supported

get_all()[source]

List all introspection rules.

Returns

list of short rule representations (uuid, description and links)

Raises

ironic_inspector_client.ClientError on error reported from a server

Raises

ironic_inspector_client.VersionNotSupported if requested api_version is not supported

exception ironic_inspector_client.v1.WaitTimeoutError[source]

Bases: Exception

Timeout while waiting for nodes to finish introspection.