diff --git a/modules/test/conn/python/src/connection_module.py b/modules/test/conn/python/src/connection_module.py index 4a0cd8376..b7717730b 100644 --- a/modules/test/conn/python/src/connection_module.py +++ b/modules/test/conn/python/src/connection_module.py @@ -599,12 +599,7 @@ def _connection_ipv6_ping(self): def _ping(self, host, ipv6=False): LOGGER.info('Pinging: ' + str(host)) - cmd = 'ping -c 1 ' - cmd += ' -6 ' if ipv6 else '' - cmd += str(host) - #cmd = 'ping -c 1 ' + str(host) - success = util.run_command(cmd, output=False) # pylint: disable=E1120 - return success + return self._dhcp_util.ping(host, ipv6=ipv6) def restore_failover_dhcp_server(self, subnet): # Configure the subnet range diff --git a/modules/test/conn/python/src/dhcp_util.py b/modules/test/conn/python/src/dhcp_util.py index 22880dab0..cfca338df 100644 --- a/modules/test/conn/python/src/dhcp_util.py +++ b/modules/test/conn/python/src/dhcp_util.py @@ -14,6 +14,7 @@ """Module that contains various methods for validating the DHCP device behaviors""" +import re import time from datetime import datetime import util @@ -205,10 +206,15 @@ def is_lease_active(self, lease): LOGGER.error('Failed to confirm a valid active lease for the device') return ping_success - def ping(self, host): - cmd = 'ping -c 1 ' + str(host) - success = util.run_command(cmd, output=False) # pylint: disable=E1120 - return success + def ping(self, host, ipv6=False): + if ipv6: + command = f'ping -c 1 -6 {host}' + else: + command = f'ping -c 1 {host}' + out, _ = util.run_command(command, supress_error=True) + if re.search(r'\s0% packet loss', out): + return True + return False def add_reserved_lease(self, hostname,