Only create one IPWrapper class instance in _arping()
We are calling arping many times in the same namespace, no need to create multiple IPWrapper class instances. Trivialfix Change-Id: Id360324d4d31181ebf39f7796346635da043f350
This commit is contained in:
parent
80085abcd6
commit
7fa05a75c2
|
@ -1051,6 +1051,7 @@ def _arping(ns_name, iface_name, address, count, log_exception):
|
|||
# not expected. In some cases (no response) and with some
|
||||
# platforms (>=Ubuntu 14.04), arping exit code can be 1.
|
||||
extra_ok_codes = [1]
|
||||
ip_wrapper = IPWrapper(namespace=ns_name)
|
||||
for i in range(count):
|
||||
if not first:
|
||||
# hopefully enough for kernel to get out of locktime loop
|
||||
|
@ -1075,7 +1076,6 @@ def _arping(ns_name, iface_name, address, count, log_exception):
|
|||
# removed while running
|
||||
'-w', 1.5, address]
|
||||
try:
|
||||
ip_wrapper = IPWrapper(namespace=ns_name)
|
||||
ip_wrapper.netns.execute(arping_cmd,
|
||||
extra_ok_codes=extra_ok_codes)
|
||||
except Exception as exc:
|
||||
|
|
|
@ -1699,15 +1699,10 @@ class TestArpPing(TestIPCmdBase):
|
|||
mIPWrapper.assert_has_calls([
|
||||
mock.call(namespace=mock.sentinel.ns_name),
|
||||
mock.call().netns.execute(mock.ANY, extra_ok_codes=[1]),
|
||||
mock.call(namespace=mock.sentinel.ns_name),
|
||||
mock.call().netns.execute(mock.ANY, extra_ok_codes=[1]),
|
||||
mock.call(namespace=mock.sentinel.ns_name),
|
||||
mock.call().netns.execute(mock.ANY, extra_ok_codes=[1, 2]),
|
||||
mock.call(namespace=mock.sentinel.ns_name),
|
||||
mock.call().netns.execute(mock.ANY, extra_ok_codes=[1, 2]),
|
||||
mock.call(namespace=mock.sentinel.ns_name),
|
||||
mock.call().netns.execute(mock.ANY, extra_ok_codes=[1, 2]),
|
||||
mock.call(namespace=mock.sentinel.ns_name),
|
||||
mock.call().netns.execute(mock.ANY, extra_ok_codes=[1, 2])])
|
||||
|
||||
ip_wrapper = mIPWrapper(namespace=mock.sentinel.ns_name)
|
||||
|
|
Loading…
Reference in New Issue