class Inspec::Resources::Bond
Public Class Methods
new(bond)
click to toggle source
# File lib/inspec/resources/bond.rb, line 18 def initialize(bond) @bond = bond @path = "/proc/net/bonding/#{bond}" @file = inspec.file(@path) @content = read_file_content(@path, allow_empty: true) @params = {} @loaded = false end
Public Instance Methods
content()
click to toggle source
# File lib/inspec/resources/bond.rb, line 45 def content read_content if @loaded == false @content end
exist?()
click to toggle source
# File lib/inspec/resources/bond.rb, line 50 def exist? @file.exist? end
has_interface?(interface)
click to toggle source
# File lib/inspec/resources/bond.rb, line 54 def has_interface?(interface) params["Slave Interface"].include?(interface) end
interfaces()
click to toggle source
# File lib/inspec/resources/bond.rb, line 58 def interfaces params["Slave Interface"] end
mode()
click to toggle source
# File lib/inspec/resources/bond.rb, line 62 def mode params["Bonding Mode"].first end
params()
click to toggle source
ensures the content is loaded before we return the params
# File lib/inspec/resources/bond.rb, line 40 def params read_content if @loaded == false @params end
read_content()
click to toggle source
# File lib/inspec/resources/bond.rb, line 27 def read_content if @file.exist? @params = SimpleConfig.new( @content, assignment_regex: /^\s*([^:]*?)\s*:\s*(.*?)\s*$/, multiple_values: true ).params end @loaded = true @content end
to_s()
click to toggle source
# File lib/inspec/resources/bond.rb, line 66 def to_s "Bond #{@bond}" end