diff --git a/ironic/common/boot_devices.py b/ironic/common/boot_devices.py index c225164cbe..4fcda5ffdc 100644 --- a/ironic/common/boot_devices.py +++ b/ironic/common/boot_devices.py @@ -40,3 +40,6 @@ BIOS = 'bios' SAFE = 'safe' "Boot from default Hard-drive, request Safe Mode" + +WANBOOT = 'wanboot' +"Boot from Wide Area Network" diff --git a/ironic/conductor/manager.py b/ironic/conductor/manager.py index f8d5a101d2..074d4cf0b6 100644 --- a/ironic/conductor/manager.py +++ b/ironic/conductor/manager.py @@ -1651,7 +1651,16 @@ class ConductorManager(periodic_task.PeriodicTasks): if not getattr(task.driver, 'management', None): raise exception.UnsupportedDriverExtension( driver=task.node.driver, extension='management') - return task.driver.management.get_supported_boot_devices() + 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() @messaging.expected_exceptions(exception.NoFreeConductorWorker, exception.NodeLocked, diff --git a/ironic/drivers/base.py b/ironic/drivers/base.py index 3e7ff33c68..5919cc6e4a 100644 --- a/ironic/drivers/base.py +++ b/ironic/drivers/base.py @@ -637,10 +637,18 @@ 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): + 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/drivers/modules/amt/management.py b/ironic/drivers/modules/amt/management.py index bff3145547..a648ebbe4c 100644 --- a/ironic/drivers/modules/amt/management.py +++ b/ironic/drivers/modules/amt/management.py @@ -165,9 +165,10 @@ class AMTManagement(base.ManagementInterface): # connect to the node until bug 1314961 is resolved. amt_common.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. """ return list(amt_common.BOOT_DEVICES_MAPPING) diff --git a/ironic/drivers/modules/drac/management.py b/ironic/drivers/modules/drac/management.py index c89974a190..5fc73138fd 100644 --- a/ironic/drivers/modules/drac/management.py +++ b/ironic/drivers/modules/drac/management.py @@ -193,9 +193,10 @@ class DracManagement(base.ManagementInterface): """ return drac_common.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/drivers/modules/fake.py b/ironic/drivers/modules/fake.py index e7e152aad6..dd60a4c97f 100644 --- a/ironic/drivers/modules/fake.py +++ b/ironic/drivers/modules/fake.py @@ -156,11 +156,11 @@ class FakeManagement(base.ManagementInterface): def validate(self, task): pass - def get_supported_boot_devices(self): + def get_supported_boot_devices(self, task): return [boot_devices.PXE] def set_boot_device(self, task, device, persistent=False): - if device not in self.get_supported_boot_devices(): + if device not in self.get_supported_boot_devices(task): raise exception.InvalidParameterValue(_( "Invalid boot device %s specified.") % device) diff --git a/ironic/drivers/modules/ilo/management.py b/ironic/drivers/modules/ilo/management.py index ae4a8439d2..9c8aeff8b7 100644 --- a/ironic/drivers/modules/ilo/management.py +++ b/ironic/drivers/modules/ilo/management.py @@ -126,9 +126,10 @@ class IloManagement(base.ManagementInterface): """ ilo_common.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/drivers/modules/ipminative.py b/ironic/drivers/modules/ipminative.py index 438f3ef183..c104945643 100644 --- a/ironic/drivers/modules/ipminative.py +++ b/ironic/drivers/modules/ipminative.py @@ -379,9 +379,10 @@ class NativeIPMIManagement(base.ManagementInterface): """ _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`. @@ -406,7 +407,7 @@ class NativeIPMIManagement(base.ManagementInterface): are missing. :raises: IPMIFailure on an error from pyghmi. """ - if device not in self.get_supported_boot_devices(): + if device not in self.get_supported_boot_devices(task): raise exception.InvalidParameterValue(_( "Invalid boot device %s specified.") % device) driver_info = _parse_driver_info(task.node) diff --git a/ironic/drivers/modules/ipmitool.py b/ironic/drivers/modules/ipmitool.py index 3e8384994c..38cb5b7ffe 100644 --- a/ironic/drivers/modules/ipmitool.py +++ b/ironic/drivers/modules/ipmitool.py @@ -767,9 +767,10 @@ class IPMIManagement(base.ManagementInterface): """ _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`. @@ -794,7 +795,7 @@ class IPMIManagement(base.ManagementInterface): :raises: IPMIFailure on an error from ipmitool. """ - if device not in self.get_supported_boot_devices(): + if device not in self.get_supported_boot_devices(task): raise exception.InvalidParameterValue(_( "Invalid boot device %s specified.") % device) diff --git a/ironic/drivers/modules/irmc/management.py b/ironic/drivers/modules/irmc/management.py index ec0bc5320c..78de52c6ef 100644 --- a/ironic/drivers/modules/irmc/management.py +++ b/ironic/drivers/modules/irmc/management.py @@ -138,7 +138,7 @@ class IRMCManagement(ipmitool.IPMIManagement): """ if driver_utils.get_node_capability(task.node, 'boot_mode') == 'uefi': - if device not in self.get_supported_boot_devices(): + if device not in self.get_supported_boot_devices(task): raise exception.InvalidParameterValue(_( "Invalid boot device %s specified.") % device) timeout_disable = "0x00 0x08 0x03 0x08" diff --git a/ironic/drivers/modules/msftocs/management.py b/ironic/drivers/modules/msftocs/management.py index 10451a19f8..f148c43949 100644 --- a/ironic/drivers/modules/msftocs/management.py +++ b/ironic/drivers/modules/msftocs/management.py @@ -48,9 +48,10 @@ class MSFTOCSManagement(base.ManagementInterface): """ msftocs_common.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. """ return list(BOOT_TYPE_TO_DEVICE_MAP.values()) diff --git a/ironic/drivers/modules/seamicro.py b/ironic/drivers/modules/seamicro.py index e535402579..185586e3b7 100644 --- a/ironic/drivers/modules/seamicro.py +++ b/ironic/drivers/modules/seamicro.py @@ -540,9 +540,10 @@ class Management(base.ManagementInterface): """ _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`. @@ -567,7 +568,7 @@ class Management(base.ManagementInterface): :raises: MissingParameterValue when a required parameter is missing """ - if device not in self.get_supported_boot_devices(): + if device not in self.get_supported_boot_devices(task): raise exception.InvalidParameterValue(_( "Invalid boot device %s specified.") % device) diff --git a/ironic/drivers/modules/ssh.py b/ironic/drivers/modules/ssh.py index e910af7d13..1ba607694f 100644 --- a/ironic/drivers/modules/ssh.py +++ b/ironic/drivers/modules/ssh.py @@ -620,9 +620,10 @@ class SSHManagement(base.ManagementInterface): """ _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`. @@ -652,7 +653,7 @@ class SSHManagement(base.ManagementInterface): """ node = task.node driver_info = _parse_driver_info(node) - if device not in self.get_supported_boot_devices(): + if device not in self.get_supported_boot_devices(task): raise exception.InvalidParameterValue(_( "Invalid boot device %s specified.") % device) driver_info['macs'] = driver_utils.get_node_mac_addresses(task) diff --git a/ironic/drivers/modules/virtualbox.py b/ironic/drivers/modules/virtualbox.py index 5fd882f5e2..bc6bddce60 100644 --- a/ironic/drivers/modules/virtualbox.py +++ b/ironic/drivers/modules/virtualbox.py @@ -281,9 +281,10 @@ class VirtualBoxManagement(base.ManagementInterface): """ _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/conductor/test_manager.py b/ironic/tests/conductor/test_manager.py index 34e5a1d5f5..deefdb4925 100644 --- a/ironic/tests/conductor/test_manager.py +++ b/ironic/tests/conductor/test_manager.py @@ -2536,6 +2536,28 @@ 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/drivers/amt/test_management.py b/ironic/tests/drivers/amt/test_management.py index 07d5bf9033..6aac13da97 100644 --- a/ironic/tests/drivers/amt/test_management.py +++ b/ironic/tests/drivers/amt/test_management.py @@ -152,7 +152,8 @@ class AMTManagementTestCase(db_base.DbTestCase): shared=True) as task: self.assertEqual( sorted(expected), - sorted(task.driver.management.get_supported_boot_devices())) + sorted(task.driver.management. + get_supported_boot_devices(task))) def test_set_boot_device_one_time(self): with task_manager.acquire(self.context, self.node.uuid, diff --git a/ironic/tests/drivers/drac/test_management.py b/ironic/tests/drivers/drac/test_management.py index f48ac09908..5e142053ae 100644 --- a/ironic/tests/drivers/drac/test_management.py +++ b/ironic/tests/drivers/drac/test_management.py @@ -169,7 +169,8 @@ class DracManagementTestCase(db_base.DbTestCase): def test_get_supported_boot_devices(self, mock_client_pywsman): expected = [boot_devices.PXE, boot_devices.DISK, boot_devices.CDROM] self.assertEqual(sorted(expected), - sorted(self.driver.get_supported_boot_devices())) + sorted(self.driver. + get_supported_boot_devices(self.task))) @mock.patch.object(drac_mgmt, '_get_next_boot_mode', spec_set=True, autospec=True) diff --git a/ironic/tests/drivers/ilo/test_management.py b/ironic/tests/drivers/ilo/test_management.py index b401fdf4f7..451ec6e25c 100644 --- a/ironic/tests/drivers/ilo/test_management.py +++ b/ironic/tests/drivers/ilo/test_management.py @@ -65,7 +65,8 @@ class IloManagementTestCase(db_base.DbTestCase): boot_devices.CDROM] self.assertEqual( sorted(expected), - sorted(task.driver.management.get_supported_boot_devices())) + sorted(task.driver.management. + get_supported_boot_devices(task))) @mock.patch.object(ilo_common, 'get_ilo_object', spec_set=True, autospec=True) diff --git a/ironic/tests/drivers/irmc/test_management.py b/ironic/tests/drivers/irmc/test_management.py index a15282b72f..05fe2d1d0b 100644 --- a/ironic/tests/drivers/irmc/test_management.py +++ b/ironic/tests/drivers/irmc/test_management.py @@ -82,7 +82,7 @@ class IRMCManagementTestCase(db_base.DbTestCase): boot_devices.CDROM, boot_devices.BIOS, boot_devices.SAFE] self.assertEqual(sorted(expected), sorted(task.driver.management. - get_supported_boot_devices())) + get_supported_boot_devices(task))) @mock.patch.object(ipmitool.IPMIManagement, 'set_boot_device', spec_set=True, autospec=True) diff --git a/ironic/tests/drivers/msftocs/test_management.py b/ironic/tests/drivers/msftocs/test_management.py index 098d25573f..b90fe2d876 100644 --- a/ironic/tests/drivers/msftocs/test_management.py +++ b/ironic/tests/drivers/msftocs/test_management.py @@ -70,7 +70,8 @@ class MSFTOCSManagementTestCase(db_base.DbTestCase): shared=True) as task: self.assertEqual( sorted(expected), - sorted(task.driver.management.get_supported_boot_devices())) + sorted(task.driver.management. + get_supported_boot_devices(task))) @mock.patch.object(msftocs_common, 'get_client_info', autospec=True) def _test_set_boot_device_one_time(self, persistent, uefi, diff --git a/ironic/tests/drivers/test_fake.py b/ironic/tests/drivers/test_fake.py index 1b9e16cc0a..0cca076020 100644 --- a/ironic/tests/drivers/test_fake.py +++ b/ironic/tests/drivers/test_fake.py @@ -101,8 +101,9 @@ class FakeDriverTestCase(db_base.DbTestCase): def test_management_interface_get_supported_boot_devices(self): expected = [boot_devices.PXE] - self.assertEqual(expected, - self.driver.management.get_supported_boot_devices()) + self.assertEqual( + expected, + self.driver.management.get_supported_boot_devices(self.task)) def test_management_interface_get_boot_device(self): expected = {'boot_device': boot_devices.PXE, 'persistent': False} diff --git a/ironic/tests/drivers/test_ipminative.py b/ironic/tests/drivers/test_ipminative.py index a3012da156..e3298cebe1 100644 --- a/ironic/tests/drivers/test_ipminative.py +++ b/ironic/tests/drivers/test_ipminative.py @@ -332,7 +332,7 @@ class IPMINativeDriverTestCase(db_base.DbTestCase): expected = [boot_devices.PXE, boot_devices.DISK, boot_devices.CDROM, boot_devices.BIOS] self.assertEqual(sorted(expected), sorted(task.driver.management. - get_supported_boot_devices())) + get_supported_boot_devices(task))) @mock.patch('pyghmi.ipmi.command.Command', autospec=True) def test_management_interface_get_boot_device_good(self, ipmi_mock): diff --git a/ironic/tests/drivers/test_ipmitool.py b/ironic/tests/drivers/test_ipmitool.py index 5b3c2c0fb0..79e302bf2b 100644 --- a/ironic/tests/drivers/test_ipmitool.py +++ b/ironic/tests/drivers/test_ipmitool.py @@ -1496,7 +1496,7 @@ class IPMIToolDriverTestCase(db_base.DbTestCase): boot_devices.CDROM, boot_devices.BIOS, boot_devices.SAFE] self.assertEqual(sorted(expected), sorted(task.driver.management. - get_supported_boot_devices())) + get_supported_boot_devices(task))) @mock.patch.object(ipmi, '_exec_ipmitool', autospec=True) def test_management_interface_get_boot_device(self, mock_exec): diff --git a/ironic/tests/drivers/test_seamicro.py b/ironic/tests/drivers/test_seamicro.py index 06073d0d53..ca8131e402 100644 --- a/ironic/tests/drivers/test_seamicro.py +++ b/ironic/tests/drivers/test_seamicro.py @@ -563,7 +563,7 @@ class SeaMicroPowerDriverTestCase(db_base.DbTestCase): with task_manager.acquire(self.context, self.node.uuid) as task: expected = [boot_devices.PXE, boot_devices.DISK] self.assertEqual(sorted(expected), sorted(task.driver.management. - get_supported_boot_devices())) + get_supported_boot_devices(task))) def test_management_interface_get_boot_device(self): with task_manager.acquire(self.context, self.node.uuid) as task: diff --git a/ironic/tests/drivers/test_ssh.py b/ironic/tests/drivers/test_ssh.py index 59c28afa5b..127af5eacc 100644 --- a/ironic/tests/drivers/test_ssh.py +++ b/ironic/tests/drivers/test_ssh.py @@ -852,7 +852,7 @@ class SSHDriverTestCase(db_base.DbTestCase): expected = [boot_devices.PXE, boot_devices.DISK, boot_devices.CDROM] self.assertEqual(sorted(expected), sorted(task.driver.management. - get_supported_boot_devices())) + get_supported_boot_devices(task))) @mock.patch.object(ssh, '_get_connection', autospec=True) @mock.patch.object(ssh, '_get_hosts_name_for_node', autospec=True) diff --git a/ironic/tests/drivers/test_virtualbox.py b/ironic/tests/drivers/test_virtualbox.py index 8f158d70e6..a6ede977b9 100644 --- a/ironic/tests/drivers/test_virtualbox.py +++ b/ironic/tests/drivers/test_virtualbox.py @@ -312,7 +312,7 @@ class VirtualBoxManagementTestCase(db_base.DbTestCase): def test_get_supported_boot_devices(self): with task_manager.acquire(self.context, self.node.uuid, shared=False) as task: - devices = task.driver.management.get_supported_boot_devices() + devices = task.driver.management.get_supported_boot_devices(task) self.assertIn(boot_devices.PXE, devices) self.assertIn(boot_devices.DISK, devices) self.assertIn(boot_devices.CDROM, devices)