Add deploy steps for iLO BIOS interface
Change-Id: If2ee0e125c3fe2955495a74f87ef39072b277cb7 Story: 1722275 Task: 29904
This commit is contained in:
parent
3c9f2a834e
commit
f546e8f168
@ -36,6 +36,13 @@ ilo_error = importutils.try_import('proliantutils.exception')
|
|||||||
|
|
||||||
class IloBIOS(base.BIOSInterface):
|
class IloBIOS(base.BIOSInterface):
|
||||||
|
|
||||||
|
_APPLY_CONFIGURATION_ARGSINFO = {
|
||||||
|
'settings': {
|
||||||
|
'description': 'Dictionary with current BIOS configuration.',
|
||||||
|
'required': True
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
def get_properties(self):
|
def get_properties(self):
|
||||||
return ilo_common.REQUIRED_PROPERTIES
|
return ilo_common.REQUIRED_PROPERTIES
|
||||||
|
|
||||||
@ -56,21 +63,25 @@ class IloBIOS(base.BIOSInterface):
|
|||||||
def _execute_pre_boot_bios_step(self, task, step, data=None):
|
def _execute_pre_boot_bios_step(self, task, step, data=None):
|
||||||
"""Perform operations required prior to the reboot.
|
"""Perform operations required prior to the reboot.
|
||||||
|
|
||||||
Depending on the clean step, it executes the operations required
|
Depending on the step, it executes the operations required
|
||||||
and moves the node to CLEANWAIT state prior to reboot.
|
and moves the node to CLEANWAIT or DEPLOYWAIT state prior to reboot
|
||||||
|
based on the operation being performed.
|
||||||
:param task: a task from TaskManager.
|
:param task: a task from TaskManager.
|
||||||
:param step: name of the clean step to be performed
|
:param step: name of the clean step to be performed
|
||||||
:param data: if the clean step is apply_configuration it holds
|
:param data: if the clean step is apply_configuration it holds
|
||||||
the settings data.
|
the settings data.
|
||||||
:raises: NodeCleaningFailure if it fails any conditions expected
|
:raises: NodeCleaningFailure, on failure to execute of clean step.
|
||||||
|
:raises: InstanceDeployFailure, on failure to execute of deploy step.
|
||||||
"""
|
"""
|
||||||
node = task.node
|
node = task.node
|
||||||
|
|
||||||
if step not in ('apply_configuration', 'factory_reset'):
|
if step not in ('apply_configuration', 'factory_reset'):
|
||||||
errmsg = _('Could not find the step %(step)s for the '
|
errmsg = (_('Could not find the step %(step)s for the '
|
||||||
'node %(node)s.')
|
'node %(node)s.')
|
||||||
raise exception.NodeCleaningFailure(
|
% {'step': step, 'node': node.uuid})
|
||||||
errmsg % {'step': step, 'node': node.uuid})
|
if node.clean_step:
|
||||||
|
raise exception.NodeCleaningFailure(errmsg)
|
||||||
|
raise exception.InstanceDeployFailure(reason=errmsg)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
ilo_object = ilo_common.get_ilo_object(node)
|
ilo_object = ilo_common.get_ilo_object(node)
|
||||||
@ -80,20 +91,20 @@ class IloBIOS(base.BIOSInterface):
|
|||||||
exception.InvalidParameterValue,
|
exception.InvalidParameterValue,
|
||||||
ilo_error.IloError,
|
ilo_error.IloError,
|
||||||
ilo_error.IloCommandNotSupportedError) as ir_exception:
|
ilo_error.IloCommandNotSupportedError) as ir_exception:
|
||||||
errmsg = _('Clean step %(step)s failed '
|
errmsg = (_('Step %(step)s failed '
|
||||||
'on the node %(node)s with error: %(err)s')
|
'on the node %(node)s with error: %(err)s')
|
||||||
raise exception.NodeCleaningFailure(
|
% {'step': step, 'node': node.uuid, 'err': ir_exception})
|
||||||
errmsg % {'step': step, 'node': node.uuid,
|
if node.clean_step:
|
||||||
'err': ir_exception})
|
raise exception.NodeCleaningFailure(errmsg)
|
||||||
|
raise exception.InstanceDeployFailure(reason=errmsg)
|
||||||
|
|
||||||
deploy_opts = deploy_utils.build_agent_options(node)
|
deploy_opts = deploy_utils.build_agent_options(node)
|
||||||
task.driver.boot.prepare_ramdisk(task, deploy_opts)
|
task.driver.boot.prepare_ramdisk(task, deploy_opts)
|
||||||
manager_utils.node_power_action(task, states.REBOOT)
|
manager_utils.node_power_action(task, states.REBOOT)
|
||||||
|
|
||||||
|
deploy_utils.set_async_step_flags(node, reboot=True,
|
||||||
|
skip_current_step=False)
|
||||||
driver_internal_info = node.driver_internal_info
|
driver_internal_info = node.driver_internal_info
|
||||||
driver_internal_info['cleaning_reboot'] = True
|
|
||||||
driver_internal_info['skip_current_clean_step'] = False
|
|
||||||
|
|
||||||
if step == 'apply_configuration':
|
if step == 'apply_configuration':
|
||||||
driver_internal_info['apply_bios'] = True
|
driver_internal_info['apply_bios'] = True
|
||||||
else:
|
else:
|
||||||
@ -101,7 +112,7 @@ class IloBIOS(base.BIOSInterface):
|
|||||||
|
|
||||||
node.driver_internal_info = driver_internal_info
|
node.driver_internal_info = driver_internal_info
|
||||||
node.save()
|
node.save()
|
||||||
return states.CLEANWAIT
|
return deploy_utils.get_async_step_return_state(node)
|
||||||
|
|
||||||
def _execute_post_boot_bios_step(self, task, step):
|
def _execute_post_boot_bios_step(self, task, step):
|
||||||
"""Perform operations required after the reboot.
|
"""Perform operations required after the reboot.
|
||||||
@ -110,7 +121,8 @@ class IloBIOS(base.BIOSInterface):
|
|||||||
with the clean step post reboot.
|
with the clean step post reboot.
|
||||||
:param task: a task from TaskManager.
|
:param task: a task from TaskManager.
|
||||||
:param step: name of the clean step to be performed
|
:param step: name of the clean step to be performed
|
||||||
:raises: NodeCleaningFailure if it fails any conditions expected
|
:raises: NodeCleaningFailure, on failure to execute of clean step.
|
||||||
|
:raises: InstanceDeployFailure, on failure to execute of deploy step.
|
||||||
"""
|
"""
|
||||||
node = task.node
|
node = task.node
|
||||||
|
|
||||||
@ -121,10 +133,12 @@ class IloBIOS(base.BIOSInterface):
|
|||||||
task.node.save()
|
task.node.save()
|
||||||
|
|
||||||
if step not in ('apply_configuration', 'factory_reset'):
|
if step not in ('apply_configuration', 'factory_reset'):
|
||||||
errmsg = _('Could not find the step %(step)s for the '
|
errmsg = (_('Could not find the step %(step)s for the '
|
||||||
'node %(node)s.')
|
'node %(node)s.')
|
||||||
raise exception.NodeCleaningFailure(
|
% {'step': step, 'node': node.uuid})
|
||||||
errmsg % {'step': step, 'node': node.uuid})
|
if node.clean_step:
|
||||||
|
raise exception.NodeCleaningFailure(errmsg)
|
||||||
|
raise exception.InstanceDeployFailure(reason=errmsg)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
ilo_object = ilo_common.get_ilo_object(node)
|
ilo_object = ilo_common.get_ilo_object(node)
|
||||||
@ -133,35 +147,34 @@ class IloBIOS(base.BIOSInterface):
|
|||||||
exception.InvalidParameterValue,
|
exception.InvalidParameterValue,
|
||||||
ilo_error.IloError,
|
ilo_error.IloError,
|
||||||
ilo_error.IloCommandNotSupportedError) as ir_exception:
|
ilo_error.IloCommandNotSupportedError) as ir_exception:
|
||||||
|
errmsg = (_('Step %(step)s failed '
|
||||||
errmsg = _('Clean step %(step)s failed '
|
'on the node %(node)s with error: %(err)s')
|
||||||
'on the node %(node)s with error: %(err)s')
|
% {'step': step, 'node': node.uuid, 'err': ir_exception})
|
||||||
raise exception.NodeCleaningFailure(
|
if node.clean_step:
|
||||||
errmsg % {'step': step, 'node': node.uuid,
|
raise exception.NodeCleaningFailure(errmsg)
|
||||||
'err': ir_exception})
|
raise exception.InstanceDeployFailure(reason=errmsg)
|
||||||
|
|
||||||
if status.get('status') == 'failed':
|
if status.get('status') == 'failed':
|
||||||
errmsg = _('Clean step %(step)s failed '
|
errmsg = (_('Step %(step)s failed '
|
||||||
'on the node %(node)s with error: %(err)s')
|
'on the node %(node)s with error: %(err)s')
|
||||||
raise exception.NodeCleaningFailure(
|
% {'step': step, 'node': node.uuid,
|
||||||
errmsg % {'step': step, 'node': node.uuid,
|
'err': status.get('results')})
|
||||||
'err': status.get('results')})
|
if node.clean_step:
|
||||||
|
raise exception.NodeCleaningFailure(errmsg)
|
||||||
|
raise exception.InstanceDeployFailure(reason=errmsg)
|
||||||
|
|
||||||
@METRICS.timer('IloBIOS.apply_configuration')
|
@METRICS.timer('IloBIOS.apply_configuration')
|
||||||
@base.clean_step(priority=0, abortable=False, argsinfo={
|
@base.deploy_step(priority=0, argsinfo=_APPLY_CONFIGURATION_ARGSINFO)
|
||||||
'settings': {
|
@base.clean_step(priority=0, abortable=False,
|
||||||
'description': "Dictionary with current BIOS configuration.",
|
argsinfo=_APPLY_CONFIGURATION_ARGSINFO)
|
||||||
'required': True
|
|
||||||
}
|
|
||||||
})
|
|
||||||
@base.cache_bios_settings
|
@base.cache_bios_settings
|
||||||
def apply_configuration(self, task, settings):
|
def apply_configuration(self, task, settings):
|
||||||
"""Applies the provided configuration on the node.
|
"""Applies the provided configuration on the node.
|
||||||
|
|
||||||
:param task: a TaskManager instance.
|
:param task: a TaskManager instance.
|
||||||
:param settings: Settings intended to be applied on the node.
|
:param settings: Settings intended to be applied on the node.
|
||||||
:raises: NodeCleaningFailure when applying the configuration on
|
:raises: NodeCleaningFailure, on failure to execute of clean step.
|
||||||
the node fails.
|
:raises: InstanceDeployFailure, on failure to execute of deploy step.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
node = task.node
|
node = task.node
|
||||||
@ -177,14 +190,15 @@ class IloBIOS(base.BIOSInterface):
|
|||||||
task, 'apply_configuration')
|
task, 'apply_configuration')
|
||||||
|
|
||||||
@METRICS.timer('IloBIOS.factory_reset')
|
@METRICS.timer('IloBIOS.factory_reset')
|
||||||
|
@base.deploy_step(priority=0)
|
||||||
@base.clean_step(priority=0, abortable=False)
|
@base.clean_step(priority=0, abortable=False)
|
||||||
@base.cache_bios_settings
|
@base.cache_bios_settings
|
||||||
def factory_reset(self, task):
|
def factory_reset(self, task):
|
||||||
"""Reset the BIOS settings to factory configuration.
|
"""Reset the BIOS settings to factory configuration.
|
||||||
|
|
||||||
:param task: a TaskManager instance.
|
:param task: a TaskManager instance.
|
||||||
:raises: NodeCleaningFailure when IloError or any other exception
|
:raises: NodeCleaningFailure, on failure to execute of clean step.
|
||||||
is caught.
|
:raises: InstanceDeployFailure, on failure to execute of deploy step.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
node = task.node
|
node = task.node
|
||||||
@ -200,15 +214,13 @@ class IloBIOS(base.BIOSInterface):
|
|||||||
"""Store the BIOS settings in the database.
|
"""Store the BIOS settings in the database.
|
||||||
|
|
||||||
:param task: a TaskManager instance.
|
:param task: a TaskManager instance.
|
||||||
:raises: NodeCleaningFailure when IloError or any other exception
|
:raises: NodeCleaningFailure, on failure to execute of clean step.
|
||||||
is caught.
|
:raises: InstanceDeployFailure, on failure to execute of deploy step.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
node = task.node
|
node = task.node
|
||||||
nodeid = node.id
|
nodeid = node.id
|
||||||
|
|
||||||
errmsg = _("Caching BIOS settings failed "
|
|
||||||
"on node %(node)s with error: %(err)s")
|
|
||||||
try:
|
try:
|
||||||
ilo_object = ilo_common.get_ilo_object(node)
|
ilo_object = ilo_common.get_ilo_object(node)
|
||||||
bios_settings = ilo_object.get_current_bios_settings()
|
bios_settings = ilo_object.get_current_bios_settings()
|
||||||
@ -217,8 +229,12 @@ class IloBIOS(base.BIOSInterface):
|
|||||||
exception.InvalidParameterValue,
|
exception.InvalidParameterValue,
|
||||||
ilo_error.IloError,
|
ilo_error.IloError,
|
||||||
ilo_error.IloCommandNotSupportedError) as ir_exception:
|
ilo_error.IloCommandNotSupportedError) as ir_exception:
|
||||||
raise exception.NodeCleaningFailure(
|
errmsg = (_("Caching BIOS settings failed "
|
||||||
errmsg % {'node': node.uuid, 'err': ir_exception})
|
"on node %(node)s with error: %(err)s")
|
||||||
|
% {'node': node.uuid, 'err': ir_exception})
|
||||||
|
if node.clean_step:
|
||||||
|
raise exception.NodeCleaningFailure(errmsg)
|
||||||
|
raise exception.InstanceDeployFailure(reason=errmsg)
|
||||||
|
|
||||||
fmt_bios_settings = []
|
fmt_bios_settings = []
|
||||||
|
|
||||||
|
@ -55,13 +55,19 @@ class IloBiosTestCase(test_common.BaseIloTest):
|
|||||||
def _test_ilo_error(self, exc_cls,
|
def _test_ilo_error(self, exc_cls,
|
||||||
test_methods_not_called,
|
test_methods_not_called,
|
||||||
test_methods_called,
|
test_methods_called,
|
||||||
method_details, exception_mock):
|
method_details, exception_mock,
|
||||||
|
operation='cleaning'):
|
||||||
exception_mock.side_effect = exc_cls('error')
|
exception_mock.side_effect = exc_cls('error')
|
||||||
method = method_details.get("name")
|
method = method_details.get("name")
|
||||||
args = method_details.get("args")
|
args = method_details.get("args")
|
||||||
self.assertRaises(exception.NodeCleaningFailure,
|
if self.node.clean_step:
|
||||||
method,
|
self.assertRaises(exception.NodeCleaningFailure,
|
||||||
*args)
|
method,
|
||||||
|
*args)
|
||||||
|
else:
|
||||||
|
self.assertRaises(exception.InstanceDeployFailure,
|
||||||
|
method,
|
||||||
|
*args)
|
||||||
for test_method in test_methods_not_called:
|
for test_method in test_methods_not_called:
|
||||||
test_method.assert_not_called()
|
test_method.assert_not_called()
|
||||||
for called_method in test_methods_called:
|
for called_method in test_methods_called:
|
||||||
@ -168,8 +174,8 @@ class IloBiosTestCase(test_common.BaseIloTest):
|
|||||||
driver_info = task.node.driver_internal_info
|
driver_info = task.node.driver_internal_info
|
||||||
self.assertTrue(
|
self.assertTrue(
|
||||||
all(x in driver_info for x in (
|
all(x in driver_info for x in (
|
||||||
'apply_bios', 'cleaning_reboot',
|
'apply_bios', 'deployment_reboot',
|
||||||
'skip_current_clean_step')))
|
'skip_current_deploy_step')))
|
||||||
ilo_object_mock.set_bios_settings.assert_called_once_with(data)
|
ilo_object_mock.set_bios_settings.assert_called_once_with(data)
|
||||||
self.assertFalse(ilo_object_mock.reset_bios_to_default.called)
|
self.assertFalse(ilo_object_mock.reset_bios_to_default.called)
|
||||||
build_agent_mock.assert_called_once_with(task.node)
|
build_agent_mock.assert_called_once_with(task.node)
|
||||||
@ -184,112 +190,223 @@ class IloBiosTestCase(test_common.BaseIloTest):
|
|||||||
autospec=True)
|
autospec=True)
|
||||||
@mock.patch.object(ilo_common, 'get_ilo_object', spec_set=True,
|
@mock.patch.object(ilo_common, 'get_ilo_object', spec_set=True,
|
||||||
autospec=True)
|
autospec=True)
|
||||||
def test__execute_pre_boot_bios_step_factory_reset(
|
def _test__execute_pre_boot_bios_step(
|
||||||
self, get_ilo_object_mock, build_agent_mock,
|
self, get_ilo_mock, build_agent_mock,
|
||||||
node_power_mock, prepare_mock):
|
node_power_mock, prepare_mock):
|
||||||
|
if self.node.clean_step:
|
||||||
|
step_data = self.node.clean_step
|
||||||
|
check_fields = ['cleaning_reboot', 'skip_current_clean_step']
|
||||||
|
else:
|
||||||
|
step_data = self.node.deploy_step
|
||||||
|
check_fields = ['deployment_reboot', 'skip_current_deploy_step']
|
||||||
|
|
||||||
|
data = step_data['argsinfo'].get('settings', None)
|
||||||
|
step = step_data['step']
|
||||||
|
if step == 'factory_reset':
|
||||||
|
check_fields.append('reset_bios')
|
||||||
|
elif step == 'apply_configuration':
|
||||||
|
check_fields.append('apply_bios')
|
||||||
|
|
||||||
with task_manager.acquire(self.context, self.node.uuid,
|
with task_manager.acquire(self.context, self.node.uuid,
|
||||||
shared=True) as task:
|
shared=True) as task:
|
||||||
ilo_object_mock = get_ilo_object_mock.return_value
|
ilo_mock = get_ilo_mock.return_value
|
||||||
data = {
|
|
||||||
"SET_A": "VAL_A",
|
|
||||||
"SET_B": "VAL_B",
|
|
||||||
"SET_C": "VAL_C",
|
|
||||||
"SET_D": "VAL_D"
|
|
||||||
}
|
|
||||||
step = 'factory_reset'
|
|
||||||
task.driver.bios._execute_pre_boot_bios_step(task, step, data)
|
task.driver.bios._execute_pre_boot_bios_step(task, step, data)
|
||||||
driver_info = task.node.driver_internal_info
|
drv_internal_info = task.node.driver_internal_info
|
||||||
self.assertTrue(
|
self.assertTrue(
|
||||||
all(x in driver_info for x in (
|
all(x in drv_internal_info for x in check_fields))
|
||||||
'reset_bios', 'cleaning_reboot',
|
|
||||||
'skip_current_clean_step')))
|
if step == 'factory_reset':
|
||||||
ilo_object_mock.reset_bios_to_default.assert_called_once_with()
|
ilo_mock.reset_bios_to_default.assert_called_once_with()
|
||||||
self.assertFalse(ilo_object_mock.set_bios_settings.called)
|
|
||||||
|
elif step == 'apply_configuration':
|
||||||
|
ilo_mock.set_bios_settings.assert_called_once_with(data)
|
||||||
|
|
||||||
build_agent_mock.assert_called_once_with(task.node)
|
build_agent_mock.assert_called_once_with(task.node)
|
||||||
self.assertTrue(prepare_mock.called)
|
self.assertTrue(prepare_mock.called)
|
||||||
self.assertTrue(node_power_mock.called)
|
self.assertTrue(node_power_mock.called)
|
||||||
|
|
||||||
@mock.patch.object(ilo_common, 'get_ilo_object', spec_set=True,
|
def test__execute_pre_boot_bios_step_apply_conf_cleaning(self):
|
||||||
autospec=True)
|
data = {"SET_A": "VAL_A",
|
||||||
def test__execute_pre_boot_bios_step_invalid(
|
|
||||||
self, get_ilo_object_mock):
|
|
||||||
|
|
||||||
with task_manager.acquire(self.context, self.node.uuid,
|
|
||||||
shared=True) as task:
|
|
||||||
data = {
|
|
||||||
"SET_A": "VAL_A",
|
|
||||||
"SET_B": "VAL_B",
|
"SET_B": "VAL_B",
|
||||||
"SET_C": "VAL_C",
|
"SET_C": "VAL_C",
|
||||||
"SET_D": "VAL_D"
|
"SET_D": "VAL_D"}
|
||||||
}
|
self.node.clean_step = {'priority': 100, 'interface': 'bios',
|
||||||
step = 'invalid_step'
|
'step': 'apply_configuration',
|
||||||
self.assertRaises(exception.NodeCleaningFailure,
|
'argsinfo': {'settings': data}}
|
||||||
task.driver.bios._execute_pre_boot_bios_step,
|
self.node.save()
|
||||||
task, step, data)
|
self._test__execute_pre_boot_bios_step()
|
||||||
|
|
||||||
|
def test__execute_pre_boot_bios_step_apply_conf_deploying(self):
|
||||||
|
data = {"SET_A": "VAL_A",
|
||||||
|
"SET_B": "VAL_B",
|
||||||
|
"SET_C": "VAL_C",
|
||||||
|
"SET_D": "VAL_D"}
|
||||||
|
self.node.deploy_step = {'priority': 100, 'interface': 'bios',
|
||||||
|
'step': 'apply_configuration',
|
||||||
|
'argsinfo': {'settings': data}}
|
||||||
|
self.node.save()
|
||||||
|
self._test__execute_pre_boot_bios_step()
|
||||||
|
|
||||||
|
def test__execute_pre_boot_bios_step_factory_reset_cleaning(self):
|
||||||
|
self.node.clean_step = {'priority': 100, 'interface': 'bios',
|
||||||
|
'step': 'factory_reset', 'argsinfo': {}}
|
||||||
|
self.node.save()
|
||||||
|
self._test__execute_pre_boot_bios_step()
|
||||||
|
|
||||||
|
def test__execute_pre_boot_bios_step_factory_reset_deploying(self):
|
||||||
|
self.node.deploy_step = {'priority': 100, 'interface': 'bios',
|
||||||
|
'step': 'factory_reset', 'argsinfo': {}}
|
||||||
|
self.node.save()
|
||||||
|
self._test__execute_pre_boot_bios_step()
|
||||||
|
|
||||||
@mock.patch.object(ilo_common, 'get_ilo_object', spec_set=True,
|
@mock.patch.object(ilo_common, 'get_ilo_object', spec_set=True,
|
||||||
autospec=True)
|
autospec=True)
|
||||||
def test__execute_pre_boot_bios_step_iloobj_failed(
|
def _test__execute_pre_boot_bios_step_invalid(
|
||||||
self, get_ilo_object_mock):
|
self, get_ilo_object_mock):
|
||||||
|
if self.node.clean_step:
|
||||||
|
step_data = self.node.clean_step
|
||||||
|
exept = exception.NodeCleaningFailure
|
||||||
|
else:
|
||||||
|
step_data = self.node.deploy_step
|
||||||
|
exept = exception.InstanceDeployFailure
|
||||||
|
|
||||||
|
data = step_data['argsinfo'].get('settings', None)
|
||||||
|
step = step_data['step']
|
||||||
with task_manager.acquire(self.context, self.node.uuid,
|
with task_manager.acquire(self.context, self.node.uuid,
|
||||||
shared=True) as task:
|
shared=True) as task:
|
||||||
data = {
|
|
||||||
"SET_A": "VAL_A",
|
|
||||||
"SET_B": "VAL_B",
|
|
||||||
"SET_C": "VAL_C",
|
|
||||||
"SET_D": "VAL_D"
|
|
||||||
}
|
|
||||||
get_ilo_object_mock.side_effect = exception.MissingParameterValue(
|
|
||||||
'err')
|
|
||||||
step = 'apply_configuration'
|
|
||||||
self.assertRaises(exception.NodeCleaningFailure,
|
|
||||||
task.driver.bios._execute_pre_boot_bios_step,
|
|
||||||
task, step, data)
|
|
||||||
|
|
||||||
@mock.patch.object(ilo_common, 'get_ilo_object', spec_set=True,
|
|
||||||
autospec=True)
|
|
||||||
def test__execute_pre_boot_bios_step_set_bios_failed(
|
|
||||||
self, get_ilo_object_mock):
|
|
||||||
|
|
||||||
with task_manager.acquire(self.context, self.node.uuid,
|
|
||||||
shared=True) as task:
|
|
||||||
data = {
|
|
||||||
"SET_A": "VAL_A",
|
|
||||||
"SET_B": "VAL_B",
|
|
||||||
"SET_C": "VAL_C",
|
|
||||||
"SET_D": "VAL_D"
|
|
||||||
}
|
|
||||||
ilo_object_mock = get_ilo_object_mock.return_value
|
ilo_object_mock = get_ilo_object_mock.return_value
|
||||||
ilo_object_mock.set_bios_settings.side_effect = ilo_error.IloError(
|
ilo_object_mock.set_bios_settings.side_effect = ilo_error.IloError(
|
||||||
'err')
|
'err')
|
||||||
step = 'apply_configuration'
|
if task.node.clean_step:
|
||||||
self.assertRaises(exception.NodeCleaningFailure,
|
exept = exception.NodeCleaningFailure
|
||||||
|
else:
|
||||||
|
exept = exception.InstanceDeployFailure
|
||||||
|
self.assertRaises(exept,
|
||||||
task.driver.bios._execute_pre_boot_bios_step,
|
task.driver.bios._execute_pre_boot_bios_step,
|
||||||
task, step, data)
|
task, step, data)
|
||||||
|
|
||||||
|
def test__execute_pre_boot_bios_step_invalid_cleaning(self):
|
||||||
|
data = {"SET_A": "VAL_A",
|
||||||
|
"SET_B": "VAL_B",
|
||||||
|
"SET_C": "VAL_C",
|
||||||
|
"SET_D": "VAL_D"}
|
||||||
|
self.node.clean_step = {'priority': 100, 'interface': 'bios',
|
||||||
|
'step': 'invalid_step',
|
||||||
|
'argsinfo': {'settings': data}}
|
||||||
|
self.node.save()
|
||||||
|
self._test__execute_pre_boot_bios_step_invalid()
|
||||||
|
|
||||||
|
def test__execute_pre_boot_bios_step_invalid_deploying(self):
|
||||||
|
data = {"SET_A": "VAL_A",
|
||||||
|
"SET_B": "VAL_B",
|
||||||
|
"SET_C": "VAL_C",
|
||||||
|
"SET_D": "VAL_D"}
|
||||||
|
self.node.deploy_step = {'priority': 100, 'interface': 'bios',
|
||||||
|
'step': 'invalid_step',
|
||||||
|
'argsinfo': {'settings': data}}
|
||||||
|
self.node.save()
|
||||||
|
self._test__execute_pre_boot_bios_step_invalid()
|
||||||
|
|
||||||
|
@mock.patch.object(ilo_common, 'get_ilo_object', autospec=True)
|
||||||
|
def _test__execute_pre_boot_bios_step_ilo_fail(self, get_ilo_mock):
|
||||||
|
if self.node.clean_step:
|
||||||
|
step_data = self.node.clean_step
|
||||||
|
exept = exception.NodeCleaningFailure
|
||||||
|
else:
|
||||||
|
step_data = self.node.deploy_step
|
||||||
|
exept = exception.InstanceDeployFailure
|
||||||
|
|
||||||
|
data = step_data['argsinfo'].get('settings', None)
|
||||||
|
step = step_data['step']
|
||||||
|
with task_manager.acquire(self.context, self.node.uuid,
|
||||||
|
shared=True) as task:
|
||||||
|
get_ilo_mock.side_effect = exception.MissingParameterValue('err')
|
||||||
|
self.assertRaises(exept,
|
||||||
|
task.driver.bios._execute_pre_boot_bios_step,
|
||||||
|
task, step, data)
|
||||||
|
|
||||||
|
def test__execute_pre_boot_bios_step_iloobj_failed_cleaning(self):
|
||||||
|
data = {"SET_A": "VAL_A",
|
||||||
|
"SET_B": "VAL_B",
|
||||||
|
"SET_C": "VAL_C",
|
||||||
|
"SET_D": "VAL_D"}
|
||||||
|
self.node.clean_step = {'priority': 100, 'interface': 'bios',
|
||||||
|
'step': 'apply_configuration',
|
||||||
|
'argsinfo': {'settings': data}}
|
||||||
|
self.node.save()
|
||||||
|
self._test__execute_pre_boot_bios_step_ilo_fail()
|
||||||
|
|
||||||
|
def test__execute_pre_boot_bios_step_iloobj_failed_deploying(self):
|
||||||
|
data = {"SET_A": "VAL_A",
|
||||||
|
"SET_B": "VAL_B",
|
||||||
|
"SET_C": "VAL_C",
|
||||||
|
"SET_D": "VAL_D"}
|
||||||
|
self.node.deploy_step = {'priority': 100, 'interface': 'bios',
|
||||||
|
'step': 'apply_configuration',
|
||||||
|
'argsinfo': {'settings': data}}
|
||||||
|
self.node.save()
|
||||||
|
self._test__execute_pre_boot_bios_step_ilo_fail()
|
||||||
|
|
||||||
@mock.patch.object(ilo_common, 'get_ilo_object', spec_set=True,
|
@mock.patch.object(ilo_common, 'get_ilo_object', spec_set=True,
|
||||||
autospec=True)
|
autospec=True)
|
||||||
def test__execute_pre_boot_bios_step_reset_bios_failed(
|
def _test__execute_pre_boot_bios_step_set_bios_failed(
|
||||||
self, get_ilo_object_mock):
|
self, get_ilo_object_mock):
|
||||||
|
if self.node.clean_step:
|
||||||
|
step_data = self.node.clean_step
|
||||||
|
exept = exception.NodeCleaningFailure
|
||||||
|
else:
|
||||||
|
step_data = self.node.deploy_step
|
||||||
|
exept = exception.InstanceDeployFailure
|
||||||
|
|
||||||
|
data = step_data['argsinfo'].get('settings', None)
|
||||||
|
step = step_data['step']
|
||||||
with task_manager.acquire(self.context, self.node.uuid,
|
with task_manager.acquire(self.context, self.node.uuid,
|
||||||
shared=True) as task:
|
shared=True) as task:
|
||||||
data = {
|
|
||||||
"SET_A": "VAL_A",
|
|
||||||
"SET_B": "VAL_B",
|
|
||||||
"SET_C": "VAL_C",
|
|
||||||
"SET_D": "VAL_D"
|
|
||||||
}
|
|
||||||
ilo_object_mock = get_ilo_object_mock.return_value
|
ilo_object_mock = get_ilo_object_mock.return_value
|
||||||
ilo_object_mock.reset_bios_to_default.side_effect = (
|
ilo_object_mock.set_bios_settings.side_effect = ilo_error.IloError(
|
||||||
ilo_error.IloError('err'))
|
'err')
|
||||||
step = 'factory_reset'
|
if task.node.clean_step:
|
||||||
self.assertRaises(exception.NodeCleaningFailure,
|
exept = exception.NodeCleaningFailure
|
||||||
|
else:
|
||||||
|
exept = exception.InstanceDeployFailure
|
||||||
|
self.assertRaises(exept,
|
||||||
task.driver.bios._execute_pre_boot_bios_step,
|
task.driver.bios._execute_pre_boot_bios_step,
|
||||||
task, step, data)
|
task, step, data)
|
||||||
|
|
||||||
|
def test__execute_pre_boot_bios_step_set_bios_failed_cleaning(self):
|
||||||
|
data = {"SET_A": "VAL_A",
|
||||||
|
"SET_B": "VAL_B",
|
||||||
|
"SET_C": "VAL_C",
|
||||||
|
"SET_D": "VAL_D"}
|
||||||
|
self.node.clean_step = {'priority': 100, 'interface': 'bios',
|
||||||
|
'step': 'apply_configuration',
|
||||||
|
'argsinfo': {'settings': data}}
|
||||||
|
self.node.save()
|
||||||
|
self._test__execute_post_boot_bios_get_settings_failed()
|
||||||
|
|
||||||
|
def test__execute_pre_boot_bios_step_set_bios_failed_deploying(self):
|
||||||
|
data = {"SET_A": "VAL_A",
|
||||||
|
"SET_B": "VAL_B",
|
||||||
|
"SET_C": "VAL_C",
|
||||||
|
"SET_D": "VAL_D"}
|
||||||
|
self.node.deploy_step = {'priority': 100, 'interface': 'bios',
|
||||||
|
'step': 'apply_configuration',
|
||||||
|
'argsinfo': {'settings': data}}
|
||||||
|
self.node.save()
|
||||||
|
self._test__execute_post_boot_bios_get_settings_failed()
|
||||||
|
|
||||||
|
def test__execute_pre_boot_bios_step_reset_bios_failed_cleaning(self):
|
||||||
|
self.node.clean_step = {'priority': 100, 'interface': 'bios',
|
||||||
|
'step': 'factory_reset', 'argsinfo': {}}
|
||||||
|
self.node.save()
|
||||||
|
self._test__execute_post_boot_bios_get_settings_failed()
|
||||||
|
|
||||||
|
def test__execute_pre_boot_bios_step_reset_bios_failed_deploying(self):
|
||||||
|
self.node.deploy_step = {'priority': 100, 'interface': 'bios',
|
||||||
|
'step': 'factory_reset', 'argsinfo': {}}
|
||||||
|
self.node.save()
|
||||||
|
self._test__execute_post_boot_bios_get_settings_failed()
|
||||||
|
|
||||||
@mock.patch.object(ilo_common, 'get_ilo_object', spec_set=True,
|
@mock.patch.object(ilo_common, 'get_ilo_object', spec_set=True,
|
||||||
autospec=True)
|
autospec=True)
|
||||||
def test__execute_post_boot_bios_step_apply_configuration(
|
def test__execute_post_boot_bios_step_apply_configuration(
|
||||||
@ -328,7 +445,7 @@ class IloBiosTestCase(test_common.BaseIloTest):
|
|||||||
|
|
||||||
@mock.patch.object(ilo_common, 'get_ilo_object', spec_set=True,
|
@mock.patch.object(ilo_common, 'get_ilo_object', spec_set=True,
|
||||||
autospec=True)
|
autospec=True)
|
||||||
def test__execute_post_boot_bios_step_invalid(
|
def _test__execute_post_boot_bios_step_invalid(
|
||||||
self, get_ilo_object_mock):
|
self, get_ilo_object_mock):
|
||||||
|
|
||||||
with task_manager.acquire(self.context, self.node.uuid,
|
with task_manager.acquire(self.context, self.node.uuid,
|
||||||
@ -338,35 +455,73 @@ class IloBiosTestCase(test_common.BaseIloTest):
|
|||||||
task.node.driver_internal_info = driver_info
|
task.node.driver_internal_info = driver_info
|
||||||
task.node.save()
|
task.node.save()
|
||||||
step = 'invalid_step'
|
step = 'invalid_step'
|
||||||
self.assertRaises(exception.NodeCleaningFailure,
|
if self.node.clean_step:
|
||||||
|
exept = exception.NodeCleaningFailure
|
||||||
|
else:
|
||||||
|
exept = exception.InstanceDeployFailure
|
||||||
|
self.assertRaises(exept,
|
||||||
task.driver.bios._execute_post_boot_bios_step,
|
task.driver.bios._execute_post_boot_bios_step,
|
||||||
task, step)
|
task, step)
|
||||||
self.assertTrue(
|
self.assertTrue(
|
||||||
'apply_bios' not in task.node.driver_internal_info)
|
'apply_bios' not in task.node.driver_internal_info)
|
||||||
|
|
||||||
|
def test__execute_post_boot_bios_step_invalid_cleaning(self):
|
||||||
|
self.node.clean_step = {'priority': 100, 'interface': 'bios',
|
||||||
|
'step': u'apply_configuration',
|
||||||
|
'argsinfo': {'settings': {'a': 1, 'b': 2}}}
|
||||||
|
self.node.save()
|
||||||
|
self._test__execute_post_boot_bios_step_invalid()
|
||||||
|
|
||||||
|
def test__execute_post_boot_bios_step_invalid_deploy(self):
|
||||||
|
self.node.deploy_step = {'priority': 100, 'interface': 'bios',
|
||||||
|
'step': u'apply_configuration',
|
||||||
|
'argsinfo': {'settings': {'a': 1, 'b': 2}}}
|
||||||
|
self.node.save()
|
||||||
|
self._test__execute_post_boot_bios_step_invalid()
|
||||||
|
|
||||||
@mock.patch.object(ilo_common, 'get_ilo_object', spec_set=True,
|
@mock.patch.object(ilo_common, 'get_ilo_object', spec_set=True,
|
||||||
autospec=True)
|
autospec=True)
|
||||||
def test__execute_post_boot_bios_step_iloobj_failed(
|
def _test__execute_post_boot_bios_step_iloobj_failed(
|
||||||
self, get_ilo_object_mock):
|
self, get_ilo_object_mock):
|
||||||
|
|
||||||
|
if self.node.clean_step:
|
||||||
|
step = self.node.clean_step['step']
|
||||||
|
exept = exception.NodeCleaningFailure
|
||||||
|
if self.node.deploy_step:
|
||||||
|
step = self.node.deploy_step['step']
|
||||||
|
exept = exception.InstanceDeployFailure
|
||||||
|
driver_internal_info = self.node.driver_internal_info
|
||||||
|
driver_internal_info['apply_bios'] = True
|
||||||
|
self.node.driver_internal_info = driver_internal_info
|
||||||
|
self.node.save()
|
||||||
with task_manager.acquire(self.context, self.node.uuid,
|
with task_manager.acquire(self.context, self.node.uuid,
|
||||||
shared=True) as task:
|
shared=True) as task:
|
||||||
driver_info = task.node.driver_internal_info
|
|
||||||
driver_info.update({'apply_bios': True})
|
|
||||||
task.node.driver_internal_info = driver_info
|
|
||||||
task.node.save()
|
|
||||||
get_ilo_object_mock.side_effect = exception.MissingParameterValue(
|
get_ilo_object_mock.side_effect = exception.MissingParameterValue(
|
||||||
'err')
|
'err')
|
||||||
step = 'apply_configuration'
|
step = 'apply_configuration'
|
||||||
self.assertRaises(exception.NodeCleaningFailure,
|
self.assertRaises(exept,
|
||||||
task.driver.bios._execute_post_boot_bios_step,
|
task.driver.bios._execute_post_boot_bios_step,
|
||||||
task, step)
|
task, step)
|
||||||
self.assertTrue(
|
self.assertTrue(
|
||||||
'apply_bios' not in task.node.driver_internal_info)
|
'apply_bios' not in task.node.driver_internal_info)
|
||||||
|
|
||||||
|
def test__execute_post_boot_bios_step_iloobj_failed_cleaning(self):
|
||||||
|
self.node.clean_step = {'priority': 100, 'interface': 'bios',
|
||||||
|
'step': u'apply_configuration',
|
||||||
|
'argsinfo': {'settings': {'a': 1, 'b': 2}}}
|
||||||
|
self.node.save()
|
||||||
|
self._test__execute_post_boot_bios_step_iloobj_failed()
|
||||||
|
|
||||||
|
def test__execute_post_boot_bios_step_iloobj_failed_deploy(self):
|
||||||
|
self.node.deploy_step = {'priority': 100, 'interface': 'bios',
|
||||||
|
'step': u'apply_configuration',
|
||||||
|
'argsinfo': {'settings': {'a': 1, 'b': 2}}}
|
||||||
|
self.node.save()
|
||||||
|
self._test__execute_post_boot_bios_step_iloobj_failed()
|
||||||
|
|
||||||
@mock.patch.object(ilo_common, 'get_ilo_object', spec_set=True,
|
@mock.patch.object(ilo_common, 'get_ilo_object', spec_set=True,
|
||||||
autospec=True)
|
autospec=True)
|
||||||
def test__execute_post_boot_bios_get_settings_error(
|
def _test__execute_post_boot_bios_get_settings_error(
|
||||||
self, get_ilo_object_mock):
|
self, get_ilo_object_mock):
|
||||||
|
|
||||||
with task_manager.acquire(self.context, self.node.uuid,
|
with task_manager.acquire(self.context, self.node.uuid,
|
||||||
@ -390,9 +545,25 @@ class IloBiosTestCase(test_common.BaseIloTest):
|
|||||||
self.assertTrue(
|
self.assertTrue(
|
||||||
'apply_bios' not in task.node.driver_internal_info)
|
'apply_bios' not in task.node.driver_internal_info)
|
||||||
|
|
||||||
|
def test__execute_post_boot_bios_get_settings_error_cleaning(
|
||||||
|
self):
|
||||||
|
self.node.clean_step = {'priority': 100, 'interface': 'bios',
|
||||||
|
'step': u'apply_configuration',
|
||||||
|
'argsinfo': {'settings': {'a': 1, 'b': 2}}}
|
||||||
|
self.node.save()
|
||||||
|
self._test__execute_post_boot_bios_get_settings_error()
|
||||||
|
|
||||||
|
def test__execute_post_boot_bios_get_settings_error_deploying(
|
||||||
|
self):
|
||||||
|
self.node.deploy_step = {'priority': 100, 'interface': 'bios',
|
||||||
|
'step': 'apply_configuration',
|
||||||
|
'argsinfo': {'settings': {'a': 1, 'b': 2}}}
|
||||||
|
self.node.save()
|
||||||
|
self._test__execute_post_boot_bios_get_settings_error()
|
||||||
|
|
||||||
@mock.patch.object(ilo_common, 'get_ilo_object', spec_set=True,
|
@mock.patch.object(ilo_common, 'get_ilo_object', spec_set=True,
|
||||||
autospec=True)
|
autospec=True)
|
||||||
def test__execute_post_boot_bios_get_settings_failed(
|
def _test__execute_post_boot_bios_get_settings_failed(
|
||||||
self, get_ilo_object_mock):
|
self, get_ilo_object_mock):
|
||||||
|
|
||||||
with task_manager.acquire(self.context, self.node.uuid,
|
with task_manager.acquire(self.context, self.node.uuid,
|
||||||
@ -405,12 +576,30 @@ class IloBiosTestCase(test_common.BaseIloTest):
|
|||||||
ilo_object_mock.get_bios_settings_result.return_value = (
|
ilo_object_mock.get_bios_settings_result.return_value = (
|
||||||
{'status': 'failed', 'message': 'Some data'})
|
{'status': 'failed', 'message': 'Some data'})
|
||||||
step = 'factory_reset'
|
step = 'factory_reset'
|
||||||
self.assertRaises(exception.NodeCleaningFailure,
|
if task.node.clean_step:
|
||||||
|
exept = exception.NodeCleaningFailure
|
||||||
|
else:
|
||||||
|
exept = exception.InstanceDeployFailure
|
||||||
|
self.assertRaises(exept,
|
||||||
task.driver.bios._execute_post_boot_bios_step,
|
task.driver.bios._execute_post_boot_bios_step,
|
||||||
task, step)
|
task, step)
|
||||||
self.assertTrue(
|
self.assertTrue(
|
||||||
'reset_bios' not in task.node.driver_internal_info)
|
'reset_bios' not in task.node.driver_internal_info)
|
||||||
|
|
||||||
|
def test__execute_post_boot_bios_get_settings_failed_cleaning(
|
||||||
|
self):
|
||||||
|
self.node.clean_step = {'priority': 100, 'interface': 'bios',
|
||||||
|
'step': 'factory_reset', 'argsinfo': {}}
|
||||||
|
self.node.save()
|
||||||
|
self._test__execute_post_boot_bios_get_settings_failed()
|
||||||
|
|
||||||
|
def test__execute_post_boot_bios_get_settings_failed_deploying(
|
||||||
|
self):
|
||||||
|
self.node.depoy_step = {'priority': 100, 'interface': 'bios',
|
||||||
|
'step': 'factory_reset', 'argsinfo': {}}
|
||||||
|
self.node.save()
|
||||||
|
self._test__execute_post_boot_bios_get_settings_failed()
|
||||||
|
|
||||||
@mock.patch.object(objects.BIOSSettingList, 'create')
|
@mock.patch.object(objects.BIOSSettingList, 'create')
|
||||||
@mock.patch.object(objects.BIOSSettingList, 'save')
|
@mock.patch.object(objects.BIOSSettingList, 'save')
|
||||||
@mock.patch.object(objects.BIOSSettingList, 'delete')
|
@mock.patch.object(objects.BIOSSettingList, 'delete')
|
||||||
|
@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- |
|
||||||
|
Adds support for deploy steps to ``bios`` interface of ``ilo``
|
||||||
|
hardware type. The methods ``factory_reset`` and
|
||||||
|
``apply_configuration`` can be used as deploy steps.
|
Loading…
x
Reference in New Issue
Block a user