Merge "Enable agent_ilo for uefi-bios switching"
This commit is contained in:
commit
b865538d0b
@ -327,14 +327,23 @@ def set_boot_mode(node, boot_mode):
|
||||
{'uuid': node.uuid, 'boot_mode': boot_mode})
|
||||
|
||||
|
||||
def update_boot_mode_capability(task):
|
||||
def update_boot_mode(task):
|
||||
"""Update 'boot_mode' capability value of node's 'capabilities' property.
|
||||
|
||||
This method updates the 'boot_mode' capability in node's 'capabilities'
|
||||
property if not set.
|
||||
It also sets the boot mode to be used in the next boot.
|
||||
|
||||
:param task: Task object.
|
||||
:raises: IloOperationError if setting boot mode failed.
|
||||
|
||||
"""
|
||||
ilo_object = get_ilo_object(task.node)
|
||||
boot_mode = driver_utils.get_node_capability(task.node, 'boot_mode')
|
||||
if boot_mode is not None:
|
||||
set_boot_mode(task.node, boot_mode)
|
||||
return
|
||||
|
||||
ilo_object = get_ilo_object(task.node)
|
||||
try:
|
||||
p_boot_mode = ilo_object.get_pending_boot_mode()
|
||||
if p_boot_mode == 'UNKNOWN':
|
||||
|
@ -340,11 +340,7 @@ class IloVirtualMediaIscsiDeploy(base.DeployInterface):
|
||||
:param task: a TaskManager instance containing the node to act on.
|
||||
:raises: IloOperationError, if some operation on iLO failed.
|
||||
"""
|
||||
boot_mode = driver_utils.get_node_capability(task.node, 'boot_mode')
|
||||
if boot_mode is not None:
|
||||
ilo_common.set_boot_mode(task.node, boot_mode)
|
||||
else:
|
||||
ilo_common.update_boot_mode_capability(task)
|
||||
ilo_common.update_boot_mode(task)
|
||||
|
||||
def clean_up(self, task):
|
||||
"""Clean up the deployment environment for the task's node.
|
||||
@ -415,6 +411,7 @@ class IloVirtualMediaAgentDeploy(base.DeployInterface):
|
||||
node = task.node
|
||||
node.instance_info = agent.build_instance_info_for_deploy(task)
|
||||
node.save()
|
||||
ilo_common.update_boot_mode(task)
|
||||
|
||||
def clean_up(self, task):
|
||||
"""Clean up the deployment environment for this node.
|
||||
@ -448,11 +445,7 @@ class IloPXEDeploy(pxe.PXEDeploy):
|
||||
|
||||
:param task: a TaskManager instance containing the node to act on.
|
||||
"""
|
||||
boot_mode = driver_utils.get_node_capability(task.node, 'boot_mode')
|
||||
if boot_mode is None:
|
||||
ilo_common.update_boot_mode_capability(task)
|
||||
else:
|
||||
ilo_common.set_boot_mode(task.node, boot_mode)
|
||||
ilo_common.update_boot_mode(task)
|
||||
super(IloPXEDeploy, self).prepare(task)
|
||||
|
||||
def deploy(self, task):
|
||||
|
@ -302,15 +302,15 @@ class IloCommonMethodsTestCase(db_base.DbTestCase):
|
||||
@mock.patch.object(driver_utils, 'rm_node_capability')
|
||||
@mock.patch.object(driver_utils, 'add_node_capability')
|
||||
@mock.patch.object(ilo_common, 'get_ilo_object')
|
||||
def test_update_boot_mode_capability(self, get_ilo_object_mock,
|
||||
add_node_capability_mock,
|
||||
rm_node_capability_mock):
|
||||
def test_update_boot_mode(self, get_ilo_object_mock,
|
||||
add_node_capability_mock,
|
||||
rm_node_capability_mock):
|
||||
ilo_mock_obj = get_ilo_object_mock.return_value
|
||||
ilo_mock_obj.get_pending_boot_mode.return_value = 'legacy'
|
||||
|
||||
with task_manager.acquire(self.context, self.node.uuid,
|
||||
shared=False) as task:
|
||||
ilo_common.update_boot_mode_capability(task)
|
||||
ilo_common.update_boot_mode(task)
|
||||
get_ilo_object_mock.assert_called_once_with(task.node)
|
||||
ilo_mock_obj.get_pending_boot_mode.assert_called_once_with()
|
||||
rm_node_capability_mock.assert_called_once_with(task, 'boot_mode')
|
||||
@ -320,16 +320,16 @@ class IloCommonMethodsTestCase(db_base.DbTestCase):
|
||||
|
||||
@mock.patch.object(driver_utils, 'add_node_capability')
|
||||
@mock.patch.object(ilo_common, 'get_ilo_object')
|
||||
def test_update_boot_mode_capability_unknown(self,
|
||||
get_ilo_object_mock,
|
||||
add_node_capability_mock):
|
||||
def test_update_boot_mode_unknown(self,
|
||||
get_ilo_object_mock,
|
||||
add_node_capability_mock):
|
||||
ilo_mock_obj = get_ilo_object_mock.return_value
|
||||
ilo_mock_obj.get_pending_boot_mode.return_value = 'UNKNOWN'
|
||||
set_pending_boot_mode_mock = ilo_mock_obj.set_pending_boot_mode
|
||||
|
||||
with task_manager.acquire(self.context, self.node.uuid,
|
||||
shared=False) as task:
|
||||
ilo_common.update_boot_mode_capability(task)
|
||||
ilo_common.update_boot_mode(task)
|
||||
get_ilo_object_mock.assert_called_once_with(task.node)
|
||||
ilo_mock_obj.get_pending_boot_mode.assert_called_once_with()
|
||||
set_pending_boot_mode_mock.assert_called_once_with('UEFI')
|
||||
@ -339,22 +339,33 @@ class IloCommonMethodsTestCase(db_base.DbTestCase):
|
||||
|
||||
@mock.patch.object(driver_utils, 'add_node_capability')
|
||||
@mock.patch.object(ilo_common, 'get_ilo_object')
|
||||
def test_update_boot_mode_capability_legacy(self,
|
||||
get_ilo_object_mock,
|
||||
add_node_capability_mock):
|
||||
def test_update_boot_mode_legacy(self,
|
||||
get_ilo_object_mock,
|
||||
add_node_capability_mock):
|
||||
ilo_mock_obj = get_ilo_object_mock.return_value
|
||||
exc = ilo_error.IloCommandNotSupportedError('error')
|
||||
ilo_mock_obj.get_pending_boot_mode.side_effect = exc
|
||||
|
||||
with task_manager.acquire(self.context, self.node.uuid,
|
||||
shared=False) as task:
|
||||
ilo_common.update_boot_mode_capability(task)
|
||||
ilo_common.update_boot_mode(task)
|
||||
get_ilo_object_mock.assert_called_once_with(task.node)
|
||||
ilo_mock_obj.get_pending_boot_mode.assert_called_once_with()
|
||||
add_node_capability_mock.assert_called_once_with(task,
|
||||
'boot_mode',
|
||||
'bios')
|
||||
|
||||
@mock.patch.object(ilo_common, 'set_boot_mode')
|
||||
def test_update_boot_mode_prop_boot_mode_exist(self,
|
||||
set_boot_mode_mock):
|
||||
|
||||
properties = {'capabilities': 'boot_mode:uefi'}
|
||||
with task_manager.acquire(self.context, self.node.uuid,
|
||||
shared=False) as task:
|
||||
task.node.properties = properties
|
||||
ilo_common.update_boot_mode(task)
|
||||
set_boot_mode_mock.assert_called_once_with(task.node, 'uefi')
|
||||
|
||||
@mock.patch.object(images, 'get_temp_url_for_glance_image')
|
||||
@mock.patch.object(ilo_common, 'attach_vmedia')
|
||||
@mock.patch.object(ilo_common, '_prepare_floppy_image')
|
||||
|
@ -336,6 +336,14 @@ class IloVirtualMediaIscsiDeployTestCase(db_base.DbTestCase):
|
||||
destroy_images_mock.assert_called_once_with(task.node.uuid)
|
||||
clean_up_boot_mock.assert_called_once_with(task.node)
|
||||
|
||||
@mock.patch.object(ilo_common, 'update_boot_mode')
|
||||
def test_prepare(self,
|
||||
update_boot_mode_mock):
|
||||
with task_manager.acquire(self.context, self.node.uuid,
|
||||
shared=False) as task:
|
||||
task.driver.deploy.prepare(task)
|
||||
update_boot_mode_mock.assert_called_once_with(task)
|
||||
|
||||
|
||||
class IloVirtualMediaAgentDeployTestCase(db_base.DbTestCase):
|
||||
|
||||
@ -378,13 +386,17 @@ class IloVirtualMediaAgentDeployTestCase(db_base.DbTestCase):
|
||||
states.POWER_OFF)
|
||||
self.assertEqual(states.DELETED, returned_state)
|
||||
|
||||
@mock.patch.object(ilo_common, 'update_boot_mode')
|
||||
@mock.patch.object(agent, 'build_instance_info_for_deploy')
|
||||
def test_prepare(self, build_instance_info_mock):
|
||||
def test_prepare(self,
|
||||
build_instance_info_mock,
|
||||
update_boot_mode_mock):
|
||||
deploy_opts = {'a': 'b'}
|
||||
build_instance_info_mock.return_value = deploy_opts
|
||||
with task_manager.acquire(self.context, self.node.uuid,
|
||||
shared=False) as task:
|
||||
task.driver.deploy.prepare(task)
|
||||
update_boot_mode_mock.assert_called_once_with(task)
|
||||
self.assertEqual(deploy_opts, task.node.instance_info)
|
||||
|
||||
|
||||
@ -653,30 +665,14 @@ class IloPXEDeployTestCase(db_base.DbTestCase):
|
||||
pxe_validate_mock.assert_called_once_with(task)
|
||||
|
||||
@mock.patch.object(pxe.PXEDeploy, 'prepare')
|
||||
@mock.patch.object(ilo_common, 'set_boot_mode')
|
||||
@mock.patch.object(driver_utils, 'get_node_capability')
|
||||
def test_prepare(self, node_capability_mock,
|
||||
set_boot_mode_mock, pxe_prepare_mock):
|
||||
@mock.patch.object(ilo_common, 'update_boot_mode')
|
||||
def test_prepare(self,
|
||||
update_boot_mode_mock,
|
||||
pxe_prepare_mock):
|
||||
with task_manager.acquire(self.context, self.node.uuid,
|
||||
shared=False) as task:
|
||||
node_capability_mock.return_value = 'uefi'
|
||||
task.driver.deploy.prepare(task)
|
||||
node_capability_mock.assert_called_once_with(task.node,
|
||||
'boot_mode')
|
||||
set_boot_mode_mock.assert_called_once_with(task.node, 'uefi')
|
||||
pxe_prepare_mock.assert_called_once_with(task)
|
||||
|
||||
@mock.patch.object(pxe.PXEDeploy, 'prepare')
|
||||
@mock.patch.object(ilo_common, 'update_boot_mode_capability')
|
||||
@mock.patch.object(driver_utils, 'get_node_capability')
|
||||
def test_prepare_boot_mode_doesnt_exist(self, node_capability_mock,
|
||||
update_capability_mock,
|
||||
pxe_prepare_mock):
|
||||
with task_manager.acquire(self.context, self.node.uuid,
|
||||
shared=False) as task:
|
||||
node_capability_mock.return_value = None
|
||||
task.driver.deploy.prepare(task)
|
||||
update_capability_mock.assert_called_once_with(task)
|
||||
update_boot_mode_mock.assert_called_once_with(task)
|
||||
pxe_prepare_mock.assert_called_once_with(task)
|
||||
|
||||
@mock.patch.object(pxe.PXEDeploy, 'deploy')
|
||||
|
Loading…
Reference in New Issue
Block a user