save_and_reraise_exception() instead of raise

Instead of simply re-'raise'ing the exception, this uses oslo_utils'
excutils.save_and_reraise_exception() -- to handles cases where
the exception context might be cleared.

Change-Id: Ibfa26e8b1b4dd760b6de4321457593c8479d774d
This commit is contained in:
Ruby Loo 2017-04-19 16:41:52 -04:00
parent 350d8dec39
commit 7a78ea1a7f
1 changed files with 6 additions and 6 deletions

View File

@ -706,12 +706,12 @@ def try_set_boot_device(task, device, persistent=True):
manager_utils.node_set_boot_device(task, device,
persistent=persistent)
except exception.IPMIFailure:
if get_boot_mode_for_deploy(task.node) == 'uefi':
LOG.warning(_LW("ipmitool is unable to set boot device while "
"the node %s is in UEFI boot mode. Please set "
"the boot device manually."), task.node.uuid)
else:
raise
with excutils.save_and_reraise_exception() as ctxt:
if get_boot_mode_for_deploy(task.node) == 'uefi':
ctxt.reraise = False
LOG.warning(_LW("ipmitool is unable to set boot device while "
"the node %s is in UEFI boot mode. Please set "
"the boot device manually."), task.node.uuid)
def is_secure_boot_requested(node):