/usr/lib/ruby/vendor_ruby/serverspec/type/interface.rb is in ruby-serverspec 2.37.2-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | 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 ipv4_address
@runner.get_interface_ipv4_address(@name).stdout.strip
end
def ipv6_address
@runner.get_interface_ipv6_address(@name).stdout.strip
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
|