Merge "Prevent ilo drivers powering off active nodes during take over"

This commit is contained in:
Jenkins
2015-09-03 09:28:52 +00:00
committed by Gerrit Code Review
2 changed files with 57 additions and 15 deletions

View File

@@ -480,7 +480,8 @@ class IloVirtualMediaIscsiDeploy(base.DeployInterface):
:param task: a TaskManager instance containing the node to act on.
: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):
"""Clean up the deployment environment for the task's node.
@@ -549,10 +550,11 @@ class IloVirtualMediaAgentDeploy(base.DeployInterface):
:param task: a TaskManager instance.
"""
node = task.node
node.instance_info = agent.build_instance_info_for_deploy(task)
node.save()
_prepare_node_for_deploy(task)
if task.node.provision_state != states.ACTIVE:
node = task.node
node.instance_info = agent.build_instance_info_for_deploy(task)
node.save()
_prepare_node_for_deploy(task)
def clean_up(self, task):
"""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: 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.
# Whole disk image deploy is not supported in UEFI boot mode if
# 'boot_option' is not 'local'.
# If boot_mode is not set in the node properties/capabilities then
# PXEDeploy.validate() would pass.
# Boot mode gets updated in prepare stage. It is possible that the
# deploy boot mode is 'uefi' after call to update_boot_mode().
# Hence a re-check is required here.
pxe.validate_boot_option_for_uefi(task.node)
# Check if 'boot_option' is compatible with 'boot_mode' and image.
# Whole disk image deploy is not supported in UEFI boot mode if
# 'boot_option' is not 'local'.
# If boot_mode is not set in the node properties/capabilities then
# PXEDeploy.validate() would pass.
# Boot mode gets updated in prepare stage. It is possible that the
# deploy boot mode is 'uefi' after call to update_boot_mode().
# Hence a re-check is required here.
pxe.validate_boot_option_for_uefi(task.node)
super(IloPXEDeploy, self).prepare(task)

View File

@@ -695,6 +695,16 @@ class IloVirtualMediaIscsiDeployTestCase(db_base.DbTestCase):
task.driver.deploy.prepare(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):
@@ -778,6 +788,20 @@ class IloVirtualMediaAgentDeployTestCase(db_base.DbTestCase):
self.assertEqual(deploy_opts, task.node.instance_info)
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',
spec_set=True, autospec=True)
@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)
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,
autospec=True)
@mock.patch.object(ilo_deploy, '_prepare_node_for_deploy', spec_set=True,