Sha256: 2322496f8c8d56e9cfdf88ab3fb3a478f6ae7796c5bb1dad6dd90d643877ff04

Contents?: true

Size: 784 Bytes

Versions: 6

Compression:

Stored size: 784 Bytes

Contents

module Serverspec::Type
  class Interface < Base
    def exists?
      @runner.check_interface_exists(@name)
    end

    def speed
      ret = @runner.get_interface_speed_of(@name)
      val_to_integer(ret)
    end

    def mtu
      ret = @runner.get_interface_mtu_of(@name)
      val_to_integer(ret)
    end

    def has_ipv4_address?(ip_address)
      @runner.check_interface_has_ipv4_address(@name, ip_address)
    end

    def has_ipv6_address?(ip_address)
      @runner.check_interface_has_ipv6_address(@name, ip_address)
    end

    def up?
      ret = @runner.get_interface_link_state(@name)
      ret.stdout.strip == 'up'
    end

    private

    def val_to_integer(ret)
      val = ret.stdout.strip
      val = val.to_i if val.match(/^\d+$/)
      val
    end

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
serverspec-2.30.1 lib/serverspec/type/interface.rb
serverspec-2.30.0 lib/serverspec/type/interface.rb
serverspec-2.29.2 lib/serverspec/type/interface.rb
serverspec-2.29.1 lib/serverspec/type/interface.rb
serverspec-2.29.0 lib/serverspec/type/interface.rb
serverspec-2.28.0 lib/serverspec/type/interface.rb