]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Call on dhcp-agent DhcpLocalProcess.restart() breaks dhcp
authorMiguel Angel Ajo <mangelajo@redhat.com>
Thu, 15 Jan 2015 00:23:29 +0000 (00:23 +0000)
committerMiguel Angel Ajo <mangelajo@redhat.com>
Thu, 15 Jan 2015 00:23:29 +0000 (00:23 +0000)
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
neutron/tests/unit/test_linux_dhcp.py

index 534d27969bd2f7dc74ba455d46edd61f66ba5752..37e53e48299444663a6d9680bc48b67ded8bf098 100644 (file)
@@ -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()
index 98b5beaab8825f620a0c9b422e16e5a2f847b47f..faabbd3a9c56ffb87848ad8c49e9131ca8d65c7b 100644 (file)
@@ -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