ironic_inspector.common.ironic module

exception ironic_inspector.common.ironic.NotFound(node_ident, code=404, *args, **kwargs)[source]

Bases: Error

Node not found in Ironic.

ironic_inspector.common.ironic.call_with_retries(func, *args, **kwargs)[source]

Call an ironic client function retrying all errors.

If an ironic client exception is raised, try calling the func again, at most 5 times, waiting 1 sec between each call. If on the 5th attempt the func raises again, the exception is propagated to the caller.


Convert the Node’s capabilities into a dictionary.


Sanity checks the provision state of the node.


node – An API client returned node object describing the baremetal node according to ironic’s node data model.


None if no action is to be taken, True if the power node state should not be modified.


Error on an invalid state being detected.


Convert a dictionary into a string with the capabilities syntax.


Get an ironic client connection.


Get the BMC address defined in node.driver_info dictionary

Possible names of BMC address value examined in order of list [‘ipmi_address’] + CONF.ipmi_address_fields. The value could be an IP address or a hostname. DNS lookup performed for the first non empty value.

The first valid BMC address value returned along with it’s v4 and v6 IP addresses.


node – Node object with defined driver_info dictionary


tuple (ipmi_address, ipv4_address, ipv6_address)

ironic_inspector.common.ironic.get_node(node_id, ironic=None, **kwargs)[source]

Get a node from Ironic.

  • node_id – node UUID or name.

  • ironic – ironic client instance.

  • kwargs – arguments to pass to Ironic client.


Error on failure

ironic_inspector.common.ironic.lookup_node(macs=None, bmc_addresses=None, introspection_data=None, ironic=None)[source]

Lookup a node in the ironic database.

ironic_inspector.common.ironic.lookup_node_by_bmc_addresses(addresses, introspection_data=None, ironic=None, fail=False)[source]

Find a node by its BMC address.

ironic_inspector.common.ironic.lookup_node_by_macs(macs, introspection_data=None, ironic=None, fail=False)[source]

Find a node by its MACs.


Reset the global session variable.

Mostly useful for unit tests.