summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ironic/drivers/modules/ilo/deploy.py33
-rw-r--r--ironic/tests/drivers/ilo/test_deploy.py39
2 files changed, 57 insertions, 15 deletions
diff --git a/ironic/drivers/modules/ilo/deploy.py b/ironic/drivers/modules/ilo/deploy.py
index 5f901184e..fe51b4881 100644
--- a/ironic/drivers/modules/ilo/deploy.py
+++ b/ironic/drivers/modules/ilo/deploy.py
@@ -458,7 +458,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.
@@ -537,10 +538,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.
@@ -645,17 +647,18 @@ class IloPXEDeploy(pxe.PXEDeploy):
:raises: IloOperationError, if some operation on iLO failed.
:raises: InvalidParameterValue, if some information is invalid.
"""
- ilo_common.update_boot_mode(task)
+ if task.node.provision_state != states.ACTIVE:
+ ilo_common.update_boot_mode(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)
diff --git a/ironic/tests/drivers/ilo/test_deploy.py b/ironic/tests/drivers/ilo/test_deploy.py
index e54d8a6e6..d1be90bc6 100644
--- a/ironic/tests/drivers/ilo/test_deploy.py
+++ b/ironic/tests/drivers/ilo/test_deploy.py
@@ -595,6 +595,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):
@@ -672,6 +682,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')
@mock.patch('ironic.dhcp.neutron.NeutronDHCPApi.create_cleaning_ports')
@mock.patch.object(ilo_deploy, '_prepare_agent_vmedia_boot')
@@ -1127,6 +1151,21 @@ class IloPXEDeployTestCase(db_base.DbTestCase):
pxe_prepare_mock.assert_called_once_with(task)
@mock.patch.object(pxe.PXEDeploy, 'prepare')
+ @mock.patch.object(pxe, 'validate_boot_option_for_uefi')
+ @mock.patch.object(ilo_common, 'update_boot_mode')
+ def test_prepare_active_node(self,
+ update_mock, validate_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(update_mock.called)
+ self.assertFalse(validate_mock.called)
+ pxe_prepare_mock.assert_called_once_with(task)
+
+ @mock.patch.object(pxe.PXEDeploy, 'prepare')
@mock.patch.object(ilo_common, 'update_boot_mode')
def test_prepare_uefi_whole_disk_image_fail(self,
update_boot_mode_mock,