ironic.conductor.periodics module¶
Conductor periodics.
- exception ironic.conductor.periodics.Stop[source]¶
Bases:
ExceptionA 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.
NodeNotFoundandNodeLockedexceptions are ignored. RaiseStopto 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_groupplus everything frompredicate_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 containuuid,driverandconductor_groupsince they are always included.limit – how many nodes to process before stopping the current iteration. If
predicatereturnsFalse, the node is not counted. If the decorated function returnsFalse, 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, or a callable returning the spacing in seconds.
enabled – whether the task is enabled; defaults to
spacing > 0. May be a callable returning a boolean, in which case it is evaluated when periodic tasks are collected (and after spawn unpickling when configuration has been restored).
- ironic.conductor.periodics.refresh_class_periodic_attributes(cls)[source]¶
Refresh lazy periodic attributes on all periodic methods of
cls.
- ironic.conductor.periodics.refresh_periodic_attributes(func)[source]¶
Update futurist periodic attributes from deferred CONF resolvers.
Used for periodics whose
enabledorspacingwere supplied as callables so that values are read after configuration is loaded (for example in oslo.service spawn workers, which bypass the LP #1562258 import-order guard inironic.command.conductor).