Class: Specinfra::Command::Freebsd::Base::Interface
- Inherits:
-
Base::Interface
- Object
- Base
- Base::Interface
- Specinfra::Command::Freebsd::Base::Interface
- Defined in:
- lib/specinfra/command/freebsd/base/interface.rb
Class Method Summary collapse
- .check_exists(name) ⇒ Object
- .check_has_ipv4_address(interface, ip_address) ⇒ Object
- .check_has_ipv6_address(interface, ip_address) ⇒ Object
Methods inherited from Base
Class Method Details
.check_exists(name) ⇒ Object
3 4 5 |
# File 'lib/specinfra/command/freebsd/base/interface.rb', line 3 def check_exists(name) "ifconfig #{name}" end |
.check_has_ipv4_address(interface, ip_address) ⇒ Object
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/specinfra/command/freebsd/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) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/specinfra/command/freebsd/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 |