class Specinfra::Command::Darwin::Base::Interface
Public Class Methods
check_exists(name)
click to toggle source
# File lib/specinfra/command/darwin/base/interface.rb, line 3 def check_exists(name) "ifconfig #{name}" end
check_has_ipv4_address(interface, ip_address)
click to toggle source
# File lib/specinfra/command/darwin/base/interface.rb, line 7 def check_has_ipv4_address(interface, ip_address) ip_address = ip_address.dup if ip_address =~ /\/\d+$/ # remove the prefix - better would be to calculate the netmask ip_address.gsub!(/\/\d+$/, "") end ip_address << " " ip_address.gsub!(".", "\\.") "ifconfig #{interface} inet | grep 'inet #{ip_address}'" end
check_has_ipv6_address(interface, ip_address)
click to toggle source
# File lib/specinfra/command/darwin/base/interface.rb, line 18 def check_has_ipv6_address(interface, ip_address) ip_address = ip_address.dup (ip_address, prefixlen) = ip_address.split(/\//) ip_address.downcase! if ip_address =~ /^fe80::/i # link local needs the scope (interface) appended ip_address << "%#{interface}" end unless prefixlen.to_s.empty? # append prefixlen ip_address << " prefixlen #{prefixlen}" else ip_address << " " end "ifconfig #{interface} inet6 | grep 'inet6 #{ip_address}'" end
get_link_state(interface)
click to toggle source
# File lib/specinfra/command/darwin/base/interface.rb, line 35 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