Class: Specinfra::Command::Linux::Base::Interface

Inherits:
Base::Interface show all
Defined in:
lib/specinfra/command/linux/base/interface.rb

Class Method Summary collapse

Methods inherited from Base

create, escape

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



11
12
13
14
15
16
17
18
19
20
# File 'lib/specinfra/command/linux/base/interface.rb', line 11

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 addr show #{interface} | grep 'inet #{ip_address}'"
end

.check_has_ipv6_address(interface, ip_address) ⇒ Object



22
23
24
25
26
27
28
29
30
31
# File 'lib/specinfra/command/linux/base/interface.rb', line 22

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 addr show #{interface} | grep 'inet6 #{ip_address}'"
end


33
34
35
# File 'lib/specinfra/command/linux/base/interface.rb', line 33

def get_link_state(name)
  "cat /sys/class/net/#{name}/operstate"
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