Class: Specinfra::Command::Redhat::V7::Host

Inherits:
Base::Host show all
Defined in:
lib/specinfra/command/redhat/v7/host.rb

Class Method Summary collapse

Methods inherited from Base::Host

create

Methods inherited from Base::Host

check_is_resolvable, get_ipaddress, get_ipv4_address, get_ipv6_address

Methods inherited from Base

create, escape

Class Method Details

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



3
4
5
6
7
8
9
10
11
12
13
# File 'lib/specinfra/command/redhat/v7/host.rb', line 3

def check_is_reachable(host, port, proto, timeout)
  if port.nil?
    "ping -w #{escape(timeout)} -c 2 -n #{escape(host)}"
  else
    # RHEL7 comes with ncat which does no longer sport the -z option
    # hence this kludge
    "ncat -vvvv#{escape(proto[0].chr)} #{escape(host)} #{escape(port)} " +
    "-w #{escape(timeout)} -i #{escape(timeout)} 2>&1 | " +
    "grep -q SUCCESS"
  end
end