Merge "Prevent ilo drivers powering off active nodes during take over"
This commit is contained in:
@@ -480,7 +480,8 @@ class IloVirtualMediaIscsiDeploy(base.DeployInterface):
|
|||||||
:param task: a TaskManager instance containing the node to act on.
|
:param task: a TaskManager instance containing the node to act on.
|
||||||
:raises: IloOperationError, if some operation on iLO failed.
|
:raises: IloOperationError, if some operation on iLO failed.
|
||||||
"""
|
"""
|
||||||
_prepare_node_for_deploy(task)
|
if task.node.provision_state != states.ACTIVE:
|
||||||
|
_prepare_node_for_deploy(task)
|
||||||
|
|
||||||
def clean_up(self, task):
|
def clean_up(self, task):
|
||||||
"""Clean up the deployment environment for the task's node.
|
"""Clean up the deployment environment for the task's node.
|
||||||
@@ -549,10 +550,11 @@ class IloVirtualMediaAgentDeploy(base.DeployInterface):
|
|||||||
|
|
||||||
:param task: a TaskManager instance.
|
:param task: a TaskManager instance.
|
||||||
"""
|
"""
|
||||||
node = task.node
|
if task.node.provision_state != states.ACTIVE:
|
||||||
node.instance_info = agent.build_instance_info_for_deploy(task)
|
node = task.node
|
||||||
node.save()
|
node.instance_info = agent.build_instance_info_for_deploy(task)
|
||||||
_prepare_node_for_deploy(task)
|
node.save()
|
||||||
|
_prepare_node_for_deploy(task)
|
||||||
|
|
||||||
def clean_up(self, task):
|
def clean_up(self, task):
|
||||||
"""Clean up the deployment environment for this node.
|
"""Clean up the deployment environment for this node.
|
||||||
@@ -661,17 +663,18 @@ class IloPXEDeploy(iscsi_deploy.ISCSIDeploy):
|
|||||||
:raises: IloOperationError, if some operation on iLO failed.
|
:raises: IloOperationError, if some operation on iLO failed.
|
||||||
:raises: InvalidParameterValue, if some information is invalid.
|
:raises: InvalidParameterValue, if some information is invalid.
|
||||||
"""
|
"""
|
||||||
_prepare_node_for_deploy(task)
|
if task.node.provision_state != states.ACTIVE:
|
||||||
|
_prepare_node_for_deploy(task)
|
||||||
|
|
||||||
# Check if 'boot_option' is compatible with 'boot_mode' and image.
|
# Check if 'boot_option' is compatible with 'boot_mode' and image.
|
||||||
# Whole disk image deploy is not supported in UEFI boot mode if
|
# Whole disk image deploy is not supported in UEFI boot mode if
|
||||||
# 'boot_option' is not 'local'.
|
# 'boot_option' is not 'local'.
|
||||||
# If boot_mode is not set in the node properties/capabilities then
|
# If boot_mode is not set in the node properties/capabilities then
|
||||||
# PXEDeploy.validate() would pass.
|
# PXEDeploy.validate() would pass.
|
||||||
# Boot mode gets updated in prepare stage. It is possible that the
|
# Boot mode gets updated in prepare stage. It is possible that the
|
||||||
# deploy boot mode is 'uefi' after call to update_boot_mode().
|
# deploy boot mode is 'uefi' after call to update_boot_mode().
|
||||||
# Hence a re-check is required here.
|
# Hence a re-check is required here.
|
||||||
pxe.validate_boot_option_for_uefi(task.node)
|
pxe.validate_boot_option_for_uefi(task.node)
|
||||||
|
|
||||||
super(IloPXEDeploy, self).prepare(task)
|
super(IloPXEDeploy, self).prepare(task)
|
||||||
|
|
||||||
|
|||||||
@@ -695,6 +695,16 @@ class IloVirtualMediaIscsiDeployTestCase(db_base.DbTestCase):
|
|||||||
task.driver.deploy.prepare(task)
|
task.driver.deploy.prepare(task)
|
||||||
func_prepare_node_for_deploy.assert_called_once_with(task)
|
func_prepare_node_for_deploy.assert_called_once_with(task)
|
||||||
|
|
||||||
|
@mock.patch.object(ilo_deploy, '_prepare_node_for_deploy', spec_set=True,
|
||||||
|
autospec=True)
|
||||||
|
def test_prepare_active_node(self, func_prepare_node_for_deploy):
|
||||||
|
self.node.provision_state = states.ACTIVE
|
||||||
|
self.node.save()
|
||||||
|
with task_manager.acquire(self.context, self.node.uuid,
|
||||||
|
shared=False) as task:
|
||||||
|
task.driver.deploy.prepare(task)
|
||||||
|
self.assertFalse(func_prepare_node_for_deploy.called)
|
||||||
|
|
||||||
|
|
||||||
class IloVirtualMediaAgentDeployTestCase(db_base.DbTestCase):
|
class IloVirtualMediaAgentDeployTestCase(db_base.DbTestCase):
|
||||||
|
|
||||||
@@ -778,6 +788,20 @@ class IloVirtualMediaAgentDeployTestCase(db_base.DbTestCase):
|
|||||||
self.assertEqual(deploy_opts, task.node.instance_info)
|
self.assertEqual(deploy_opts, task.node.instance_info)
|
||||||
func_prepare_node_for_deploy.assert_called_once_with(task)
|
func_prepare_node_for_deploy.assert_called_once_with(task)
|
||||||
|
|
||||||
|
@mock.patch.object(ilo_deploy, '_prepare_node_for_deploy', spec_set=True,
|
||||||
|
autospec=True)
|
||||||
|
@mock.patch.object(agent, 'build_instance_info_for_deploy', spec_set=True,
|
||||||
|
autospec=True)
|
||||||
|
def test_prepare_active_node(self,
|
||||||
|
build_instance_info_mock,
|
||||||
|
func_prepare_node_for_deploy):
|
||||||
|
with task_manager.acquire(self.context, self.node.uuid,
|
||||||
|
shared=False) as task:
|
||||||
|
task.node.provision_state = states.ACTIVE
|
||||||
|
task.driver.deploy.prepare(task)
|
||||||
|
self.assertFalse(build_instance_info_mock.called)
|
||||||
|
self.assertFalse(func_prepare_node_for_deploy.called)
|
||||||
|
|
||||||
@mock.patch('ironic.dhcp.neutron.NeutronDHCPApi.delete_cleaning_ports',
|
@mock.patch('ironic.dhcp.neutron.NeutronDHCPApi.delete_cleaning_ports',
|
||||||
spec_set=True, autospec=True)
|
spec_set=True, autospec=True)
|
||||||
@mock.patch('ironic.dhcp.neutron.NeutronDHCPApi.create_cleaning_ports',
|
@mock.patch('ironic.dhcp.neutron.NeutronDHCPApi.create_cleaning_ports',
|
||||||
@@ -1407,6 +1431,21 @@ class IloPXEDeployTestCase(db_base.DbTestCase):
|
|||||||
prepare_node_mock.assert_called_once_with(task)
|
prepare_node_mock.assert_called_once_with(task)
|
||||||
pxe_prepare_mock.assert_called_once_with(mock.ANY, task)
|
pxe_prepare_mock.assert_called_once_with(mock.ANY, task)
|
||||||
|
|
||||||
|
@mock.patch.object(iscsi_deploy.ISCSIDeploy, 'prepare', spec_set=True,
|
||||||
|
autospec=True)
|
||||||
|
@mock.patch.object(ilo_deploy, '_prepare_node_for_deploy', spec_set=True,
|
||||||
|
autospec=True)
|
||||||
|
def test_prepare_active_node(self,
|
||||||
|
prepare_node_mock,
|
||||||
|
pxe_prepare_mock):
|
||||||
|
with task_manager.acquire(self.context, self.node.uuid,
|
||||||
|
shared=False) as task:
|
||||||
|
task.node.provision_state = states.ACTIVE
|
||||||
|
task.node.properties['capabilities'] = 'boot_mode:uefi'
|
||||||
|
task.driver.deploy.prepare(task)
|
||||||
|
self.assertFalse(prepare_node_mock.called)
|
||||||
|
pxe_prepare_mock.assert_called_once_with(mock.ANY, task)
|
||||||
|
|
||||||
@mock.patch.object(iscsi_deploy.ISCSIDeploy, 'prepare', spec_set=True,
|
@mock.patch.object(iscsi_deploy.ISCSIDeploy, 'prepare', spec_set=True,
|
||||||
autospec=True)
|
autospec=True)
|
||||||
@mock.patch.object(ilo_deploy, '_prepare_node_for_deploy', spec_set=True,
|
@mock.patch.object(ilo_deploy, '_prepare_node_for_deploy', spec_set=True,
|
||||||
|
|||||||
Reference in New Issue
Block a user