summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Alvarez <dalvarez@redhat.com>2018-10-10 11:15:59 +0200
committerDaniel Alvarez <dalvarez@redhat.com>2018-10-10 11:15:59 +0200
commitf30fc92adf607207d210b5cdf25c3020999641cc (patch)
tree8639abb2afaa2d023eb8bfbaf1f85280bfba9905
parent6918f4a2372991a41d02fa2313b38de157ac5ab3 (diff)
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>
Notes
Notes (review): Code-Review+1: Jakub Libosvar <libosvar@redhat.com> Code-Review+2: Slawek Kaplonski <skaplons@redhat.com> Code-Review+1: LIU Yulong <i@liuyulong.me> Code-Review+2: Brian Haley <haleyb.dev@gmail.com> Workflow+1: Brian Haley <haleyb.dev@gmail.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Thu, 11 Oct 2018 11:06:44 +0000 Reviewed-on: https://review.openstack.org/609336 Project: openstack/neutron Branch: refs/heads/master
-rw-r--r--neutron/cmd/netns_cleanup.py4
-rw-r--r--neutron/tests/unit/cmd/test_netns_cleanup.py16
2 files changed, 6 insertions, 14 deletions
diff --git a/neutron/cmd/netns_cleanup.py b/neutron/cmd/netns_cleanup.py
index ff33ee9..3e9a8f6 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):
117 return force or ip.namespace_is_empty() 117 return force or ip.namespace_is_empty()
118 118
119 119
120def unplug_device(conf, device): 120def unplug_device(device):
121 orig_log_fail_as_error = device.get_log_fail_as_error() 121 orig_log_fail_as_error = device.get_log_fail_as_error()
122 device.set_log_fail_as_error(False) 122 device.set_log_fail_as_error(False)
123 try: 123 try:
@@ -246,7 +246,7 @@ def destroy_namespace(conf, namespace, force=False):
246 LOG.error('Not all processes were killed in %s', 246 LOG.error('Not all processes were killed in %s',
247 namespace) 247 namespace)
248 for device in ip.get_devices(): 248 for device in ip.get_devices():
249 unplug_device(conf, device) 249 unplug_device(device)
250 250
251 ip.garbage_collect_namespace() 251 ip.garbage_collect_namespace()
252 except Exception: 252 except Exception:
diff --git a/neutron/tests/unit/cmd/test_netns_cleanup.py b/neutron/tests/unit/cmd/test_netns_cleanup.py
index 3aff7fc..c77b655 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):
145 ip_wrap.assert_has_calls(expected_calls) 145 ip_wrap.assert_has_calls(expected_calls)
146 146
147 def test_unplug_device_regular_device(self): 147 def test_unplug_device_regular_device(self):
148 conf = mock.Mock()
149 device = mock.Mock() 148 device = mock.Mock()
150 149
151 util.unplug_device(conf, device) 150 util.unplug_device(device)
152 device.assert_has_calls([mock.call.link.delete()]) 151 device.assert_has_calls([mock.call.link.delete()])
153 152
154 def test_unplug_device_ovs_port(self): 153 def test_unplug_device_ovs_port(self):
155 conf = mock.Mock()
156 conf.ovs_integration_bridge = 'br-int'
157
158 device = mock.Mock() 154 device = mock.Mock()
159 device.name = 'tap1' 155 device.name = 'tap1'
160 device.link.delete.side_effect = RuntimeError 156 device.link.delete.side_effect = RuntimeError
@@ -168,7 +164,7 @@ class TestNetnsCleanup(base.BaseTestCase):
168 ovs_bridge = mock.Mock() 164 ovs_bridge = mock.Mock()
169 ovs_br_cls.return_value = ovs_bridge 165 ovs_br_cls.return_value = ovs_bridge
170 166
171 util.unplug_device(conf, device) 167 util.unplug_device(device)
172 168
173 mock_get_bridge_for_iface.assert_called_once_with('tap1') 169 mock_get_bridge_for_iface.assert_called_once_with('tap1')
174 ovs_br_cls.assert_called_once_with('br-int') 170 ovs_br_cls.assert_called_once_with('br-int')
@@ -176,9 +172,6 @@ class TestNetnsCleanup(base.BaseTestCase):
176 [mock.call.delete_port(device.name)]) 172 [mock.call.delete_port(device.name)])
177 173
178 def test_unplug_device_cannot_determine_bridge_port(self): 174 def test_unplug_device_cannot_determine_bridge_port(self):
179 conf = mock.Mock()
180 conf.ovs_integration_bridge = 'br-int'
181
182 device = mock.Mock() 175 device = mock.Mock()
183 device.name = 'tap1' 176 device.name = 'tap1'
184 device.link.delete.side_effect = RuntimeError 177 device.link.delete.side_effect = RuntimeError
@@ -193,7 +186,7 @@ class TestNetnsCleanup(base.BaseTestCase):
193 ovs_bridge = mock.Mock() 186 ovs_bridge = mock.Mock()
194 ovs_br_cls.return_value = ovs_bridge 187 ovs_br_cls.return_value = ovs_bridge
195 188
196 util.unplug_device(conf, device) 189 util.unplug_device(device)
197 190
198 mock_get_bridge_for_iface.assert_called_once_with('tap1') 191 mock_get_bridge_for_iface.assert_called_once_with('tap1')
199 self.assertEqual([], ovs_br_cls.mock_calls) 192 self.assertEqual([], ovs_br_cls.mock_calls)
@@ -338,8 +331,7 @@ class TestNetnsCleanup(base.BaseTestCase):
338 mock.call().get_devices()]) 331 mock.call().get_devices()])
339 self.assertTrue(kill_dhcp.called) 332 self.assertTrue(kill_dhcp.called)
340 unplug.assert_has_calls( 333 unplug.assert_has_calls(
341 [mock.call(conf, d) for d in 334 [mock.call(d) for d in devices[1:]])
342 devices[1:]])
343 335
344 expected.append( 336 expected.append(
345 mock.call().garbage_collect_namespace()) 337 mock.call().garbage_collect_namespace())