Fix iLO drivers inconsistent boot mode default value

When no boot mode is explicitly passed to iLO drivers, it picks
default boot mode based on series of factors like, pending boot
mode setting, UEFI boot mode support on the node. This causes
confusion to the users as these factors are node specific and
beyond user's control. User expects a predictable behavior when
no boot mode is explicitly passed.
A new configuration parameter '[ilo]/default_boot_mode' has
been added to specify default boot mode. It would be used if no
boot mode is explicitly passed to iLO drivers.

Change-Id: I4efd28985674bedabe42fe786135255698425321
Closes-Bug: #1604002
This commit is contained in:
Shivanand Tendulker 2016-07-20 23:52:26 -07:00
parent 8783e8d036
commit 8b2ec52e42
6 changed files with 59 additions and 1 deletions

View File

@ -626,6 +626,11 @@ mode (Legacy BIOS or UEFI).
* When boot mode capability is not configured:
- If config variable ``default_boot_mode`` in ``[ilo]`` section of
ironic configuration file is set to either 'bios' or 'uefi', then iLO
drivers use that boot mode for provisioning the baremetal ProLiant
servers.
- If the pending boot mode is set on the node then iLO drivers use that boot
mode for provisioning the baremetal ProLiant servers.

View File

@ -1331,6 +1331,15 @@
# CA certificate file to validate iLO. (string value)
#ca_file = <None>
# Default boot mode to be used in provisioning when
# "boot_mode" capability is not provided in
# the"properties/capabilities" of the node. The default is
# "auto" for backward compatibility. When "auto" is specified,
# default boot mode will be selected based on boot mode
# settings on the system. (string value)
# Allowed values: auto, bios, uefi
#default_boot_mode = auto
[inspector]

View File

@ -80,6 +80,15 @@ opts = [
'operations')),
cfg.StrOpt('ca_file',
help=_('CA certificate file to validate iLO.')),
cfg.StrOpt('default_boot_mode',
default='auto',
choices=['auto', 'bios', 'uefi'],
help=_('Default boot mode to be used in provisioning when '
'"boot_mode" capability is not provided in the'
'"properties/capabilities" of the node. The default is '
'"auto" for backward compatibility. When "auto" is '
'specified, default boot mode will be selected based '
'on boot mode settings on the system.')),
]

View File

@ -437,12 +437,22 @@ def update_boot_mode(task):
node = task.node
boot_mode = deploy_utils.get_boot_mode_for_deploy(node)
if boot_mode is not None:
# No boot mode found. Check if default_boot_mode is defined
if not boot_mode and (CONF.ilo.default_boot_mode in ['bios', 'uefi']):
boot_mode = CONF.ilo.default_boot_mode
instance_info = node.instance_info
instance_info['deploy_boot_mode'] = boot_mode
node.instance_info = instance_info
node.save()
# Boot mode is computed, setting it for the deploy
if boot_mode:
LOG.debug("Node %(uuid)s boot mode is being set to %(boot_mode)s",
{'uuid': node.uuid, 'boot_mode': boot_mode})
set_boot_mode(node, boot_mode)
return
# Computing boot mode based on boot mode settings on bare metal
LOG.debug("Check pending boot mode for node %s.", node.uuid)
ilo_object = get_ilo_object(node)

View File

@ -373,9 +373,22 @@ class IloCommonMethodsTestCase(db_base.DbTestCase):
ilo_common.update_boot_mode(task)
set_boot_mode_mock.assert_called_once_with(task.node, 'bios')
@mock.patch.object(ilo_common, 'set_boot_mode', spec_set=True,
autospec=True)
def test_update_boot_mode_use_def_boot_mode(self,
set_boot_mode_mock):
self.config(default_boot_mode='bios', group='ilo')
with task_manager.acquire(self.context, self.node.uuid,
shared=False) as task:
ilo_common.update_boot_mode(task)
set_boot_mode_mock.assert_called_once_with(task.node, 'bios')
self.assertEqual('bios',
task.node.instance_info['deploy_boot_mode'])
@mock.patch.object(ilo_common, 'get_ilo_object', spec_set=True,
autospec=True)
def test_update_boot_mode(self, get_ilo_object_mock):
self.config(default_boot_mode="auto", group='ilo')
ilo_mock_obj = get_ilo_object_mock.return_value
ilo_mock_obj.get_pending_boot_mode.return_value = 'LEGACY'

View File

@ -0,0 +1,12 @@
---
fixes:
- When no boot mode is explicitly set on a node using
an iLO driver, ironic automatically picks a boot
mode based on hardware capabilities. This confuses
deployers, as these factors are system specific and
not configurable. In order to ensure predictable
behavior, a new configuration parameter,
``[ilo]/default_boot_mode``, was added to allow
deployers to explicitly set a default. The default
value of this option keeps behavior consistent for
existing deployments.