Deprecate putting periodic tasks on a driver object

This approach will no longer make sense when the driver composition is in effect.
Anyway usually a better place to put a task is an interface.

Change-Id: I7096e428ce9774d89ac624c2d38bb23984a4b842
Related-Bug: #1524745
This commit is contained in:
Dmitry Tantsur 2016-08-01 15:40:08 +02:00
parent 66b66fd629
commit 8c842ec505
3 changed files with 14 additions and 10 deletions

View File

@ -76,8 +76,8 @@ Driver-Specific Periodic Tasks
------------------------------
Drivers may run their own periodic tasks, i.e. actions run repeatedly after
a certain amount of time. Such task is created by decorating a method on the
driver itself or on any interface with periodic_ decorator, e.g.
a certain amount of time. Such task is created by decorating a method on
an interface with periodic_ decorator, e.g.
::
@ -88,18 +88,15 @@ driver itself or on any interface with periodic_ decorator, e.g.
def task(self, manager, context):
pass # do something
class FakeDriver(base.BaseDriver):
def __init__(self):
self.power = FakePower()
@periodics.periodic(spacing=42)
def task2(self, manager, context):
pass # do something
Here the ``spacing`` argument is a period in seconds for a given periodic task.
For example 'spacing=5' means every 5 seconds.
.. note::
As of the Newton release, it's possible to bind periodic tasks to a driver
object instead of an interface. This is deprecated and support for it will
be removed in the Ocata release.
Message Routing
===============

View File

@ -110,6 +110,8 @@ class BaseConductorManager(object):
periodic_task_classes = set()
self._collect_periodic_tasks(self, (admin_context,))
for driver_obj in drivers.values():
# TODO(dtantsur): collecting tasks from driver objects is
# deprecated and should be removed in Ocata.
self._collect_periodic_tasks(driver_obj, (self, admin_context))
for iface_name in driver_obj.all_interfaces:
iface = getattr(driver_obj, iface_name, None)

View File

@ -0,0 +1,5 @@
---
deprecations:
- Putting periodic tasks on a driver object (rather than interface) is
deprecated. Driver developers should move periodic tasks from driver
objects to interface objects.