diff --git a/ironic/drivers/modules/deploy_utils.py b/ironic/drivers/modules/deploy_utils.py index 8ebe407d65..22c8f46d75 100644 --- a/ironic/drivers/modules/deploy_utils.py +++ b/ironic/drivers/modules/deploy_utils.py @@ -1550,6 +1550,22 @@ def reboot_to_finish_step(task, timeout=None): return get_async_step_return_state(task.node) +def step_error_handler(task, logmsg, errmsg=None): + """Run the correct handler for the current step. + + :param task: a TaskManager instance. + :param logmsg: Message to be logged. + :param errmsg: Message for the user. Optional, if not provided `logmsg` is + used. + """ + if task.node.provision_state in [states.CLEANING, states.CLEANWAIT]: + manager_utils.cleaning_error_handler(task, logmsg, errmsg=errmsg) + elif task.node.provision_state in [states.DEPLOYING, states.DEPLOYWAIT]: + manager_utils.deploying_error_handler(task, logmsg, errmsg=errmsg) + elif task.node.provision_state in [states.SERVICING, states.SERVICEWAIT]: + manager_utils.servicing_error_handler(task, logmsg, errmsg=errmsg) + + def get_root_device_for_deploy(node): """Get a root device requested for deployment or None. diff --git a/ironic/drivers/modules/redfish/bios.py b/ironic/drivers/modules/redfish/bios.py index 8bae07dfd6..6e72f0bfd2 100644 --- a/ironic/drivers/modules/redfish/bios.py +++ b/ironic/drivers/modules/redfish/bios.py @@ -18,8 +18,6 @@ import sushy from ironic.common import exception from ironic.common.i18n import _ -from ironic.common import states -from ironic.conductor import utils as manager_utils from ironic.drivers import base from ironic.drivers.modules import deploy_utils from ironic.drivers.modules.redfish import utils as redfish_utils @@ -364,7 +362,4 @@ class RedfishBIOS(base.BIOSInterface): last_error = (_('Redfish BIOS apply_configuration step failed. ' 'Attributes %(attrs)s are not updated.') % {'attrs': attrs_not_updated}) - if task.node.provision_state in [states.CLEANING, states.CLEANWAIT]: - manager_utils.cleaning_error_handler(task, last_error) - if task.node.provision_state in [states.DEPLOYING, states.DEPLOYWAIT]: - manager_utils.deploying_error_handler(task, error_msg, last_error) + deploy_utils.step_error_handler(task, error_msg, last_error)