summaryrefslogtreecommitdiff
path: root/ironic/conductor
diff options
context:
space:
mode:
authorIlya Etingof <etingof@gmail.com>2017-12-07 17:13:59 +0100
committerJulia Kreger <juliaashleykreger@gmail.com>2018-06-15 15:19:41 +0000
commit5e8f2e39d4f3508b2189dc09d6eecc9492c42f0c (patch)
tree840c898c5dbe2788f9fdcc4a3a8828374a05168a /ironic/conductor
parent643422b4d6d7db9dd062bd443a0b272d24c05f61 (diff)
downloadironic-5e8f2e39d4f3508b2189dc09d6eecc9492c42f0c.tar.gz
Adds boot mode support to ManagementInterface
This change introduces optional boot mode get/set methods to driver management interface [1] [2] alongside existing get/set boot device calls. The management interface is called at deploy time to synchronize BM machine boot mode setting with Ironic node configuration whenever needed. Also, this change introduces common exception class to be eventually used by the drivers to communicate their runtime errors to Ironic code in a uniformed way. 1. http://eavesdrop.openstack.org/irclogs/%23openstack-ironic/%23openstack-ironic.2018-01-09.log.html#t2018-01-09T15:54:16 2. http://eavesdrop.openstack.org/irclogs/%23openstack-ironic/%23openstack-ironic.2018-05-11.log.html#t2018-05-11T12:47:12 Story: 1734131 Task: 10640 Change-Id: If3db6ab8d3fae35d17808a231b7eecf11cf58327
Diffstat (limited to 'ironic/conductor')
-rw-r--r--ironic/conductor/manager.py1
-rw-r--r--ironic/conductor/utils.py87
2 files changed, 79 insertions, 9 deletions
diff --git a/ironic/conductor/manager.py b/ironic/conductor/manager.py
index 76d493c0f..d9c6f3995 100644
--- a/ironic/conductor/manager.py
+++ b/ironic/conductor/manager.py
@@ -944,6 +944,7 @@ class ConductorManager(base_manager.BaseConductorManager):
driver_internal_info.pop('clean_steps', None)
driver_internal_info.pop('root_uuid_or_disk_id', None)
driver_internal_info.pop('is_whole_disk_image', None)
+ driver_internal_info.pop('deploy_boot_mode', None)
node.driver_internal_info = driver_internal_info
network.remove_vifs_from_node(task)
node.save()
diff --git a/ironic/conductor/utils.py b/ironic/conductor/utils.py
index 68f9cbc2a..46e0f446d 100644
--- a/ironic/conductor/utils.py
+++ b/ironic/conductor/utils.py
@@ -47,9 +47,6 @@ CLEANING_INTERFACE_PRIORITY = {
def node_set_boot_device(task, device, persistent=False):
"""Set the boot device for a node.
- Sets the boot device for a node if the node's driver interface
- contains a 'management' interface.
-
If the node that the boot device change is being requested for
is in ADOPTING state, the boot device will not be set as that
change could potentially result in the future running state of
@@ -63,12 +60,84 @@ def node_set_boot_device(task, device, persistent=False):
ManagementInterface fails.
"""
- if getattr(task.driver, 'management', None):
- task.driver.management.validate(task)
- if task.node.provision_state != states.ADOPTING:
- task.driver.management.set_boot_device(task,
- device=device,
- persistent=persistent)
+ # TODO(etingof): remove `if` once classic drivers are gone
+ if not getattr(task.driver, 'management', None):
+ return
+
+ task.driver.management.validate(task)
+ if task.node.provision_state != states.ADOPTING:
+ task.driver.management.set_boot_device(task,
+ device=device,
+ persistent=persistent)
+
+
+def node_get_boot_mode(task):
+ """Read currently set boot mode from a node.
+
+ Reads the boot mode for a node. If boot mode can't be discovered,
+ `None` is returned.
+
+ :param task: a TaskManager instance.
+ :raises: DriverOperationError or its derivative in case
+ of driver runtime error.
+ :raises: UnsupportedDriverExtension if current driver does not have
+ management interface or `get_boot_mode()` method is
+ not supported.
+ :returns: Boot mode. One of :mod:`ironic.common.boot_mode` or `None`
+ if boot mode can't be discovered
+ """
+ # TODO(etingof): remove `if` once classic drivers are gone
+ if not getattr(task.driver, 'management', None):
+ return
+
+ task.driver.management.validate(task)
+ return task.driver.management.get_boot_mode(task)
+
+
+# TODO(ietingof): remove `Sets the boot mode...` from the docstring
+# once classic drivers are gone
+@task_manager.require_exclusive_lock
+def node_set_boot_mode(task, mode):
+ """Set the boot mode for a node.
+
+ Sets the boot mode for a node if the node's driver interface
+ contains a 'management' interface.
+
+ If the node that the boot mode change is being requested for
+ is in ADOPTING state, the boot mode will not be set as that
+ change could potentially result in the future running state of
+ an adopted node being modified erroneously.
+
+ :param task: a TaskManager instance.
+ :param mode: Boot mode. Values are one of
+ :mod:`ironic.common.boot_modes`
+ :raises: InvalidParameterValue if the validation of the
+ ManagementInterface fails.
+ :raises: DriverOperationError or its derivative in case
+ of driver runtime error.
+ :raises: UnsupportedDriverExtension if current driver does not have
+ vendor interface or method is unsupported.
+ """
+ if task.node.provision_state == states.ADOPTING:
+ return
+
+ # TODO(etingof): remove `if` once classic drivers are gone
+ if not getattr(task.driver, 'management', None):
+ return
+
+ task.driver.management.validate(task)
+
+ boot_modes = task.driver.management.get_supported_boot_modes(task)
+
+ if mode not in boot_modes:
+ msg = _("Unsupported boot mode %(mode)s specified for "
+ "node %(node_id)s. Supported boot modes are: "
+ "%(modes)s") % {'mode': mode,
+ 'modes': ', '.join(boot_modes),
+ 'node_id': task.node.uuid}
+ raise exception.InvalidParameterValue(msg)
+
+ task.driver.management.set_boot_mode(task, mode=mode)
def node_wait_for_power_state(task, new_state, timeout=None):