Merge "Unbind tenant ports before rebuild"

This commit is contained in:
Jenkins 2017-02-08 14:22:35 +00:00 committed by Gerrit Code Review
commit d601a11e91
5 changed files with 24 additions and 5 deletions

View File

@ -425,6 +425,9 @@ class AgentDeploy(AgentDeployMixin, base.DeployInterface):
# 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)
# NOTE(vdrok): in case of rebuild, we have tenant network already
# configured, unbind tenant ports if present
task.driver.network.unconfigure_tenant_networks(task)
task.driver.network.add_provisioning_network(task)
if node.provision_state == states.ACTIVE:
task.driver.boot.prepare_instance(task)

View File

@ -497,6 +497,9 @@ class ISCSIDeploy(AgentDeployMixin, base.DeployInterface):
# 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)
# NOTE(vdrok): in case of rebuild, we have tenant network
# already configured, unbind tenant ports if present
task.driver.network.unconfigure_tenant_networks(task)
task.driver.network.add_provisioning_network(task)
deploy_opts = deploy_utils.build_agent_options(node)

View File

@ -286,8 +286,12 @@ class TestAgentDeploy(db_base.DbTestCase):
@mock.patch.object(deploy_utils, 'build_instance_info_for_deploy')
@mock.patch('ironic.drivers.modules.network.flat.FlatNetwork.'
'add_provisioning_network', autospec=True)
def test_prepare(self, add_provisioning_net_mock, build_instance_info_mock,
build_options_mock, pxe_prepare_ramdisk_mock):
@mock.patch('ironic.drivers.modules.network.flat.FlatNetwork.'
'unconfigure_tenant_networks', spec_set=True, autospec=True)
def test_prepare(
self, unconfigure_tenant_net_mock, add_provisioning_net_mock,
build_instance_info_mock, build_options_mock,
pxe_prepare_ramdisk_mock):
with task_manager.acquire(
self.context, self.node['uuid'], shared=False) as task:
task.node.provision_state = states.DEPLOYING
@ -301,6 +305,7 @@ class TestAgentDeploy(db_base.DbTestCase):
pxe_prepare_ramdisk_mock.assert_called_once_with(
task, {'a': 'b'})
add_provisioning_net_mock.assert_called_once_with(mock.ANY, task)
unconfigure_tenant_net_mock.assert_called_once_with(mock.ANY, task)
self.node.refresh()
self.assertEqual('bar', self.node.instance_info['foo'])

View File

@ -594,9 +594,11 @@ class ISCSIDeployTestCase(db_base.DbTestCase):
@mock.patch.object(pxe.PXEBoot, 'prepare_ramdisk', autospec=True)
@mock.patch('ironic.drivers.modules.network.flat.FlatNetwork.'
'add_provisioning_network', spec_set=True, autospec=True)
def test_prepare_node_deploying(self, add_provisioning_net_mock,
mock_prepare_ramdisk,
mock_agent_options):
@mock.patch('ironic.drivers.modules.network.flat.FlatNetwork.'
'unconfigure_tenant_networks', spec_set=True, autospec=True)
def test_prepare_node_deploying(
self, unconfigure_tenant_net_mock, add_provisioning_net_mock,
mock_prepare_ramdisk, mock_agent_options):
mock_agent_options.return_value = {'c': 'd'}
with task_manager.acquire(self.context, self.node.uuid) as task:
task.node.provision_state = states.DEPLOYING
@ -607,6 +609,7 @@ class ISCSIDeployTestCase(db_base.DbTestCase):
mock_prepare_ramdisk.assert_called_once_with(
task.driver.boot, task, {'c': 'd'})
add_provisioning_net_mock.assert_called_once_with(mock.ANY, task)
unconfigure_tenant_net_mock.assert_called_once_with(mock.ANY, task)
@mock.patch.object(manager_utils, 'node_power_action', autospec=True)
@mock.patch.object(iscsi_deploy, 'check_image_size', autospec=True)

View File

@ -0,0 +1,5 @@
---
fixes:
- |
Fixes an issue with node rebuild, when tenant network ports were not
unbound prior to moving the node to provisioning network.