From 46a7150d862943ee72a391141cbc6a84cf66bde3 Mon Sep 17 00:00:00 2001 From: Eduardo Olivares Date: Tue, 3 Jun 2025 15:16:13 +0200 Subject: [PATCH] Run ping with interval option only when the ping interface supports it Some ping interfaces, such as busybox (cirros) do not support the -i option. Tobiko should ignore the interval value in those cases. Closes-ticket: TOBIKO-151 Change-Id: Ie5629c51479f4577fb0d0da41ef3550b6f41be48 --- tobiko/shell/ping/_interface.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/tobiko/shell/ping/_interface.py b/tobiko/shell/ping/_interface.py index 3307582ce..ff0cf0e45 100644 --- a/tobiko/shell/ping/_interface.py +++ b/tobiko/shell/ping/_interface.py @@ -172,7 +172,11 @@ class PingInterface(object): interval = parameters.interval if interval > 1: - options += self.get_interval_option(interval) + if self.has_interval_option: + options += self.get_interval_option(interval) + else: + LOG.warning(f'Interval option with value {interval} ignored ' + f'because not supported by ping interface {self}') fragment = parameters.fragmentation if fragment is not None: @@ -199,8 +203,12 @@ class PingInterface(object): def get_size_option(self, size): return ['-s', int(size)] + has_interval_option = False + def get_interval_option(self, interval): - return ['-i', int(interval)] + details = ("{!r} ping implementation doesn't support " + "'interval={!r}' option").format(self, interval) + raise _exception.UnsupportedPingOption(details=details) has_fragment_option = False @@ -238,6 +246,11 @@ class IpUtilsPingInterface(PingInterface): def match_ping_usage(self, usage): return usage.startswith(IPUTILS_PING_USAGE) + has_interval_option = True + + def get_interval_option(self, interval): + return ['-i', int(interval)] + has_fragment_option = True def get_fragment_option(self, fragment):