From 5461c783eb4357b4225c37f0df3ef7761bcb15fc Mon Sep 17 00:00:00 2001 From: rossella Date: Wed, 9 Apr 2014 14:12:50 +0000 Subject: [PATCH] Remove "reuse_existing" from setup method in dhcp.py This flag is never used, it's always set to True by DhcpLocalProcess.enable() Change-Id: Ic30e0f2c97679d5919cc4e4afeb38666a6d41392 Closes-bug: #1305083 --- neutron/agent/linux/dhcp.py | 9 ++------- neutron/tests/unit/test_dhcp_agent.py | 13 ++++--------- neutron/tests/unit/test_linux_dhcp.py | 2 +- 3 files changed, 7 insertions(+), 17 deletions(-) diff --git a/neutron/agent/linux/dhcp.py b/neutron/agent/linux/dhcp.py index e650c00318..81a9b17dab 100644 --- a/neutron/agent/linux/dhcp.py +++ b/neutron/agent/linux/dhcp.py @@ -162,8 +162,7 @@ class DhcpLocalProcess(DhcpBase): def enable(self): """Enables DHCP for this network by spawning a local process.""" - interface_name = self.device_manager.setup(self.network, - reuse_existing=True) + interface_name = self.device_manager.setup(self.network) if self.active: self.restart() elif self._enable_dhcp(): @@ -811,7 +810,7 @@ class DeviceManager(object): return dhcp_port - def setup(self, network, reuse_existing=False): + def setup(self, network): """Create and initialize a device for network's DHCP on this host.""" port = self.setup_dhcp_port(network) interface_name = self.get_interface_name(network, port) @@ -819,10 +818,6 @@ class DeviceManager(object): if ip_lib.device_exists(interface_name, self.root_helper, network.namespace): - if not reuse_existing: - raise exceptions.PreexistingDeviceFailure( - dev_name=interface_name) - LOG.debug(_('Reusing existing device: %s.'), interface_name) else: self.driver.plug(network.id, diff --git a/neutron/tests/unit/test_dhcp_agent.py b/neutron/tests/unit/test_dhcp_agent.py index 58836e8e20..21b01e4f94 100644 --- a/neutron/tests/unit/test_dhcp_agent.py +++ b/neutron/tests/unit/test_dhcp_agent.py @@ -1124,8 +1124,7 @@ class TestDeviceManager(base.BaseTestCase): self.iproute_cls_p.stop() super(TestDeviceManager, self).tearDown() - def _test_setup_helper(self, device_exists, reuse_existing=False, - net=None, port=None): + def _test_setup_helper(self, device_exists, net=None, port=None): net = net or fake_network port = port or fake_port1 plugin = mock.Mock() @@ -1136,7 +1135,7 @@ class TestDeviceManager(base.BaseTestCase): dh = dhcp.DeviceManager(cfg.CONF, cfg.CONF.root_helper, plugin) dh._set_default_route = mock.Mock() - interface_name = dh.setup(net, reuse_existing) + interface_name = dh.setup(net) self.assertEqual(interface_name, 'tap12345678-12') @@ -1156,7 +1155,7 @@ class TestDeviceManager(base.BaseTestCase): expected_ips, namespace=net.namespace)] - if not reuse_existing: + if not device_exists: expected.insert(1, mock.call.plug(net.id, port.id, @@ -1174,11 +1173,7 @@ class TestDeviceManager(base.BaseTestCase): self._test_setup_helper(False) def test_setup_device_exists(self): - with testtools.ExpectedException(exceptions.PreexistingDeviceFailure): - self._test_setup_helper(True) - - def test_setup_device_exists_reuse(self): - self._test_setup_helper(True, True) + self._test_setup_helper(True) def test_create_dhcp_port_raise_conflict(self): plugin = mock.Mock() diff --git a/neutron/tests/unit/test_linux_dhcp.py b/neutron/tests/unit/test_linux_dhcp.py index 7764bce763..1a6723d044 100644 --- a/neutron/tests/unit/test_linux_dhcp.py +++ b/neutron/tests/unit/test_linux_dhcp.py @@ -527,7 +527,7 @@ class TestDhcpLocalProcess(TestBase): self.mock_mgr.assert_has_calls( [mock.call(self.conf, 'sudo', None), - mock.call().setup(mock.ANY, reuse_existing=True)]) + mock.call().setup(mock.ANY)]) self.assertEqual(lp.called, ['spawn']) self.assertTrue(mocks['interface_name'].__set__.called)