Method: PSWindows::Exec#ping

Defined in:
lib/beaker/host/pswindows/exec.rb

#ping(target, attempts = 5) ⇒ Boolean

Attempt to ping the provided target hostname

Parameters:

  • target (String)

    The hostname to ping

  • attempts (Integer) (defaults to: 5)

    Amount of times to attempt ping before giving up

Returns:

  • (Boolean)

    true of ping successful, overwise false



90
91
92
93
94
95
96
97
98
99
# File 'lib/beaker/host/pswindows/exec.rb', line 90

def ping target, attempts = 5
  try = 0
  while try < attempts
    result = exec(Beaker::Command.new("ping -n 1 #{target}"), :accept_all_exit_codes => true)
    return true if result.exit_code == 0

    try += 1
  end
  result.exit_code == 0
end