Merge ""ping"/"ping6" command support in rootwrap filters" into stable/rocky

This commit is contained in:
Zuul 2020-11-15 11:24:20 +00:00 committed by Gerrit Code Review
commit 41ca97de0d
3 changed files with 9 additions and 8 deletions

View File

@ -12,7 +12,7 @@
# from inside a namespace which requires root # from inside a namespace which requires root
# _alt variants allow to match -c and -w in any order # _alt variants allow to match -c and -w in any order
# (used by NeutronDebugAgent.ping_all) # (used by NeutronDebugAgent.ping_all)
ping: RegExpFilter, ping, root, ping, -w, \d+, -c, \d+, [0-9\.]+ ping: CommandFilter, ping, root
ping_alt: RegExpFilter, ping, root, ping, -c, \d+, -w, \d+, [0-9\.]+ ping6: CommandFilter, ping6, root
ping6: RegExpFilter, ping6, root, ping6, -w, \d+, -c, \d+, [0-9A-Fa-f:]+ ping_exec: IpNetnsExecFilter, ping, root
ping6_alt: RegExpFilter, ping6, root, ping6, -c, \d+, -w, \d+, [0-9A-Fa-f:]+ ping6_exec: IpNetnsExecFilter, ping6, root

View File

@ -110,7 +110,7 @@ def assert_ping(src_namespace, dst_ip, timeout=1, count=3):
ipversion = netaddr.IPAddress(dst_ip).version ipversion = netaddr.IPAddress(dst_ip).version
ping_command = 'ping' if ipversion == 4 else 'ping6' ping_command = 'ping' if ipversion == 4 else 'ping6'
ns_ip_wrapper = ip_lib.IPWrapper(src_namespace) ns_ip_wrapper = ip_lib.IPWrapper(src_namespace)
ns_ip_wrapper.netns.execute([ping_command, '-c', count, '-W', timeout, ns_ip_wrapper.netns.execute([ping_command, '-W', timeout, '-c', count,
dst_ip]) dst_ip])
@ -123,7 +123,7 @@ def assert_async_ping(src_namespace, dst_ip, timeout=1, count=1, interval=1):
# cannot be used and it needs to be done using the following workaround. # cannot be used and it needs to be done using the following workaround.
for _index in range(count): for _index in range(count):
start_time = time.time() start_time = time.time()
ns_ip_wrapper.netns.execute([ping_command, '-c', '1', '-W', timeout, ns_ip_wrapper.netns.execute([ping_command, '-W', timeout, '-c', '1',
dst_ip]) dst_ip])
end_time = time.time() end_time = time.time()
diff = end_time - start_time diff = end_time - start_time
@ -389,11 +389,12 @@ class Pinger(object):
raise RuntimeError("This pinger has already a running process") raise RuntimeError("This pinger has already a running process")
ip_version = common_utils.get_ip_version(self.address) ip_version = common_utils.get_ip_version(self.address)
ping_exec = 'ping' if ip_version == 4 else 'ping6' ping_exec = 'ping' if ip_version == 4 else 'ping6'
cmd = [ping_exec, self.address, '-W', str(self.timeout)] cmd = [ping_exec, '-W', str(self.timeout)]
if self.count: if self.count:
cmd.extend(['-c', str(self.count)]) cmd.extend(['-c', str(self.count)])
if self.interval: if self.interval:
cmd.extend(['-i', str(self.interval)]) cmd.extend(['-i', str(self.interval)])
cmd.append(self.address)
self.proc = RootHelperProcess(cmd, namespace=self.namespace) self.proc = RootHelperProcess(cmd, namespace=self.namespace)
def stop(self): def stop(self):

View File

@ -333,7 +333,7 @@ class L3AgentTestCase(framework.L3AgentTestFramework):
# Verify that the ping replys with fip # Verify that the ping replys with fip
ns_ip_wrapper = ip_lib.IPWrapper(src_machine.namespace) ns_ip_wrapper = ip_lib.IPWrapper(src_machine.namespace)
result = ns_ip_wrapper.netns.execute( result = ns_ip_wrapper.netns.execute(
['ping', '-c', 1, '-W', 5, dst_fip]) ['ping', '-W', 5, '-c', 1, dst_fip])
self._assert_ping_reply_from_expected_address(result, dst_fip) self._assert_ping_reply_from_expected_address(result, dst_fip)
def _setup_address_scope(self, internal_address_scope1, def _setup_address_scope(self, internal_address_scope1,