Sha256: f0e8bb7a15f208117e2ae176152ab5bf8f56bc8e21d6c00690032c244b707c56

Contents?: true

Size: 1.21 KB

Versions: 145

Compression:

Stored size: 1.21 KB

Contents

class Specinfra::Command::Linux::Base::Interface < Specinfra::Command::Base::Interface
  class << self
    def check_exists(name)
      "ip link show #{name}"
    end

    def get_speed_of(name)
      "cat /sys/class/net/#{name}/speed"
    end

    def get_mtu_of(name)
      "cat /sys/class/net/#{name}/mtu"
    end

    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

    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

    def get_ipv4_address(interface)
      "ip -4 addr show #{interface} | grep #{interface}$ | awk '{print $2}'"
    end

    def get_ipv6_address(interface)
      "ip -6 addr show #{interface} | grep inet6 | awk '{print $2}'"
    end

    def get_link_state(name)
      "cat /sys/class/net/#{name}/operstate"
    end
  end
end

Version data entries

145 entries across 145 versions & 1 rubygems

Version Path
specinfra-2.91.0 lib/specinfra/command/linux/base/interface.rb
specinfra-2.90.1 lib/specinfra/command/linux/base/interface.rb
specinfra-2.90.0 lib/specinfra/command/linux/base/interface.rb
specinfra-2.89.0 lib/specinfra/command/linux/base/interface.rb
specinfra-2.88.2 lib/specinfra/command/linux/base/interface.rb
specinfra-2.88.1 lib/specinfra/command/linux/base/interface.rb
specinfra-2.88.0 lib/specinfra/command/linux/base/interface.rb
specinfra-2.87.2 lib/specinfra/command/linux/base/interface.rb
specinfra-2.87.1 lib/specinfra/command/linux/base/interface.rb
specinfra-2.87.0 lib/specinfra/command/linux/base/interface.rb
specinfra-2.86.0 lib/specinfra/command/linux/base/interface.rb
specinfra-2.85.1 lib/specinfra/command/linux/base/interface.rb
specinfra-2.85.0 lib/specinfra/command/linux/base/interface.rb
specinfra-2.84.1 lib/specinfra/command/linux/base/interface.rb
specinfra-2.84.0 lib/specinfra/command/linux/base/interface.rb
specinfra-2.83.4 lib/specinfra/command/linux/base/interface.rb
specinfra-2.83.3 lib/specinfra/command/linux/base/interface.rb
specinfra-2.83.2 lib/specinfra/command/linux/base/interface.rb
specinfra-2.83.1 lib/specinfra/command/linux/base/interface.rb
specinfra-2.83.0 lib/specinfra/command/linux/base/interface.rb