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.

ironic_inspector.common.ironic.capabilities_to_dict(caps)[source]

Convert the Node’s capabilities into a dictionary.

ironic_inspector.common.ironic.check_provision_state(node)[source]

Sanity checks the provision state of the node.

Parameters:

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

Returns:

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

Raises:

Error on an invalid state being detected.

ironic_inspector.common.ironic.dict_to_capabilities(caps_dict)[source]

Convert a dictionary into a string with the capabilities syntax.

ironic_inspector.common.ironic.get_client(token=None)[source]

Get an ironic client connection.

ironic_inspector.common.ironic.get_ipmi_address(node)[source]

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.

Parameters:

node – Node object with defined driver_info dictionary

Returns:

tuple (ipmi_address, ipv4_address, ipv6_address)

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

Get a node from Ironic.

Parameters:
  • node_id – node UUID or name.

  • ironic – ironic client instance.

  • kwargs – arguments to pass to Ironic client.

Raises:

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.

ironic_inspector.common.ironic.reset_ironic_session()[source]

Reset the global session variable.

Mostly useful for unit tests.