Class: Inspec::Resources::Bond
Instance Attribute Summary
Attributes inherited from FileResource
#file, #mount_options
Instance Method Summary
collapse
Methods included from FileReader
#read_file_content
#allowed?, #contain, #executable?, #more_permissive_than?, #mounted?, #readable?, #sgid, #sticky, #suid, #writable?
#includes_whitespaces?, #parse_mount_options
#select_file_perms_style
Constructor Details
#initialize(bond) ⇒ Bond
Returns a new instance of Bond.
19
20
21
22
23
24
25
26
|
# File 'lib/resources/bond.rb', line 19
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
|
Instance Method Details
#content ⇒ Object
44
45
46
47
|
# File 'lib/resources/bond.rb', line 44
def content
read_content if @loaded == false
@content
end
|
#exist? ⇒ Boolean
49
50
51
|
# File 'lib/resources/bond.rb', line 49
def exist?
@file.exist?
end
|
#has_interface?(interface) ⇒ Boolean
53
54
55
|
# File 'lib/resources/bond.rb', line 53
def has_interface?(interface)
params['Slave Interface'].include?(interface)
end
|
#interfaces ⇒ Object
57
58
59
|
# File 'lib/resources/bond.rb', line 57
def interfaces
params['Slave Interface']
end
|
#mode ⇒ Object
61
62
63
|
# File 'lib/resources/bond.rb', line 61
def mode
params['Bonding Mode'].first
end
|
#params ⇒ Object
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_content ⇒ Object
28
29
30
31
32
33
34
35
36
|
# File 'lib/resources/bond.rb', line 28
def read_content
@params = SimpleConfig.new(
@content,
assignment_regex: /^\s*([^:]*?)\s*:\s*(.*?)\s*$/,
multiple_values: true,
).params if @file.exist?
@loaded = true
@content
end
|
#to_s ⇒ Object
65
66
67
|
# File 'lib/resources/bond.rb', line 65
def to_s
"Bond #{@bond}"
end
|