The ironic_inspector.plugins.base Module

Base code for plugins support.

class ironic_inspector.plugins.base.ProcessingHook[source]

Bases: object

Abstract base class for introspection data processing hooks.

before_processing(introspection_data, **kwargs)[source]

Hook to run before any other data processing.

This hook is run even before sanity checks.

Parameters:
  • introspection_data – raw information sent by the ramdisk, may be modified by the hook.
  • kwargs – used for extensibility without breaking existing hooks
Returns:

nothing.

before_update(introspection_data, node_info, **kwargs)[source]

Hook to run before Ironic node update.

This hook is run after node is found and ports are created, just before the node is updated with the data.

Parameters:
  • introspection_data – processed data from the ramdisk.
  • node_info – NodeInfo instance.
  • kwargs – used for extensibility without breaking existing hooks.
Returns:

nothing.

[RFC 6902] - http://tools.ietf.org/html/rfc6902

dependencies = []

An ordered list of hooks that must be enabled before this one.

The items here should be entry point names, not classes.

class ironic_inspector.plugins.base.RuleActionPlugin[source]

Bases: ironic_inspector.plugins.base.WithValidation

Abstract base class for rule action plugins.

FORMATTED_PARAMS = []

List of params will be formatted with python format.

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.base.RuleConditionPlugin[source]

Bases: ironic_inspector.plugins.base.WithValidation

Abstract base class for rule condition plugins.

ALLOW_NONE = False

Whether this condition accepts None when field is not found.

REQUIRED_PARAMS = set([‘value’])
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.base.WithValidation[source]

Bases: object

OPTIONAL_PARAMS = set([])

Set with names of optional parameters.

REQUIRED_PARAMS = set([])

Set with names of required parameters.

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

ironic_inspector.plugins.base.missing_entrypoints_callback(names)[source]

Raise MissingHookError with comma-separated list of missing hooks

ironic_inspector.plugins.base.node_not_found_hook_manager(*args)[source]
ironic_inspector.plugins.base.processing_hooks_manager(*args)[source]

Create a Stevedore extension manager for processing hooks.

Parameters:args – arguments to pass to the hooks constructor.
ironic_inspector.plugins.base.rule_actions_manager()[source]

Create a Stevedore extension manager for actions in rules.

ironic_inspector.plugins.base.rule_conditions_manager()[source]

Create a Stevedore extension manager for conditions in rules.

ironic_inspector.plugins.base.validate_processing_hooks()[source]

Validate the enabled processing hooks.

Raises:MissingHookError on missing or failed to load hooks
Raises:RuntimeError on validation failure
Returns:the list of hooks passed validation