Class: LinuxHostProvider
- Inherits:
-
HostProvider
- Object
- HostProvider
- LinuxHostProvider
- Defined in:
- lib/resources/host.rb
Instance Attribute Summary
Attributes inherited from HostProvider
Instance Method Summary collapse
-
#ping(hostname, _port = nil, _proto = nil) ⇒ Object
ping is difficult to achieve, since we are not sure.
- #resolve(hostname) ⇒ Object
Methods inherited from HostProvider
Constructor Details
This class inherits a constructor from HostProvider
Instance Method Details
#ping(hostname, _port = nil, _proto = nil) ⇒ Object
ping is difficult to achieve, since we are not sure
93 94 95 96 97 98 |
# File 'lib/resources/host.rb', line 93 def ping(hostname, _port = nil, _proto = nil) # fall back to ping, but we can only test ICMP packages with ping # therefore we have to skip the test, if we do not have everything on the node to run the test ping = inspec.command("ping -w 1 -c 1 #{hostname}") ping.exit_status.to_i != 0 ? false : true end |
#resolve(hostname) ⇒ Object
100 101 102 103 104 105 106 107 108 |
# File 'lib/resources/host.rb', line 100 def resolve(hostname) # TODO: we rely on getent hosts for now, but it prefers to return IPv6, only then IPv4 cmd = inspec.command("getent hosts #{hostname}") return nil if cmd.exit_status.to_i != 0 # extract ip adress resolve = /^\s*(?<ip>\S+)\s+(.*)\s*$/.match(cmd.stdout.chomp) [resolve[1]] if resolve end |