Browse Source

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>
tags/14.0.0.0b1
Daniel Alvarez 7 months ago
parent
commit
f30fc92adf
2 changed files with 6 additions and 14 deletions
  1. 2
    2
      neutron/cmd/netns_cleanup.py
  2. 4
    12
      neutron/tests/unit/cmd/test_netns_cleanup.py

+ 2
- 2
neutron/cmd/netns_cleanup.py View File

@@ -117,7 +117,7 @@ def eligible_for_deletion(conf, namespace, force=False):
117 117
     return force or ip.namespace_is_empty()
118 118
 
119 119
 
120
-def unplug_device(conf, device):
120
+def unplug_device(device):
121 121
     orig_log_fail_as_error = device.get_log_fail_as_error()
122 122
     device.set_log_fail_as_error(False)
123 123
     try:
@@ -246,7 +246,7 @@ def destroy_namespace(conf, namespace, force=False):
246 246
                     LOG.error('Not all processes were killed in %s',
247 247
                               namespace)
248 248
                 for device in ip.get_devices():
249
-                    unplug_device(conf, device)
249
+                    unplug_device(device)
250 250
 
251 251
         ip.garbage_collect_namespace()
252 252
     except Exception:

+ 4
- 12
neutron/tests/unit/cmd/test_netns_cleanup.py View File

@@ -145,16 +145,12 @@ class TestNetnsCleanup(base.BaseTestCase):
145 145
             ip_wrap.assert_has_calls(expected_calls)
146 146
 
147 147
     def test_unplug_device_regular_device(self):
148
-        conf = mock.Mock()
149 148
         device = mock.Mock()
150 149
 
151
-        util.unplug_device(conf, device)
150
+        util.unplug_device(device)
152 151
         device.assert_has_calls([mock.call.link.delete()])
153 152
 
154 153
     def test_unplug_device_ovs_port(self):
155
-        conf = mock.Mock()
156
-        conf.ovs_integration_bridge = 'br-int'
157
-
158 154
         device = mock.Mock()
159 155
         device.name = 'tap1'
160 156
         device.link.delete.side_effect = RuntimeError
@@ -168,7 +164,7 @@ class TestNetnsCleanup(base.BaseTestCase):
168 164
                 ovs_bridge = mock.Mock()
169 165
                 ovs_br_cls.return_value = ovs_bridge
170 166
 
171
-                util.unplug_device(conf, device)
167
+                util.unplug_device(device)
172 168
 
173 169
                 mock_get_bridge_for_iface.assert_called_once_with('tap1')
174 170
                 ovs_br_cls.assert_called_once_with('br-int')
@@ -176,9 +172,6 @@ class TestNetnsCleanup(base.BaseTestCase):
176 172
                     [mock.call.delete_port(device.name)])
177 173
 
178 174
     def test_unplug_device_cannot_determine_bridge_port(self):
179
-        conf = mock.Mock()
180
-        conf.ovs_integration_bridge = 'br-int'
181
-
182 175
         device = mock.Mock()
183 176
         device.name = 'tap1'
184 177
         device.link.delete.side_effect = RuntimeError
@@ -193,7 +186,7 @@ class TestNetnsCleanup(base.BaseTestCase):
193 186
                     ovs_bridge = mock.Mock()
194 187
                     ovs_br_cls.return_value = ovs_bridge
195 188
 
196
-                    util.unplug_device(conf, device)
189
+                    util.unplug_device(device)
197 190
 
198 191
                     mock_get_bridge_for_iface.assert_called_once_with('tap1')
199 192
                     self.assertEqual([], ovs_br_cls.mock_calls)
@@ -338,8 +331,7 @@ class TestNetnsCleanup(base.BaseTestCase):
338 331
                                 mock.call().get_devices()])
339 332
                             self.assertTrue(kill_dhcp.called)
340 333
                             unplug.assert_has_calls(
341
-                                [mock.call(conf, d) for d in
342
-                                 devices[1:]])
334
+                                [mock.call(d) for d in devices[1:]])
343 335
 
344 336
                         expected.append(
345 337
                             mock.call().garbage_collect_namespace())

Loading…
Cancel
Save