Method: Specinfra::Command::Darwin::Base::Interface.get_link_state

Defined in:
lib/specinfra/command/darwin/base/interface.rb
[View source]

44
45
46
47
48
49
# File 'lib/specinfra/command/darwin/base/interface.rb', line 44

def get_link_state(interface)
  # Checks if interfaces is administratively up with the -u arg.
  # L1 check via status. Virtual interfaces like tapX missing the status will report up.
  # Emulates operstate in linux with exception of the unknown status.
  %Q{ifconfig -u #{interface} 2>&1 | awk -v s=up '/status:/ && $2 != "active" { s="down" }; END {print s}'}
end