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

Defined in:
lib/specinfra/command/openbsd/base/interface.rb

48
49
50
51
52
53
54
# File 'lib/specinfra/command/openbsd/base/interface.rb', line 48

def get_link_state(interface)
  # Checks if interfaces is administratively up by parsing the options.
  # 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 #{interface} 2>&1 | awk -v s=down -F '[:<>,]' } +
  %Q{'NR == 1 && $3 == "UP" { s="up" }; /status:/ && $2 != " active" { s="down" }; END{ print s }'}
end