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:
parent
6918f4a237
commit
f30fc92adf
@ -117,7 +117,7 @@ def eligible_for_deletion(conf, namespace, force=False):
|
|||||||
return force or ip.namespace_is_empty()
|
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()
|
orig_log_fail_as_error = device.get_log_fail_as_error()
|
||||||
device.set_log_fail_as_error(False)
|
device.set_log_fail_as_error(False)
|
||||||
try:
|
try:
|
||||||
@ -246,7 +246,7 @@ def destroy_namespace(conf, namespace, force=False):
|
|||||||
LOG.error('Not all processes were killed in %s',
|
LOG.error('Not all processes were killed in %s',
|
||||||
namespace)
|
namespace)
|
||||||
for device in ip.get_devices():
|
for device in ip.get_devices():
|
||||||
unplug_device(conf, device)
|
unplug_device(device)
|
||||||
|
|
||||||
ip.garbage_collect_namespace()
|
ip.garbage_collect_namespace()
|
||||||
except Exception:
|
except Exception:
|
||||||
|
@ -145,16 +145,12 @@ class TestNetnsCleanup(base.BaseTestCase):
|
|||||||
ip_wrap.assert_has_calls(expected_calls)
|
ip_wrap.assert_has_calls(expected_calls)
|
||||||
|
|
||||||
def test_unplug_device_regular_device(self):
|
def test_unplug_device_regular_device(self):
|
||||||
conf = mock.Mock()
|
|
||||||
device = mock.Mock()
|
device = mock.Mock()
|
||||||
|
|
||||||
util.unplug_device(conf, device)
|
util.unplug_device(device)
|
||||||
device.assert_has_calls([mock.call.link.delete()])
|
device.assert_has_calls([mock.call.link.delete()])
|
||||||
|
|
||||||
def test_unplug_device_ovs_port(self):
|
def test_unplug_device_ovs_port(self):
|
||||||
conf = mock.Mock()
|
|
||||||
conf.ovs_integration_bridge = 'br-int'
|
|
||||||
|
|
||||||
device = mock.Mock()
|
device = mock.Mock()
|
||||||
device.name = 'tap1'
|
device.name = 'tap1'
|
||||||
device.link.delete.side_effect = RuntimeError
|
device.link.delete.side_effect = RuntimeError
|
||||||
@ -168,7 +164,7 @@ class TestNetnsCleanup(base.BaseTestCase):
|
|||||||
ovs_bridge = mock.Mock()
|
ovs_bridge = mock.Mock()
|
||||||
ovs_br_cls.return_value = ovs_bridge
|
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')
|
mock_get_bridge_for_iface.assert_called_once_with('tap1')
|
||||||
ovs_br_cls.assert_called_once_with('br-int')
|
ovs_br_cls.assert_called_once_with('br-int')
|
||||||
@ -176,9 +172,6 @@ class TestNetnsCleanup(base.BaseTestCase):
|
|||||||
[mock.call.delete_port(device.name)])
|
[mock.call.delete_port(device.name)])
|
||||||
|
|
||||||
def test_unplug_device_cannot_determine_bridge_port(self):
|
def test_unplug_device_cannot_determine_bridge_port(self):
|
||||||
conf = mock.Mock()
|
|
||||||
conf.ovs_integration_bridge = 'br-int'
|
|
||||||
|
|
||||||
device = mock.Mock()
|
device = mock.Mock()
|
||||||
device.name = 'tap1'
|
device.name = 'tap1'
|
||||||
device.link.delete.side_effect = RuntimeError
|
device.link.delete.side_effect = RuntimeError
|
||||||
@ -193,7 +186,7 @@ class TestNetnsCleanup(base.BaseTestCase):
|
|||||||
ovs_bridge = mock.Mock()
|
ovs_bridge = mock.Mock()
|
||||||
ovs_br_cls.return_value = ovs_bridge
|
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')
|
mock_get_bridge_for_iface.assert_called_once_with('tap1')
|
||||||
self.assertEqual([], ovs_br_cls.mock_calls)
|
self.assertEqual([], ovs_br_cls.mock_calls)
|
||||||
@ -338,8 +331,7 @@ class TestNetnsCleanup(base.BaseTestCase):
|
|||||||
mock.call().get_devices()])
|
mock.call().get_devices()])
|
||||||
self.assertTrue(kill_dhcp.called)
|
self.assertTrue(kill_dhcp.called)
|
||||||
unplug.assert_has_calls(
|
unplug.assert_has_calls(
|
||||||
[mock.call(conf, d) for d in
|
[mock.call(d) for d in devices[1:]])
|
||||||
devices[1:]])
|
|
||||||
|
|
||||||
expected.append(
|
expected.append(
|
||||||
mock.call().garbage_collect_namespace())
|
mock.call().garbage_collect_namespace())
|
||||||
|
Loading…
Reference in New Issue
Block a user