The ironic_inspector_client.v1 Module

The 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(uuid)[source]

Abort running introspection for a node.

Parameters:uuid – node UUID or name.
Raises:ClientError on error reported from a server
Raises: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(uuid, raw=False)[source]

Get introspection data from the last introspection of a node.

Parameters:
  • uuid – node UUID or name.
  • raw – whether to return raw binary data or parsed JSON data
Returns:

bytes or a dict depending on the ‘raw’ argument

Raises:

ClientError on error reported from a server

Raises:

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(uuid)[source]

Get introspection status for a node.

Parameters:uuid – node UUID or name.
Raises:ClientError on error reported from a server
Raises: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(uuid)[source]

Start introspection for a node.

Parameters:uuid – node UUID or name
Raises:ClientError on error reported from a server
Raises: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:

ClientError on error reported from a server

Raises:

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(uuid)[source]

Reprocess stored introspection data.

Parameters:uuid – node UUID or name.
Raises:ClientError on error reported from a server
Raises: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(uuids, retry_interval=10, max_retries=3600, sleep_function=<built-in function sleep>)[source]

Wait for introspection finishing for given nodes.

Parameters:
  • uuids – collection of node UUIDs or names.
  • retry_interval – sleep interval between retries.
  • max_retries – maximum number of retries.
  • sleep_function – function used for sleeping between retries.
Raises:

WaitTimeoutError on timeout

Raises:

ClientError on error reported from a server

Raises:

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, 8)

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:

ClientError on error reported from a server

Raises:

VersionNotSupported if requested api_version is not supported

delete(uuid)[source]

Delete an introspection rule.

Parameters:uuid – rule UUID
Raises:ClientError on error reported from a server
Raises:VersionNotSupported if requested api_version is not supported
delete_all()[source]

Delete all introspection rules.

Raises:ClientError on error reported from a server
Raises: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:ClientError on error reported from a server
Raises: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:ClientError on error reported from a server
Raises: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:ClientError on error reported from a server
Raises:VersionNotSupported if requested api_version is not supported
exception ironic_inspector_client.v1.WaitTimeoutError[source]

Bases: exceptions.Exception

Timeout while waiting for nodes to finish introspection.

Creative Commons Attribution 3.0 License

Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.