The ironic_inspector.plugins.rules Module

Standard plugins for rules API.

class ironic_inspector.plugins.rules.AddTraitAction[source]

Bases: ironic_inspector.plugins.base.RuleActionPlugin

REQUIRED_PARAMS = {'name'}
apply(node_info, params, **kwargs)[source]

Run action on successful rule match.

Parameters
  • node_info – NodeInfo object

  • params – parameters as a dictionary

  • kwargs – used for extensibility without breaking existing plugins

Raises

utils.Error on failure

class ironic_inspector.plugins.rules.ContainsCondition[source]

Bases: ironic_inspector.plugins.rules.ReCondition

check(node_info, field, params, **kwargs)[source]

Check if condition holds for a given field.

Parameters
  • node_info – NodeInfo object

  • field – field value

  • params – parameters as a dictionary, changing it here will change what will be stored in database

  • kwargs – used for extensibility without breaking existing plugins

Raises

ValueError – on unacceptable field value

Returns

True if check succeeded, otherwise False

class ironic_inspector.plugins.rules.EmptyCondition[source]

Bases: ironic_inspector.plugins.base.RuleConditionPlugin

ALLOW_NONE = True
REQUIRED_PARAMS = {}
check(node_info, field, params, **kwargs)[source]

Check if condition holds for a given field.

Parameters
  • node_info – NodeInfo object

  • field – field value

  • params – parameters as a dictionary, changing it here will change what will be stored in database

  • kwargs – used for extensibility without breaking existing plugins

Raises

ValueError – on unacceptable field value

Returns

True if check succeeded, otherwise False

class ironic_inspector.plugins.rules.EqCondition[source]

Bases: ironic_inspector.plugins.rules.SimpleCondition

op()

eq(a, b) – Same as a==b.

class ironic_inspector.plugins.rules.ExtendAttributeAction[source]

Bases: ironic_inspector.plugins.base.RuleActionPlugin

FORMATTED_PARAMS = ['value']
OPTIONAL_PARAMS = {'unique'}
REQUIRED_PARAMS = {'path', 'value'}
apply(node_info, params, **kwargs)[source]

Run action on successful rule match.

Parameters
  • node_info – NodeInfo object

  • params – parameters as a dictionary

  • kwargs – used for extensibility without breaking existing plugins

Raises

utils.Error on failure

class ironic_inspector.plugins.rules.FailAction[source]

Bases: ironic_inspector.plugins.base.RuleActionPlugin

REQUIRED_PARAMS = {'message'}
apply(node_info, params, **kwargs)[source]

Run action on successful rule match.

Parameters
  • node_info – NodeInfo object

  • params – parameters as a dictionary

  • kwargs – used for extensibility without breaking existing plugins

Raises

utils.Error on failure

class ironic_inspector.plugins.rules.GeCondition[source]

Bases: ironic_inspector.plugins.rules.SimpleCondition

op()

ge(a, b) – Same as a>=b.

class ironic_inspector.plugins.rules.GtCondition[source]

Bases: ironic_inspector.plugins.rules.SimpleCondition

op()

gt(a, b) – Same as a>b.

class ironic_inspector.plugins.rules.LeCondition[source]

Bases: ironic_inspector.plugins.rules.SimpleCondition

op()

le(a, b) – Same as a<=b.

class ironic_inspector.plugins.rules.LtCondition[source]

Bases: ironic_inspector.plugins.rules.SimpleCondition

op()

lt(a, b) – Same as a<b.

class ironic_inspector.plugins.rules.MatchesCondition[source]

Bases: ironic_inspector.plugins.rules.ReCondition

check(node_info, field, params, **kwargs)[source]

Check if condition holds for a given field.

Parameters
  • node_info – NodeInfo object

  • field – field value

  • params – parameters as a dictionary, changing it here will change what will be stored in database

  • kwargs – used for extensibility without breaking existing plugins

Raises

ValueError – on unacceptable field value

Returns

True if check succeeded, otherwise False

class ironic_inspector.plugins.rules.NeCondition[source]

Bases: ironic_inspector.plugins.rules.SimpleCondition

op()

ne(a, b) – Same as a!=b.

class ironic_inspector.plugins.rules.NetCondition[source]

Bases: ironic_inspector.plugins.base.RuleConditionPlugin

check(node_info, field, params, **kwargs)[source]

Check if condition holds for a given field.

Parameters
  • node_info – NodeInfo object

  • field – field value

  • params – parameters as a dictionary, changing it here will change what will be stored in database

  • kwargs – used for extensibility without breaking existing plugins

Raises

ValueError – on unacceptable field value

Returns

True if check succeeded, otherwise False

validate(params, **kwargs)[source]

Validate params passed during creation.

Default implementation checks for presence of fields from REQUIRED_PARAMS and fails for unexpected fields (not from REQUIRED_PARAMS + OPTIONAL_PARAMS).

Parameters
  • params – params as a dictionary

  • kwargs – used for extensibility without breaking existing plugins

Raises

ValueError on validation failure

class ironic_inspector.plugins.rules.ReCondition[source]

Bases: ironic_inspector.plugins.base.RuleConditionPlugin

validate(params, **kwargs)[source]

Validate params passed during creation.

Default implementation checks for presence of fields from REQUIRED_PARAMS and fails for unexpected fields (not from REQUIRED_PARAMS + OPTIONAL_PARAMS).

Parameters
  • params – params as a dictionary

  • kwargs – used for extensibility without breaking existing plugins

Raises

ValueError on validation failure

class ironic_inspector.plugins.rules.RemoveTraitAction[source]

Bases: ironic_inspector.plugins.base.RuleActionPlugin

REQUIRED_PARAMS = {'name'}
apply(node_info, params, **kwargs)[source]

Run action on successful rule match.

Parameters
  • node_info – NodeInfo object

  • params – parameters as a dictionary

  • kwargs – used for extensibility without breaking existing plugins

Raises

utils.Error on failure

class ironic_inspector.plugins.rules.SetAttributeAction[source]

Bases: ironic_inspector.plugins.base.RuleActionPlugin

FORMATTED_PARAMS = ['value']
OPTIONAL_PARAMS = {'reset_interfaces', 'value'}
REQUIRED_PARAMS = {'path'}
apply(node_info, params, **kwargs)[source]

Run action on successful rule match.

Parameters
  • node_info – NodeInfo object

  • params – parameters as a dictionary

  • kwargs – used for extensibility without breaking existing plugins

Raises

utils.Error on failure

validate(params, **kwargs)[source]

Validate params passed during creation.

Default implementation checks for presence of fields from REQUIRED_PARAMS and fails for unexpected fields (not from REQUIRED_PARAMS + OPTIONAL_PARAMS).

Parameters
  • params – params as a dictionary

  • kwargs – used for extensibility without breaking existing plugins

Raises

ValueError on validation failure

class ironic_inspector.plugins.rules.SetCapabilityAction[source]

Bases: ironic_inspector.plugins.base.RuleActionPlugin

FORMATTED_PARAMS = ['value']
OPTIONAL_PARAMS = {'value'}
REQUIRED_PARAMS = {'name'}
apply(node_info, params, **kwargs)[source]

Run action on successful rule match.

Parameters
  • node_info – NodeInfo object

  • params – parameters as a dictionary

  • kwargs – used for extensibility without breaking existing plugins

Raises

utils.Error on failure

class ironic_inspector.plugins.rules.SimpleCondition[source]

Bases: ironic_inspector.plugins.base.RuleConditionPlugin

check(node_info, field, params, **kwargs)[source]

Check if condition holds for a given field.

Parameters
  • node_info – NodeInfo object

  • field – field value

  • params – parameters as a dictionary, changing it here will change what will be stored in database

  • kwargs – used for extensibility without breaking existing plugins

Raises

ValueError – on unacceptable field value

Returns

True if check succeeded, otherwise False

op = None
ironic_inspector.plugins.rules.coerce(value, expected)[source]