]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Remove "reuse_existing" from setup method in dhcp.py
authorrossella <rsblendido@suse.com>
Wed, 9 Apr 2014 14:12:50 +0000 (14:12 +0000)
committerrossella <rsblendido@suse.com>
Thu, 10 Apr 2014 08:23:15 +0000 (08:23 +0000)
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
neutron/tests/unit/test_dhcp_agent.py
neutron/tests/unit/test_linux_dhcp.py

index e650c00318d049f79320af5bcb97f43c59b6340e..81a9b17dab914b9f30d459e313fe9042f139b8da 100644 (file)
@@ -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,
index 58836e8e206d5693ba1064b7a47bcd7bab24f53f..21b01e4f9487d873bb3e463544eff9a4e66314ae 100644 (file)
@@ -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()
index 7764bce763999b07406c6f7bcb005c6d005555f1..1a6723d0441c7c23b79a8a8508065943403b2a6a 100644 (file)
@@ -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)