Class: Inspec::Resources::Bond
Instance Attribute Summary
Attributes inherited from FileResource
#file, #mount_options
Instance Method Summary
collapse
#allowed?, #contain, #executable?, #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.
16
17
18
19
20
21
22
23
|
# File 'lib/resources/bond.rb', line 16
def initialize(bond)
@bond = bond
@path = "/proc/net/bonding/#{bond}"
@file = inspec.file(@path)
@content = nil
@params = {}
@loaded = false
end
|
Instance Method Details
#content ⇒ Object
43
44
45
46
|
# File 'lib/resources/bond.rb', line 43
def content
read_content if @loaded == false
@content
end
|
#exist? ⇒ Boolean
48
49
50
|
# File 'lib/resources/bond.rb', line 48
def exist?
@file.exist?
end
|
#has_interface?(interface) ⇒ Boolean
52
53
54
|
# File 'lib/resources/bond.rb', line 52
def has_interface?(interface)
params['Slave Interface'].include?(interface)
end
|
#interfaces ⇒ Object
56
57
58
|
# File 'lib/resources/bond.rb', line 56
def interfaces
params['Slave Interface']
end
|
#mode ⇒ Object
60
61
62
|
# File 'lib/resources/bond.rb', line 60
def mode
params['Bonding Mode'].first
end
|
#params ⇒ Object
ensures the content is loaded before we return the params
38
39
40
41
|
# File 'lib/resources/bond.rb', line 38
def params
read_content if @loaded == false
@params
end
|
#read_content ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/resources/bond.rb', line 25
def read_content
@content = @file.content
@params = SimpleConfig.new(
@file.content,
assignment_regex: /^\s*([^:]*?)\s*:\s*(.*?)\s*$/,
multiple_values: true,
).params if @file.exist?
@loaded = true
@content
end
|
#to_s ⇒ Object
64
65
66
|
# File 'lib/resources/bond.rb', line 64
def to_s
"Bond #{@bond}"
end
|