From ddaa505f6d7e3cb9423419b664aeeb42da381fb8 Mon Sep 17 00:00:00 2001 From: Vladyslav Drok Date: Thu, 12 Nov 2015 18:36:25 +0200 Subject: [PATCH] Make task parameter mandatory in get_supported_boot_devices Deprecation period for not having task parameter in get_supported_boot_devices is over, this change removes this possibility and also adds now required parameter to UCS management interface. Change-Id: Id049f040865abf4c2dd50e8d91c227b67c9204b9 --- ironic/conductor/manager.py | 11 +--------- ironic/drivers/base.py | 7 ------ ironic/drivers/modules/ucs/management.py | 3 ++- ironic/tests/unit/conductor/test_manager.py | 22 ------------------- .../drivers/modules/ucs/test_management.py | 9 +++++--- 5 files changed, 9 insertions(+), 43 deletions(-) diff --git a/ironic/conductor/manager.py b/ironic/conductor/manager.py index 0af1415022..6c93045211 100644 --- a/ironic/conductor/manager.py +++ b/ironic/conductor/manager.py @@ -1936,16 +1936,7 @@ class ConductorManager(periodic_task.PeriodicTasks): if not getattr(task.driver, 'management', None): raise exception.UnsupportedDriverExtension( driver=task.node.driver, extension='management') - if task.driver.management.get_supported_boot_devices_task_arg: - return task.driver.management.get_supported_boot_devices(task) - else: - LOG.warning(_LW("Driver '%s' is missing a task " - "argument to the method " - "get_supported_boot_devices() which " - "has been deprecated. Please update the code " - "to include a task argument."), - task.node.driver) - return task.driver.management.get_supported_boot_devices() + return task.driver.management.get_supported_boot_devices(task) @messaging.expected_exceptions(exception.NoFreeConductorWorker, exception.NodeLocked, diff --git a/ironic/drivers/base.py b/ironic/drivers/base.py index 56b2734683..74ace0dbb1 100644 --- a/ironic/drivers/base.py +++ b/ironic/drivers/base.py @@ -748,13 +748,6 @@ class ManagementInterface(BaseInterface): :raises: MissingParameterValue """ - @property - def get_supported_boot_devices_task_arg(self): - # NOTE(MattMan): remove this method in next cycle(Mitaka) as task - # parameter will be mandatory then. - argspec = inspect.getargspec(self.get_supported_boot_devices) - return len(argspec.args) > 1 - @abc.abstractmethod def get_supported_boot_devices(self, task): """Get a list of the supported boot devices. diff --git a/ironic/drivers/modules/ucs/management.py b/ironic/drivers/modules/ucs/management.py index 606e6f2dd3..7a04e7657c 100644 --- a/ironic/drivers/modules/ucs/management.py +++ b/ironic/drivers/modules/ucs/management.py @@ -60,9 +60,10 @@ class UcsManagement(base.ManagementInterface): ucs_helper.parse_driver_info(task.node) - def get_supported_boot_devices(self): + def get_supported_boot_devices(self, task): """Get a list of the supported boot devices. + :param task: a task from TaskManager. :returns: A list with the supported boot devices defined in :mod:`ironic.common.boot_devices`. """ diff --git a/ironic/tests/unit/conductor/test_manager.py b/ironic/tests/unit/conductor/test_manager.py index 765b7e488e..fa685c9d9f 100644 --- a/ironic/tests/unit/conductor/test_manager.py +++ b/ironic/tests/unit/conductor/test_manager.py @@ -2830,28 +2830,6 @@ class UpdatePortTestCase(_ServiceSetUpMixin, tests_db_base.DbTestCase): node.uuid) self.assertEqual([boot_devices.PXE], bootdevs) - def test_get_supported_boot_devices_no_task(self): - # NOTE(MattMan): This test method should be removed in next - # cycle(Mitaka), task parameter will be mandatory then - node = obj_utils.create_test_node(self.context, driver='fake') - - def no_task_get_supported_boot_devices(): - return "FAKE_BOOT_DEVICE_NO_TASK" - - # Override driver's get_supported_boot_devices method ensuring - # no task parameter - saved_get_boot_devices = \ - self.driver.management.get_supported_boot_devices - self.driver.management.get_supported_boot_devices = \ - no_task_get_supported_boot_devices - bootdevs = self.service.get_supported_boot_devices(self.context, - node.uuid) - self.assertEqual("FAKE_BOOT_DEVICE_NO_TASK", bootdevs) - - # Revert back to original method - self.driver.management.get_supported_boot_devices = \ - saved_get_boot_devices - def test_get_supported_boot_devices_iface_not_supported(self): node = obj_utils.create_test_node(self.context, driver='fake') # null the management interface diff --git a/ironic/tests/unit/drivers/modules/ucs/test_management.py b/ironic/tests/unit/drivers/modules/ucs/test_management.py index 5a90006ec1..b4911b0557 100644 --- a/ironic/tests/unit/drivers/modules/ucs/test_management.py +++ b/ironic/tests/unit/drivers/modules/ucs/test_management.py @@ -53,9 +53,12 @@ class UcsManagementTestCase(db_base.DbTestCase): self.assertEqual(expected, self.interface.get_properties()) def test_get_supported_boot_devices(self): - expected = [boot_devices.PXE, boot_devices.DISK, boot_devices.CDROM] - self.assertEqual(sorted(expected), - sorted(self.interface.get_supported_boot_devices())) + with task_manager.acquire(self.context, self.node.uuid) as task: + expected = [boot_devices.PXE, boot_devices.DISK, + boot_devices.CDROM] + self.assertEqual( + sorted(expected), + sorted(self.interface.get_supported_boot_devices(task))) @mock.patch('ironic.drivers.modules.ucs.helper.ucs_helper', spec_set=True, autospec=True)