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
This commit is contained in:
parent
a701f23807
commit
5461c783eb
@ -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,
|
||||
|
@ -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,12 +1173,8 @@ 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)
|
||||
|
||||
def test_create_dhcp_port_raise_conflict(self):
|
||||
plugin = mock.Mock()
|
||||
dh = dhcp.DeviceManager(cfg.CONF, cfg.CONF.root_helper, plugin)
|
||||
|
@ -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)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user