netns_cleanup: Remove unused parameter from unplug_devices()

A conf object was passed in to the unplug_devices method
which was not used. This patch is removing it and adapting the
tests to the new prototype.

Also, there's apparently no callers outside neutron that could
get broken as per codesearch.openstack.org.

Change-Id: Ie19b8e4056b1f27be3cae51e74759ebfed41074e
Signed-off-by: Daniel Alvarez <dalvarez@redhat.com>
This commit is contained in:
Daniel Alvarez 2018-10-10 11:15:59 +02:00
parent 6918f4a237
commit f30fc92adf
2 changed files with 6 additions and 14 deletions

View File

@ -117,7 +117,7 @@ def eligible_for_deletion(conf, namespace, force=False):
return force or ip.namespace_is_empty()
def unplug_device(conf, device):
def unplug_device(device):
orig_log_fail_as_error = device.get_log_fail_as_error()
device.set_log_fail_as_error(False)
try:
@ -246,7 +246,7 @@ def destroy_namespace(conf, namespace, force=False):
LOG.error('Not all processes were killed in %s',
namespace)
for device in ip.get_devices():
unplug_device(conf, device)
unplug_device(device)
ip.garbage_collect_namespace()
except Exception:

View File

@ -145,16 +145,12 @@ class TestNetnsCleanup(base.BaseTestCase):
ip_wrap.assert_has_calls(expected_calls)
def test_unplug_device_regular_device(self):
conf = mock.Mock()
device = mock.Mock()
util.unplug_device(conf, device)
util.unplug_device(device)
device.assert_has_calls([mock.call.link.delete()])
def test_unplug_device_ovs_port(self):
conf = mock.Mock()
conf.ovs_integration_bridge = 'br-int'
device = mock.Mock()
device.name = 'tap1'
device.link.delete.side_effect = RuntimeError
@ -168,7 +164,7 @@ class TestNetnsCleanup(base.BaseTestCase):
ovs_bridge = mock.Mock()
ovs_br_cls.return_value = ovs_bridge
util.unplug_device(conf, device)
util.unplug_device(device)
mock_get_bridge_for_iface.assert_called_once_with('tap1')
ovs_br_cls.assert_called_once_with('br-int')
@ -176,9 +172,6 @@ class TestNetnsCleanup(base.BaseTestCase):
[mock.call.delete_port(device.name)])
def test_unplug_device_cannot_determine_bridge_port(self):
conf = mock.Mock()
conf.ovs_integration_bridge = 'br-int'
device = mock.Mock()
device.name = 'tap1'
device.link.delete.side_effect = RuntimeError
@ -193,7 +186,7 @@ class TestNetnsCleanup(base.BaseTestCase):
ovs_bridge = mock.Mock()
ovs_br_cls.return_value = ovs_bridge
util.unplug_device(conf, device)
util.unplug_device(device)
mock_get_bridge_for_iface.assert_called_once_with('tap1')
self.assertEqual([], ovs_br_cls.mock_calls)
@ -338,8 +331,7 @@ class TestNetnsCleanup(base.BaseTestCase):
mock.call().get_devices()])
self.assertTrue(kill_dhcp.called)
unplug.assert_has_calls(
[mock.call(conf, d) for d in
devices[1:]])
[mock.call(d) for d in devices[1:]])
expected.append(
mock.call().garbage_collect_namespace())