ironic_inspector.rules module

Support for introspection rules.

class ironic_inspector.rules.IntrospectionRule(uuid, conditions, actions, description, scope=None)[source]

Bases: object

High-level class representing an introspection rule.

apply_actions(node_info, data=None)[source]

Run actions on a node.

Parameters:
  • node_info – NodeInfo instance

  • data – introspection data

as_dict(short=False)[source]
check_conditions(node_info, data)[source]

Check if conditions are true for a given node.

Parameters:
  • node_info – a NodeInfo object

  • data – introspection data

Returns:

True if conditions match, otherwise False

check_scope(node_info)[source]

Check if node’s scope falls under rule._scope and rule is applicable

Parameters:

node_info – a NodeInfo object

Returns:

True if conditions match, otherwise False

property description
ironic_inspector.rules.actions_schema()[source]
ironic_inspector.rules.apply(node_info, data)[source]

Apply rules to a node.

ironic_inspector.rules.conditions_schema()[source]
ironic_inspector.rules.create(conditions_json, actions_json, uuid=None, description=None, scope=None)[source]

Create a new rule in database.

Parameters:
  • conditions_json – list of dicts with the following keys: * op - operator * field - JSON path to field to compare Other keys are stored as is.

  • actions_json – list of dicts with the following keys: * action - action type Other keys are stored as is.

  • uuid – rule UUID, will be generated if empty

  • description – human-readable rule description

  • scope – if scope on node and rule matches, rule applies; if its empty, rule applies to all nodes.

Returns:

new IntrospectionRule object

Raises:

utils.Error on failure

ironic_inspector.rules.delete(uuid)[source]

Delete a rule by its UUID.

ironic_inspector.rules.delete_all()[source]

Delete all rules.

ironic_inspector.rules.get(uuid)[source]

Get a rule by its UUID.

ironic_inspector.rules.get_all()[source]

List all rules.