Class: Specinfra::Command::Linux::Base::Interface
- Inherits:
-
Base::Interface
- Object
- Base
- Base::Interface
- Specinfra::Command::Linux::Base::Interface
- Defined in:
- lib/specinfra/command/linux/base/interface.rb
Direct Known Subclasses
Class Method Summary collapse
- .check_exists(name) ⇒ Object
- .check_has_ipv4_address(interface, ip_address) ⇒ Object
- .check_has_ipv6_address(interface, ip_address) ⇒ Object
- .get_ipv4_address(interface) ⇒ Object
- .get_ipv6_address(interface) ⇒ Object
- .get_link_state(name) ⇒ Object
- .get_mtu_of(name) ⇒ Object
- .get_speed_of(name) ⇒ Object
Methods inherited from Base
Class Method Details
.check_exists(name) ⇒ Object
3 4 5 |
# File 'lib/specinfra/command/linux/base/interface.rb', line 3 def check_exists(name) "ip link show #{name}" end |
.check_has_ipv4_address(interface, ip_address) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/specinfra/command/linux/base/interface.rb', line 15 def check_has_ipv4_address(interface, ip_address) ip_address = ip_address.dup if ip_address =~ /\/\d+$/ ip_address << " " else ip_address << "/" end ip_address.gsub!(".", "\\.") "ip -4 addr show #{interface} | grep 'inet #{ip_address}'" end |
.check_has_ipv6_address(interface, ip_address) ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/specinfra/command/linux/base/interface.rb', line 26 def check_has_ipv6_address(interface, ip_address) ip_address = ip_address.dup if ip_address =~ /\/\d+$/ ip_address << " " else ip_address << "/" end ip_address.downcase! "ip -6 addr show #{interface} | grep 'inet6 #{ip_address}'" end |
.get_ipv4_address(interface) ⇒ Object
37 38 39 |
# File 'lib/specinfra/command/linux/base/interface.rb', line 37 def get_ipv4_address(interface) "ip -4 addr show #{interface} | grep #{interface}$ | awk '{print $2}'" end |
.get_ipv6_address(interface) ⇒ Object
41 42 43 |
# File 'lib/specinfra/command/linux/base/interface.rb', line 41 def get_ipv6_address(interface) "ip -6 addr show #{interface} | grep inet6 | awk '{print $2}'" end |
.get_link_state(name) ⇒ Object
45 46 47 |
# File 'lib/specinfra/command/linux/base/interface.rb', line 45 def get_link_state(name) "cat /sys/class/net/#{name}/operstate" end |
.get_mtu_of(name) ⇒ Object
11 12 13 |
# File 'lib/specinfra/command/linux/base/interface.rb', line 11 def get_mtu_of(name) "cat /sys/class/net/#{name}/mtu" end |
.get_speed_of(name) ⇒ Object
7 8 9 |
# File 'lib/specinfra/command/linux/base/interface.rb', line 7 def get_speed_of(name) "cat /sys/class/net/#{name}/speed" end |