Method: Specinfra::Command::Darwin::Base::Host.check_is_resolvable
- Defined in:
- lib/specinfra/command/darwin/base/host.rb
permalink .check_is_resolvable(name, type) ⇒ Object
[View source]
3 4 5 6 7 8 9 10 11 12 13 |
# File 'lib/specinfra/command/darwin/base/host.rb', line 3 def check_is_resolvable(name, type) if type == "dns" ## try to resolve either A or AAAA record; grep is used to return the appropriate exit code %Q{dig +search +short +time=1 -q #{escape(name)} a #{escape(name)} aaaa | grep -qie '^[0-9a-f:.]*$'} elsif type == "hosts" "sed 's/#.*$//' /etc/hosts | grep -w -- #{escape(name)}" else ## grep is required as dscacheutil always returns exit code 0 "dscacheutil -q host -a name #{escape(name)} | grep -q '_address:'" end end |