Method: Specinfra::Command::Windows::Base::Host.check_is_reachable

Defined in:
lib/specinfra/command/windows/base/host.rb

.check_is_reachable(host, port, proto, timeout) ⇒ Object


12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/specinfra/command/windows/base/host.rb', line 12

def check_is_reachable(host, port, proto, timeout)
  if port.nil?
    Backend::PowerShell::Command.new do
      exec "(New-Object System.Net.NetworkInformation.Ping).send('#{host}').Status -eq 'Success'"
    end
  else
    Backend::PowerShell::Command.new do
      using 'is_remote_port_listening.ps1'
      exec"(IsRemotePortListening -hostname #{host} -port #{port} -timeout #{timeout} -proto #{proto}) -eq $true"
    end
  end
end