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.
18
19
20
21
22
23
24
25
|
# 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
|
Instance Method Details
#content ⇒ Object
45
46
47
48
|
# File 'lib/inspec/resources/bond.rb', line 45
def content
read_content if @loaded == false
@content
end
|
#exist? ⇒ Boolean
50
51
52
|
# File 'lib/inspec/resources/bond.rb', line 50
def exist?
@file.exist?
end
|
#has_interface?(interface) ⇒ Boolean
54
55
56
|
# File 'lib/inspec/resources/bond.rb', line 54
def has_interface?(interface)
params["Slave Interface"].include?(interface)
end
|
#interfaces ⇒ Object
58
59
60
|
# File 'lib/inspec/resources/bond.rb', line 58
def interfaces
params["Slave Interface"]
end
|
#mode ⇒ Object
62
63
64
|
# File 'lib/inspec/resources/bond.rb', line 62
def mode
params["Bonding Mode"].first
end
|
#params ⇒ Object
ensures the content is loaded before we return the params
40
41
42
43
|
# File 'lib/inspec/resources/bond.rb', line 40
def params
read_content if @loaded == false
@params
end
|
#read_content ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
|
# 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 ⇒ Object
66
67
68
|
# File 'lib/inspec/resources/bond.rb', line 66
def to_s
"Bond #{@bond}"
end
|