Class: Inspec::Resources::Host
- Inherits:
-
Object
- Object
- Inspec::Resources::Host
- Defined in:
- lib/resources/host.rb
Instance Method Summary collapse
-
#initialize(hostname, params = {}) ⇒ Host
constructor
A new instance of Host.
-
#ipaddress ⇒ Object
returns all A records of the IP adress, will return an array.
- #reachable?(port = nil, proto = nil, timeout = nil) ⇒ Boolean
-
#resolvable?(type = nil) ⇒ Boolean
if we get the IP adress, the host is resolvable.
- #to_s ⇒ Object
Constructor Details
#initialize(hostname, params = {}) ⇒ Host
Returns a new instance of Host.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/resources/host.rb', line 37 def initialize(hostname, params = {}) @hostname = hostname @port = params[:port] || nil @proto = params[:proto] || nil @host_provider = nil if inspec.os.linux? @host_provider = LinuxHostProvider.new(inspec) elsif inspec.os.windows? @host_provider = WindowsHostProvider.new(inspec) else return skip_resource 'The `host` resource is not supported on your OS yet.' end end |
Instance Method Details
#ipaddress ⇒ Object
returns all A records of the IP adress, will return an array
64 65 66 |
# File 'lib/resources/host.rb', line 64 def ipaddress resolve.nil? || resolve.empty? ? nil : resolve end |
#reachable?(port = nil, proto = nil, timeout = nil) ⇒ Boolean
58 59 60 61 |
# File 'lib/resources/host.rb', line 58 def reachable?(port = nil, proto = nil, timeout = nil) fail "Use `host` resource with host('#{@hostname}', port: #{port}, proto: '#{proto}') parameters." if !port.nil? || !proto.nil? || !timeout.nil? ping.nil? ? false : ping end |
#resolvable?(type = nil) ⇒ Boolean
if we get the IP adress, the host is resolvable
53 54 55 56 |
# File 'lib/resources/host.rb', line 53 def resolvable?(type = nil) warn "The `host` resource ignores #{type} parameters. Continue to resolve host." if !type.nil? resolve.nil? || resolve.empty? ? false : true end |
#to_s ⇒ Object
68 69 70 |
# File 'lib/resources/host.rb', line 68 def to_s "Host #{@hostname}" end |