diff options
author | Zhenguo Niu <niuzhenguo@huawei.com> | 2015-04-27 11:41:27 +0800 |
---|---|---|
committer | Zhenguo Niu <niuzhenguo@huawei.com> | 2015-09-02 15:45:02 +0800 |
commit | cf9466d9acbc9f3519faa9574b0a8aa0ef08a9cb (patch) | |
tree | 2d1294d0c1b5ddaf8617125a75556a6003601125 /ironic/drivers/modules/ipmitool.py | |
parent | ea09be56050c33c2843fa8568953b7883d328179 (diff) | |
download | ironic-cf9466d9acbc9f3519faa9574b0a8aa0ef08a9cb.tar.gz |
When boot option is not persisted, set boot on next power on
If the server ipmi does not support the command 'chassis bootdev'
with 'persistent' option', the boot device cannot be set persistently
and will not be set for the 2nd boot. This change proposes to add
a new parameter in node's driver_info to force set the boot device for
each power on.
Change-Id: I8d70c6292e3e013ccaf90f9ce4a616c8c916fe64
Closes-Bug: #1407820
Diffstat (limited to 'ironic/drivers/modules/ipmitool.py')
-rw-r--r-- | ironic/drivers/modules/ipmitool.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/ironic/drivers/modules/ipmitool.py b/ironic/drivers/modules/ipmitool.py index b08e7d11f..ceb69a7c4 100644 --- a/ironic/drivers/modules/ipmitool.py +++ b/ironic/drivers/modules/ipmitool.py @@ -51,6 +51,7 @@ from ironic.common import utils from ironic.conductor import task_manager from ironic.drivers import base from ironic.drivers.modules import console_utils +from ironic.drivers import utils as driver_utils CONF = cfg.CONF @@ -92,6 +93,12 @@ OPTIONAL_PROPERTIES = { "to \"single\" or \"dual\". Optional."), 'ipmi_protocol_version': _('the version of the IPMI protocol; default ' 'is "2.0". One of "1.5", "2.0". Optional.'), + 'ipmi_force_boot_device': _("Whether Ironic should specify the boot " + "device to the BMC each time the server " + "is turned on, eg. because the BMC is not " + "capable of remembering the selected boot " + "device across power cycles; default value " + "is False. Optional.") } COMMON_PROPERTIES = REQUIRED_PROPERTIES.copy() COMMON_PROPERTIES.update(OPTIONAL_PROPERTIES) @@ -247,6 +254,7 @@ def _parse_driver_info(node): target_channel = info.get('ipmi_target_channel') target_address = info.get('ipmi_target_address') protocol_version = str(info.get('ipmi_protocol_version', '2.0')) + force_boot_device = info.get('ipmi_force_boot_device', False) if protocol_version not in VALID_PROTO_VERSIONS: valid_versions = ', '.join(VALID_PROTO_VERSIONS) @@ -322,6 +330,7 @@ def _parse_driver_info(node): 'target_channel': target_channel, 'target_address': target_address, 'protocol_version': protocol_version, + 'force_boot_device': force_boot_device, } @@ -722,6 +731,7 @@ class IPMIPower(base.PowerInterface): driver_info = _parse_driver_info(task.node) if pstate == states.POWER_ON: + driver_utils.ensure_next_boot_device(task, driver_info) state = _power_on(driver_info) elif pstate == states.POWER_OFF: state = _power_off(driver_info) @@ -746,6 +756,7 @@ class IPMIPower(base.PowerInterface): """ driver_info = _parse_driver_info(task.node) _power_off(driver_info) + driver_utils.ensure_next_boot_device(task, driver_info) state = _power_on(driver_info) if state != states.POWER_ON: @@ -820,6 +831,14 @@ class IPMIManagement(base.ManagementInterface): timeout_disable = "0x00 0x08 0x03 0x08" send_raw(task, timeout_disable) + if task.node.driver_info.get('ipmi_force_boot_device', False): + driver_utils.force_persistent_boot(task, + device, + persistent) + # Reset persistent to False, in case of BMC does not support + # persistent or we do not have admin rights. + persistent = False + cmd = "chassis bootdev %s" % device if persistent: cmd = cmd + " options=persistent" @@ -852,9 +871,21 @@ class IPMIManagement(base.ManagementInterface): future boots or not, None if it is unknown. """ + driver_info = task.node.driver_info + driver_internal_info = task.node.driver_internal_info + + if (driver_info.get('ipmi_force_boot_device', False) and + driver_internal_info.get('persistent_boot_device') and + driver_internal_info.get('is_next_boot_persistent', True)): + return { + 'boot_device': driver_internal_info['persistent_boot_device'], + 'persistent': True + } + cmd = "chassis bootparam get 5" driver_info = _parse_driver_info(task.node) response = {'boot_device': None, 'persistent': None} + try: out, err = _exec_ipmitool(driver_info, cmd) except (exception.PasswordFileFailedToCreate, |