Merge "DRAC BIOS vendor_passthru: enable rebooting the node"

This commit is contained in:
Jenkins 2015-10-23 08:46:52 +00:00 committed by Gerrit Code Review
commit 1b3d69f333
4 changed files with 40 additions and 7 deletions

View File

@ -388,10 +388,12 @@ def set_config(task, **kwargs):
@task_manager.require_exclusive_lock
def commit_config(task):
def commit_config(task, reboot=False):
"""Commits pending changes added by set_config
:param task: is the ironic task for running the config job.
:param reboot: indicates whether a reboot job should be automatically
created with the config job.
:raises: DracClientError on an error from pywsman library.
:raises: DracPendingConfigJobExists if the job is already created.
:raises: DracOperationFailed if the client received response with an
@ -402,7 +404,7 @@ def commit_config(task):
"""
node = task.node
management.check_for_config_job(node)
management.create_config_job(node)
management.create_config_job(node, reboot)
@task_manager.require_exclusive_lock

View File

@ -44,6 +44,10 @@ _BOOT_DEVICES_MAP = {
TARGET_DEVICE = 'BIOS.Setup.1-1'
# RebootJobType constants
_GRACEFUL_REBOOT_WITH_FORCED_SHUTDOWN = '3'
# IsNext constants
PERSISTENT = '1'
@ -221,7 +225,7 @@ def _get_boot_list_for_boot_device(node, device, controller_version):
return {'boot_list': boot_list, 'boot_device_id': boot_device_id}
def create_config_job(node):
def create_config_job(node, reboot=False):
"""Create a configuration job.
This method is used to apply the pending values created by
@ -241,6 +245,10 @@ def create_config_job(node):
'SystemName': 'DCIM:ComputerSystem'}
properties = {'Target': TARGET_DEVICE,
'ScheduledStartTime': 'TIME_NOW'}
if reboot:
properties['RebootJobType'] = _GRACEFUL_REBOOT_WITH_FORCED_SHUTDOWN
try:
client.wsman_invoke(resource_uris.DCIM_BIOSService,
'CreateTargetedConfigJob', selectors, properties,

View File

@ -79,14 +79,16 @@ class DracVendorPassthru(base.VendorInterface):
return {'commit_needed': bios.set_config(task, **kwargs)}
@base.passthru(['POST'], async=False)
def commit_bios_config(self, task, **kwargs):
def commit_bios_config(self, task, reboot=False, **kwargs):
"""Commit a BIOS configuration job.
This method is used to commit a BIOS configuration job.
submitted through set_bios_config().
:param task: the ironic task for running the config job.
:param kwargs: not used.
:param reboot: indicates whether a reboot job should be automatically
created with the config job.
:param kwargs: additional arguments sent via vendor passthru.
:raises: DracClientError on an error from pywsman library.
:raises: DracPendingConfigJobExists if the job is already created.
:raises: DracOperationFailed if the client received response with an
@ -96,8 +98,8 @@ class DracVendorPassthru(base.VendorInterface):
:returns: A dictionary containing the committing key with no return
value, and the reboot_needed key with a value of True.
"""
bios.commit_config(task)
return {'committing': None, 'reboot_needed': True}
bios.commit_config(task, reboot=reboot)
return {'committing': None, 'reboot_needed': not reboot}
@base.passthru(['DELETE'], async=False)
def abandon_bios_config(self, task, **kwargs):

View File

@ -153,6 +153,27 @@ class DracManagementInternalMethodsTestCase(db_base.DbTestCase):
mock.ANY, resource_uris.DCIM_BIOSService,
'CreateTargetedConfigJob', None)
def test_create_config_job_with_reboot(self, mock_client_pywsman):
result_xml = test_utils.build_soap_xml(
[{'ReturnValue': drac_client.RET_CREATED}],
resource_uris.DCIM_BIOSService)
mock_xml = test_utils.mock_wsman_root(result_xml)
mock_pywsman = mock_client_pywsman.Client.return_value
mock_pywsman.invoke.return_value = mock_xml
mock_pywsman_clientopts = (
mock_client_pywsman.ClientOptions.return_value)
result = drac_mgmt.create_config_job(self.node, reboot=True)
self.assertIsNone(result)
mock_pywsman_clientopts.add_property.assert_has_calls([
mock.call('RebootJobType', '3'),
])
mock_pywsman.invoke.assert_called_once_with(
mock.ANY, resource_uris.DCIM_BIOSService,
'CreateTargetedConfigJob', None)
def test_create_config_job_error(self, mock_client_pywsman):
result_xml = test_utils.build_soap_xml(
[{'ReturnValue': drac_client.RET_ERROR,