Class: Inspec::Resources::Bond

Inherits:
FileResource show all
Defined in:
lib/resources/bond.rb

Instance Attribute Summary

Attributes inherited from FileResource

#file, #mount_options

Instance Method Summary collapse

Methods inherited from FileResource

#contain, #executable?, #mounted?, #readable?, #sgid, #sticky, #suid, #writable?

Methods included from LinuxMountParser

#parse_mount_options

Methods included from FilePermissionsSelector

#select_file_perms_style

Constructor Details

#initialize(bond) ⇒ Bond

Returns a new instance of Bond.



17
18
19
20
21
22
23
24
# File 'lib/resources/bond.rb', line 17

def initialize(bond)
  @bond = bond
  @path = "/proc/net/bonding/#{bond}"
  @file = inspec.file(@path)
  @content = nil
  @params = {}
  @loaded = false
end

Instance Method Details

#contentObject



44
45
46
47
# File 'lib/resources/bond.rb', line 44

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

#exist?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/resources/bond.rb', line 49

def exist?
  @file.exist?
end

#has_interface?(interface) ⇒ Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/resources/bond.rb', line 53

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

#interfacesObject



57
58
59
# File 'lib/resources/bond.rb', line 57

def interfaces
  params['Slave Interface']
end

#paramsObject

ensures the content is loaded before we return the params



39
40
41
42
# File 'lib/resources/bond.rb', line 39

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

#read_contentObject



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/resources/bond.rb', line 26

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

#to_sObject



61
62
63
# File 'lib/resources/bond.rb', line 61

def to_s
  "Bond #{@bond}"
end