class Inspec::Resources::Bond

def content

def content
  read_content if @loaded == false
  @content
end

def exist?

def exist?
  @file.exist?
end

def has_interface?(interface)

def has_interface?(interface)
  params['Slave Interface'].include?(interface)
end

def initialize(bond)

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

def interfaces

def interfaces
  params['Slave Interface']
end

def mode

def mode
  params['Bonding Mode'].first
end

def params

ensures the content is loaded before we return the params
def params
  read_content if @loaded == false
  @params
end

def read_content

def read_content
  @params = SimpleConfig.new(
    @content,
    assignment_regex: /^\s*([^:]*?)\s*:\s*(.*?)\s*$/,
    multiple_values: true,
  ).params if @file.exist?
  @loaded = true
  @content
end

def to_s

def to_s
  "Bond #{@bond}"
end