From f30fc92adf607207d210b5cdf25c3020999641cc Mon Sep 17 00:00:00 2001 From: Daniel Alvarez Date: Wed, 10 Oct 2018 11:15:59 +0200 Subject: [PATCH] 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 --- neutron/cmd/netns_cleanup.py | 4 ++-- neutron/tests/unit/cmd/test_netns_cleanup.py | 16 ++++------------ 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/neutron/cmd/netns_cleanup.py b/neutron/cmd/netns_cleanup.py index ff33ee9eceb..3e9a8f624eb 100644 --- a/neutron/cmd/netns_cleanup.py +++ b/neutron/cmd/netns_cleanup.py @@ -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: diff --git a/neutron/tests/unit/cmd/test_netns_cleanup.py b/neutron/tests/unit/cmd/test_netns_cleanup.py index 3aff7fc2a17..c77b6554b2a 100644 --- a/neutron/tests/unit/cmd/test_netns_cleanup.py +++ b/neutron/tests/unit/cmd/test_netns_cleanup.py @@ -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())