ironic.conductor.periodics module

Conductor periodics.

exception ironic.conductor.periodics.Stop[source]

Bases: Exception

A signal to stop the current iteration of a periodic task.

ironic.conductor.periodics.node_periodic(purpose, spacing, enabled=True, filters=None, predicate=None, predicate_extra_fields=(), limit=None, shared_task=True, node_count_metric_name=None)[source]

A decorator to define a periodic task to act on nodes.

Defines a periodic task that fetches the list of nodes mapped to the current conductor which satisfy the provided filters.

The decorated function must be a method on either the conductor manager or a hardware interface. The signature is:

  • for conductor manager: (self, task, context)

  • for hardware interfaces: (self, task, manager, context).

When the periodic is running on a hardware interface, only tasks using this interface are considered.

NodeNotFound and NodeLocked exceptions are ignored. Raise Stop to abort the current iteration of the task and reschedule it.

Parameters:
  • purpose – a human-readable description of the activity, e.g. “verifying that the cat is purring”.

  • spacing – how often (in seconds) to run the periodic task.

  • enabled – whether the task is enabled; defaults to spacing > 0.

  • filters – database-level filters for the nodes.

  • predicate – a callable to run on the fetched nodes before creating a task for them. The only parameter will be a named tuple with fields uuid, driver, conductor_group plus everything from predicate_extra_fields. If the callable accepts a 2nd parameter, it will be the conductor manager instance.

  • predicate_extra_fields – extra fields to fetch on the initial request and pass into the predicate. Must not contain uuid, driver and conductor_group since they are always included.

  • limit – how many nodes to process before stopping the current iteration. If predicate returns False, the node is not counted. If the decorated function returns False, the node is not counted either. Can be a callable, in which case it will be called on each iteration to determine the limit.

  • shared_task – if True, the task will have a shared lock. It is recommended to start with a shared lock and upgrade it only if needed.

  • node_count_metric_name – A string value to identify a metric representing the count of matching nodes to be recorded upon the completion of the periodic.

ironic.conductor.periodics.periodic(spacing, enabled=True, **kwargs)[source]

A decorator to define a periodic task.

Parameters:
  • spacing – how often (in seconds) to run the periodic task.

  • enabled – whether the task is enabled; defaults to spacing > 0.