From 718b2950616fc748881f9f644bc7000961886c65 Mon Sep 17 00:00:00 2001 From: Miguel Angel Ajo Date: Thu, 15 Jan 2015 00:23:29 +0000 Subject: [PATCH] Call on dhcp-agent DhcpLocalProcess.restart() breaks dhcp The bugfix implemented on Ib37651f7f802debd472ab292b148c2a2496063a3 creates the network_conf_dir only during __init__, and restart() method calls disable(), then enable(), where disable will remove the config directory and all configuration files. Previous implementation re-created the network_conf_dir on the interface_name setter (called from enable) with ensure_conf_dir=True. Change-Id: I6afaea062c9eed5c63fc64fb0113f460b2cf35c5 Closes-Bug: 1410982 --- neutron/agent/linux/dhcp.py | 1 + neutron/tests/unit/test_linux_dhcp.py | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/neutron/agent/linux/dhcp.py b/neutron/agent/linux/dhcp.py index 534d27969..37e53e482 100644 --- a/neutron/agent/linux/dhcp.py +++ b/neutron/agent/linux/dhcp.py @@ -228,6 +228,7 @@ class DhcpLocalProcess(DhcpBase): if self.active: self.restart() elif self._enable_dhcp(): + self._ensure_network_conf_dir() interface_name = self.device_manager.setup(self.network) self.interface_name = interface_name self.spawn_process() diff --git a/neutron/tests/unit/test_linux_dhcp.py b/neutron/tests/unit/test_linux_dhcp.py index 98b5beaab..faabbd3a9 100644 --- a/neutron/tests/unit/test_linux_dhcp.py +++ b/neutron/tests/unit/test_linux_dhcp.py @@ -618,7 +618,8 @@ class TestDhcpLocalProcess(TestBase): def test_enable(self): attrs_to_mock = dict( [(a, mock.DEFAULT) for a in - ['active', 'get_conf_file_name', 'interface_name']] + ['active', 'get_conf_file_name', 'interface_name', + '_ensure_network_conf_dir']] ) with mock.patch.multiple(LocalChild, **attrs_to_mock) as mocks: @@ -634,6 +635,7 @@ class TestDhcpLocalProcess(TestBase): mock.call().setup(mock.ANY)]) self.assertEqual(lp.called, ['spawn']) self.assertTrue(mocks['interface_name'].__set__.called) + self.assertTrue(mocks['_ensure_network_conf_dir'].called) def test_disable_not_active(self): attrs_to_mock = dict([(a, mock.DEFAULT) for a in -- 2.45.2