def ping_default_gateway():
 network = open('/etc/sysconfig/network')
 m = re.search('GATEWAY=(\\S+)', network.read())
 if m:
  gw = m.group(1)
  cmd = ('ping %s -c 5 > /dev/null' % gw)
  return utils.system(cmd, ignore_status=True)
 raise error.TestError('Unable to find default gateway')

def ping_default_gateway ( ) : network = open ( '/etc/sysconfig/network' ) m = re . search ( 'GATEWAY=(\\S+)' , network . read ( ) ) if m : gw = m . group ( 1 ) cmd = ( 'ping %s -c 5 > /dev/null' % gw ) return utils . system ( cmd , ignore_status = True ) raise error . TestError ( 'Unable to find default gateway' )
ping the default gateway .