Merge "Fix take over of ACTIVE nodes in AgentDeploy"

This commit is contained in:
Jenkins
2017-01-13 14:06:11 +00:00
committed by Gerrit Code Review
3 changed files with 10 additions and 5 deletions

View File

@ -420,16 +420,15 @@ class AgentDeploy(AgentDeployMixin, base.DeployInterface):
Glance href and is not HTTP(S) URL.
:raises: any boot interface's prepare_ramdisk exceptions.
"""
# Nodes deployed by AgentDeploy always boot from disk now. So there
# is nothing to be done in prepare() when it's called during
# take over.
node = task.node
if node.provision_state == states.DEPLOYING:
# Adding the node to provisioning network so that the dhcp
# options get added for the provisioning port.
manager_utils.node_power_action(task, states.POWER_OFF)
task.driver.network.add_provisioning_network(task)
if node.provision_state not in [states.ACTIVE, states.ADOPTING]:
if node.provision_state == states.ACTIVE:
task.driver.boot.prepare_instance(task)
elif node.provision_state != states.ADOPTING:
node.instance_info = deploy_utils.build_instance_info_for_deploy(
task)
node.save()

View File

@ -328,12 +328,14 @@ class TestAgentDeploy(db_base.DbTestCase):
@mock.patch('ironic.drivers.modules.network.flat.FlatNetwork.'
'add_provisioning_network', autospec=True)
@mock.patch.object(pxe.PXEBoot, 'prepare_instance')
@mock.patch.object(pxe.PXEBoot, 'prepare_ramdisk')
@mock.patch.object(deploy_utils, 'build_agent_options')
@mock.patch.object(deploy_utils, 'build_instance_info_for_deploy')
def test_prepare_active(
self, build_instance_info_mock, build_options_mock,
pxe_prepare_ramdisk_mock, add_provisioning_net_mock):
pxe_prepare_ramdisk_mock, pxe_prepare_instance_mock,
add_provisioning_net_mock):
with task_manager.acquire(
self.context, self.node['uuid'], shared=False) as task:
task.node.provision_state = states.ACTIVE
@ -343,6 +345,7 @@ class TestAgentDeploy(db_base.DbTestCase):
self.assertFalse(build_instance_info_mock.called)
self.assertFalse(build_options_mock.called)
self.assertFalse(pxe_prepare_ramdisk_mock.called)
self.assertTrue(pxe_prepare_instance_mock.called)
self.assertFalse(add_provisioning_net_mock.called)
@mock.patch('ironic.drivers.modules.network.flat.FlatNetwork.'

View File

@ -0,0 +1,3 @@
---
fixes:
- AgentDeploy now correctly supports take-over for ACTIVE netboot-ed nodes.