Remove deprecated driver_periodic_task
This decorator was deprecated February 24, 2016; we're past the cycle boundary and 3 month requirements. Remove it. Change-Id: I9c08e7111aac9b8baf6878e508db1fbfa0ec72cb
This commit is contained in:
parent
04209eb27e
commit
fbed8b2c47
@ -24,14 +24,13 @@ import inspect
|
|||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from futurist import periodics
|
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
from oslo_utils import excutils
|
from oslo_utils import excutils
|
||||||
import six
|
import six
|
||||||
|
|
||||||
from ironic.common import exception
|
from ironic.common import exception
|
||||||
from ironic.common.i18n import _, _LE, _LW
|
from ironic.common.i18n import _, _LE
|
||||||
from ironic.common import raid
|
from ironic.common import raid
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
@ -1142,43 +1141,3 @@ def clean_step(priority, abortable=False, argsinfo=None):
|
|||||||
func._clean_step_argsinfo = argsinfo
|
func._clean_step_argsinfo = argsinfo
|
||||||
return func
|
return func
|
||||||
return decorator
|
return decorator
|
||||||
|
|
||||||
|
|
||||||
def driver_periodic_task(**kwargs):
|
|
||||||
"""Decorator for a driver-specific periodic task.
|
|
||||||
|
|
||||||
Deprecated, please use futurist directly.
|
|
||||||
Example::
|
|
||||||
|
|
||||||
from futurist import periodics
|
|
||||||
|
|
||||||
class MyDriver(base.BaseDriver):
|
|
||||||
@periodics.periodic(spacing=42)
|
|
||||||
def task(self, manager, context):
|
|
||||||
# do some job
|
|
||||||
|
|
||||||
:param kwargs: arguments to pass to @periodics.periodic
|
|
||||||
"""
|
|
||||||
LOG.warning(_LW('driver_periodic_task decorator is deprecated, please '
|
|
||||||
'use futurist.periodics.periodic directly'))
|
|
||||||
# Previously we accepted more arguments, make a backward compatibility
|
|
||||||
# layer for out-of-tree drivers.
|
|
||||||
new_kwargs = {}
|
|
||||||
for arg in ('spacing', 'enabled', 'run_immediately'):
|
|
||||||
try:
|
|
||||||
new_kwargs[arg] = kwargs.pop(arg)
|
|
||||||
except KeyError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
# NOTE(jroll) this is here to avoid a circular import when a module
|
|
||||||
# imports ironic.common.service. Normally I would balk at this, but this
|
|
||||||
# option is deprecared for removal and this code only runs at startup.
|
|
||||||
CONF.import_opt('periodic_interval', 'ironic.common.service')
|
|
||||||
new_kwargs.setdefault('spacing', CONF.periodic_interval)
|
|
||||||
|
|
||||||
if kwargs:
|
|
||||||
LOG.warning(_LW('The following arguments are not supported by '
|
|
||||||
'futurist.periodics.periodic and are ignored: %s'),
|
|
||||||
', '.join(kwargs))
|
|
||||||
|
|
||||||
return periodics.periodic(**new_kwargs)
|
|
||||||
|
@ -25,7 +25,6 @@ from ironic.common import exception
|
|||||||
from ironic.conductor import base_manager
|
from ironic.conductor import base_manager
|
||||||
from ironic.conductor import manager
|
from ironic.conductor import manager
|
||||||
from ironic.conductor import task_manager
|
from ironic.conductor import task_manager
|
||||||
from ironic.drivers import base as drivers_base
|
|
||||||
from ironic import objects
|
from ironic import objects
|
||||||
from ironic.tests import base as tests_base
|
from ironic.tests import base as tests_base
|
||||||
from ironic.tests.unit.conductor import mgr_utils
|
from ironic.tests.unit.conductor import mgr_utils
|
||||||
@ -122,10 +121,6 @@ class StartStopTestCase(mgr_utils.ServiceSetUpMixin, tests_db_base.DbTestCase):
|
|||||||
def task(self, context):
|
def task(self, context):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@drivers_base.driver_periodic_task()
|
|
||||||
def deprecated_task(self, context):
|
|
||||||
pass
|
|
||||||
|
|
||||||
obj = Driver()
|
obj = Driver()
|
||||||
get_mock.return_value = mock.Mock(obj=obj)
|
get_mock.return_value = mock.Mock(obj=obj)
|
||||||
|
|
||||||
@ -136,7 +131,7 @@ class StartStopTestCase(mgr_utils.ServiceSetUpMixin, tests_db_base.DbTestCase):
|
|||||||
self._start_service(start_periodic_tasks=True)
|
self._start_service(start_periodic_tasks=True)
|
||||||
|
|
||||||
tasks = {c[0] for c in self.service._periodic_task_callables}
|
tasks = {c[0] for c in self.service._periodic_task_callables}
|
||||||
for t in (obj.task, obj.iface.iface, obj.deprecated_task):
|
for t in (obj.task, obj.iface.iface):
|
||||||
self.assertTrue(periodics.is_periodic(t))
|
self.assertTrue(periodics.is_periodic(t))
|
||||||
self.assertIn(t, tasks)
|
self.assertIn(t, tasks)
|
||||||
|
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
|
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from futurist import periodics
|
|
||||||
import mock
|
import mock
|
||||||
|
|
||||||
from ironic.common import exception
|
from ironic.common import exception
|
||||||
@ -101,23 +100,6 @@ class PassthruDecoratorTestCase(base.TestCase):
|
|||||||
inst2.driver_routes['driver_noexception']['func'])
|
inst2.driver_routes['driver_noexception']['func'])
|
||||||
|
|
||||||
|
|
||||||
class DriverPeriodicTaskTestCase(base.TestCase):
|
|
||||||
def test(self):
|
|
||||||
method_mock = mock.MagicMock(spec_set=[])
|
|
||||||
|
|
||||||
class TestClass(object):
|
|
||||||
@driver_base.driver_periodic_task(spacing=42)
|
|
||||||
def method(self, foo, bar=None):
|
|
||||||
method_mock(foo, bar=bar)
|
|
||||||
|
|
||||||
obj = TestClass()
|
|
||||||
self.assertEqual(42, obj.method._periodic_spacing)
|
|
||||||
self.assertTrue(periodics.is_periodic(obj.method))
|
|
||||||
|
|
||||||
obj.method(1, bar=2)
|
|
||||||
method_mock.assert_called_once_with(1, bar=2)
|
|
||||||
|
|
||||||
|
|
||||||
class CleanStepDecoratorTestCase(base.TestCase):
|
class CleanStepDecoratorTestCase(base.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
upgrade:
|
||||||
|
- Removes the deprecated decorator "driver_periodic_task",
|
||||||
|
Drivers should use the "periodics.periodic" decorator
|
||||||
|
from the futurist library instead.
|
Loading…
Reference in New Issue
Block a user