Merge "get_supported_boot_devices() returns static device list"
This commit is contained in:
commit
b4bc26c4a6
@ -40,3 +40,6 @@ BIOS = 'bios'
|
||||
|
||||
SAFE = 'safe'
|
||||
"Boot from default Hard-drive, request Safe Mode"
|
||||
|
||||
WANBOOT = 'wanboot'
|
||||
"Boot from Wide Area Network"
|
||||
|
@ -1795,7 +1795,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,
|
||||
|
@ -734,10 +734,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`.
|
||||
"""
|
||||
|
@ -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)
|
||||
|
@ -336,9 +336,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`.
|
||||
|
||||
|
@ -178,11 +178,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)
|
||||
|
||||
|
@ -127,9 +127,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`.
|
||||
|
||||
|
@ -378,9 +378,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`.
|
||||
|
||||
@ -405,7 +406,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)
|
||||
|
@ -790,9 +790,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`.
|
||||
|
||||
@ -817,7 +818,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)
|
||||
|
||||
|
@ -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"
|
||||
|
@ -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())
|
||||
|
@ -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)
|
||||
|
||||
|
@ -621,9 +621,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`.
|
||||
|
||||
@ -653,7 +654,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)
|
||||
|
@ -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`.
|
||||
"""
|
||||
|
@ -2679,6 +2679,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
|
||||
|
@ -153,7 +153,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,
|
||||
|
@ -204,7 +204,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_list', spec_set=True,
|
||||
autospec=True)
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -71,7 +71,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,
|
||||
|
@ -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}
|
||||
|
@ -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):
|
||||
|
@ -1543,7 +1543,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):
|
||||
|
@ -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:
|
||||
|
@ -854,7 +854,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)
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user