get_supported_boot_devices() returns static device list

Returning a static device list currently is only applicable
to x86 based architectures. If a node references for instance
sparc architecture, then "pxe" boot is not supported, however
"wanboot" is. The driver referenced by the node should be able
to return a custom boot device list dependent on the architecture
of the node. However to achieve this the task needs to be passed
as an argument in get_supported_boot_devices()

Change-Id: I5ae70ee84309dffb7d7bca4ac5cba28b01b7c414
Closes-Bug: #1391598
Implements: blueprint supported-boot-device-list
This commit is contained in:
Matt Keeann 2015-06-04 17:01:42 +01:00
parent 309707bab0
commit 4667972278
26 changed files with 86 additions and 30 deletions

View File

@ -40,3 +40,6 @@ BIOS = 'bios'
SAFE = 'safe'
"Boot from default Hard-drive, request Safe Mode"
WANBOOT = 'wanboot'
"Boot from Wide Area Network"

View File

@ -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,

View File

@ -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`.
"""

View File

@ -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)

View File

@ -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`.

View File

@ -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)

View File

@ -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`.

View File

@ -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)

View File

@ -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)

View File

@ -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"

View File

@ -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())

View File

@ -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)

View File

@ -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)

View File

@ -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`.
"""

View File

@ -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

View File

@ -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,

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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,

View File

@ -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}

View File

@ -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):

View File

@ -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):

View File

@ -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:

View File

@ -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)

View File

@ -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)