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/utils.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/utils.py')
-rw-r--r-- | ironic/drivers/utils.py | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/ironic/drivers/utils.py b/ironic/drivers/utils.py index cc9ccb2b7..a74633fd6 100644 --- a/ironic/drivers/utils.py +++ b/ironic/drivers/utils.py @@ -17,6 +17,7 @@ from oslo_log import log as logging from ironic.common import exception from ironic.common.i18n import _ from ironic.common.i18n import _LW +from ironic.conductor import utils from ironic.drivers import base @@ -170,3 +171,48 @@ def add_node_capability(task, capability, value): properties['capabilities'] = capabilities node.properties = properties node.save() + + +def ensure_next_boot_device(task, driver_info): + """Ensure boot from correct device if persistent is True + + If ipmi_force_boot_device is True and is_next_boot_persistent, set to + boot from correct device, else unset is_next_boot_persistent field. + + :param task: Node object. + :param driver_info: Node driver_info. + """ + + if driver_info.get('force_boot_device', False): + driver_internal_info = task.node.driver_internal_info + if driver_internal_info.get('is_next_boot_persistent') is False: + driver_internal_info.pop('is_next_boot_persistent', None) + task.node.driver_internal_info = driver_internal_info + task.node.save() + else: + boot_device = driver_internal_info.get('persistent_boot_device') + if boot_device: + utils.node_set_boot_device(task, boot_device) + + +def force_persistent_boot(task, device, persistent): + """Set persistent boot device to driver_internal_info + + If persistent is True set 'persistent_boot_device' field to the + boot device and reset persistent to False, else set + 'is_next_boot_persistent' to False. + + :param task: Task object. + :param device: Boot device. + :param persistent: Whether next boot is persistent or not. + """ + + node = task.node + driver_internal_info = node.driver_internal_info + if persistent: + driver_internal_info['persistent_boot_device'] = device + else: + driver_internal_info['is_next_boot_persistent'] = False + + node.driver_internal_info = driver_internal_info + node.save() |