ohai 8.6.0.alpha.1 → 8.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Rakefile +1 -12
- data/lib/ohai/config.rb +3 -0
- data/lib/ohai/dsl/plugin/versionvii.rb +41 -0
- data/lib/ohai/exception.rb +1 -0
- data/lib/ohai/mixin/softlayer_metadata.rb +64 -0
- data/lib/ohai/plugin_config.rb +46 -0
- data/lib/ohai/plugins/aix/cpu.rb +23 -18
- data/lib/ohai/plugins/aix/memory.rb +9 -2
- data/lib/ohai/plugins/aix/network.rb +1 -1
- data/lib/ohai/plugins/cloud.rb +34 -3
- data/lib/ohai/plugins/ec2.rb +6 -0
- data/lib/ohai/plugins/linux/network.rb +245 -190
- data/lib/ohai/plugins/linux/platform.rb +50 -15
- data/lib/ohai/plugins/linux/virtualization.rb +3 -1
- data/lib/ohai/plugins/softlayer.rb +47 -0
- data/lib/ohai/plugins/solaris2/cpu.rb +46 -17
- data/lib/ohai/plugins/solaris2/memory.rb +9 -1
- data/lib/ohai/plugins/vmware.rb +73 -0
- data/lib/ohai/plugins/windows/memory.rb +38 -0
- data/lib/ohai/version.rb +1 -1
- data/spec/unit/config_spec.rb +28 -0
- data/spec/unit/dsl/plugin_spec.rb +73 -0
- data/spec/unit/mixin/softlayer_metadata_spec.rb +71 -0
- data/spec/unit/plugin_config_spec.rb +118 -0
- data/spec/unit/plugins/aix/cpu_spec.rb +31 -12
- data/spec/unit/plugins/aix/memory_spec.rb +47 -0
- data/spec/unit/plugins/aix/network_spec.rb +1 -1
- data/spec/unit/plugins/ec2_spec.rb +35 -13
- data/spec/unit/plugins/linux/memory_spec.rb +204 -0
- data/spec/unit/plugins/linux/network_spec.rb +40 -0
- data/spec/unit/plugins/linux/platform_spec.rb +62 -6
- data/spec/unit/plugins/linux/virtualization_spec.rb +21 -0
- data/spec/unit/plugins/softlayer_spec.rb +60 -0
- data/spec/unit/plugins/solaris2/cpu_spec.rb +2887 -42
- data/spec/unit/plugins/solaris2/memory_spec.rb +15 -2
- data/spec/unit/plugins/vmware_spec.rb +62 -0
- data/spec/unit/plugins/windows/memory_spec.rb +52 -0
- metadata +18 -5
@@ -28,18 +28,48 @@ Ohai.plugin(:Platform) do
|
|
28
28
|
contents[/Rawhide/i] ? contents[/((\d+) \(Rawhide\))/i, 1].downcase : contents[/release ([\d\.]+)/, 1]
|
29
29
|
end
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
31
|
+
#
|
32
|
+
# Reads an os-release-info file and parse it into a hash
|
33
|
+
#
|
34
|
+
# @param file [String] the filename to read (e.g. '/etc/os-release')
|
35
|
+
#
|
36
|
+
# @returns [Hash] the file parsed into a Hash or nil
|
37
|
+
#
|
38
|
+
def read_os_release_info(file)
|
39
|
+
return nil unless File.exist?(file)
|
40
|
+
File.read(file).split.inject({}) do |map, line|
|
41
|
+
key, value = line.split('=')
|
42
|
+
map[key] = value.gsub(/\A"|"\Z/, '') if value
|
36
43
|
map
|
37
44
|
end
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
45
|
+
end
|
46
|
+
|
47
|
+
#
|
48
|
+
# Cached /etc/os-release info Hash. Also has logic for Cisco Nexus
|
49
|
+
# switches that pulls the chained CISCO_RELEASE_INFO file into the Hash (other
|
50
|
+
# distros can also reuse this method safely).
|
51
|
+
#
|
52
|
+
# @returns [Hash] the canonical, cached Hash of /etc/os-release info or nil
|
53
|
+
#
|
54
|
+
def os_release_info
|
55
|
+
@os_release_info ||=
|
56
|
+
begin
|
57
|
+
os_release_info = read_os_release_info('/etc/os-release')
|
58
|
+
cisco_release_info = os_release_info['CISCO_RELEASE_INFO'] if os_release_info
|
59
|
+
if cisco_release_info && File.exist?(cisco_release_info)
|
60
|
+
os_release_info.merge!(read_os_release_info(cisco_release_info))
|
61
|
+
end
|
62
|
+
os_release_info
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
#
|
67
|
+
# If /etc/os-release indicates we are Cisco based
|
68
|
+
#
|
69
|
+
# @returns [Boolean] if we are Cisco according to /etc/os-release
|
70
|
+
#
|
71
|
+
def os_release_file_is_cisco?
|
72
|
+
File.exist?('/etc/os-release') && os_release_info['CISCO_RELEASE_INFO']
|
43
73
|
end
|
44
74
|
|
45
75
|
collect_data(:linux) do
|
@@ -74,10 +104,9 @@ Ohai.plugin(:Platform) do
|
|
74
104
|
platform get_redhatish_platform(contents)
|
75
105
|
platform_version contents.match(/(\d\.\d\.\d)/)[0]
|
76
106
|
elsif File.exist?("/etc/redhat-release")
|
77
|
-
if
|
78
|
-
platform
|
79
|
-
|
80
|
-
platform_version os_release_info['VERSION'] || ""
|
107
|
+
if os_release_file_is_cisco? # Cisco guestshell
|
108
|
+
platform 'nexus_centos'
|
109
|
+
platform_version os_release_info['VERSION']
|
81
110
|
else
|
82
111
|
contents = File.read("/etc/redhat-release").chomp
|
83
112
|
platform get_redhatish_platform(contents)
|
@@ -113,6 +142,12 @@ Ohai.plugin(:Platform) do
|
|
113
142
|
# no way to determine platform_version in a rolling release distribution
|
114
143
|
# kernel release will be used - ex. 3.13
|
115
144
|
platform_version `uname -r`.strip
|
145
|
+
elsif os_release_file_is_cisco?
|
146
|
+
raise "unknown Cisco /etc/os-release ID field" unless os_release_info['ID'].include?('nexus')
|
147
|
+
raise "unknown Cisco /etc/os-release ID-LIKE field" unless os_release_info['ID_LIKE'].include?('wrlinux')
|
148
|
+
platform 'nexus'
|
149
|
+
platform_family 'wrlinux'
|
150
|
+
platform_version os_release_info['VERSION']
|
116
151
|
elsif lsb[:id] =~ /RedHat/i
|
117
152
|
platform "redhat"
|
118
153
|
platform_version lsb[:release]
|
@@ -135,7 +170,7 @@ Ohai.plugin(:Platform) do
|
|
135
170
|
platform_family "debian"
|
136
171
|
when /fedora/, /pidora/
|
137
172
|
platform_family "fedora"
|
138
|
-
when /oracle/, /centos/, /redhat/, /scientific/, /enterpriseenterprise/, /amazon/, /xenserver/, /cloudlinux/, /ibm_powerkvm/, /parallels/ # Note that 'enterpriseenterprise' is oracle's LSB "distributor ID"
|
173
|
+
when /oracle/, /centos/, /redhat/, /scientific/, /enterpriseenterprise/, /amazon/, /xenserver/, /cloudlinux/, /ibm_powerkvm/, /parallels/, /nexus_centos/ # Note that 'enterpriseenterprise' is oracle's LSB "distributor ID"
|
139
174
|
platform_family "rhel"
|
140
175
|
when /suse/
|
141
176
|
platform_family "suse"
|
@@ -190,7 +190,9 @@ Ohai.plugin(:Virtualization) do
|
|
190
190
|
# Full notes, https://tickets.opscode.com/browse/OHAI-551
|
191
191
|
# Kernel docs, https://www.kernel.org/doc/Documentation/cgroups
|
192
192
|
if File.exists?("/proc/self/cgroup")
|
193
|
-
|
193
|
+
cgroup_content = File.read("/proc/self/cgroup")
|
194
|
+
if cgroup_content =~ %r{^\d+:[^:]+:/(lxc|docker)/.+$} ||
|
195
|
+
cgroup_content =~ %r{^\d+:[^:]+:/[^/]+/(lxc|docker)-.+$}
|
194
196
|
virtualization[:system] = $1
|
195
197
|
virtualization[:role] = "guest"
|
196
198
|
virtualization[:systems][$1.to_sym] = "guest"
|
@@ -0,0 +1,47 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Alexey Karpik <alexey.karpik@rightscale.com>
|
3
|
+
# Author:: Peter Schroeter <peter.schroeter@rightscale.com>
|
4
|
+
# Author:: Stas Turlo <stanislav.turlo@rightscale.com>
|
5
|
+
# Copyright:: Copyright (c) 2010-2014 RightScale Inc
|
6
|
+
# License:: Apache License, Version 2.0
|
7
|
+
#
|
8
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
9
|
+
# you may not use this file except in compliance with the License.
|
10
|
+
# You may obtain a copy of the License at
|
11
|
+
#
|
12
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
13
|
+
#
|
14
|
+
# Unless required by applicable law or agreed to in writing, software
|
15
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
16
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
17
|
+
# implied.
|
18
|
+
# See the License for the specific language governing permissions and
|
19
|
+
# limitations under the License.
|
20
|
+
|
21
|
+
require 'ohai/mixin/softlayer_metadata'
|
22
|
+
|
23
|
+
Ohai.plugin(:Softlayer) do
|
24
|
+
include ::Ohai::Mixin::SoftlayerMetadata
|
25
|
+
|
26
|
+
provides 'softlayer'
|
27
|
+
|
28
|
+
# Identifies the softlayer cloud
|
29
|
+
#
|
30
|
+
# === Return
|
31
|
+
# true:: If the softlayer cloud can be identified
|
32
|
+
# false:: Otherwise
|
33
|
+
def looks_like_softlayer?
|
34
|
+
hint?('softlayer')
|
35
|
+
end
|
36
|
+
|
37
|
+
collect_data do
|
38
|
+
# Adds softlayer Mash
|
39
|
+
if looks_like_softlayer?
|
40
|
+
::Ohai::Log.debug("looks_like_softlayer? == true")
|
41
|
+
metadata = fetch_metadata
|
42
|
+
softlayer Mash.new
|
43
|
+
metadata.each { |k,v| softlayer[k] = v } if metadata
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
@@ -16,26 +16,55 @@
|
|
16
16
|
|
17
17
|
Ohai.plugin(:CPU) do
|
18
18
|
provides "cpu"
|
19
|
-
|
19
|
+
|
20
20
|
collect_data(:solaris2) do
|
21
21
|
cpu Mash.new
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
cpu_info = cpu_info.tr("()","").split
|
22
|
+
# This does assume that /usr/bin/kstat is in the path
|
23
|
+
processor_info = shell_out("kstat -p cpu_info").stdout.lines
|
24
|
+
cpu["total"] = 0
|
25
|
+
cpu["sockets"] = 0
|
26
|
+
cpu["cores"] = 0
|
27
|
+
cpu["corethreads"] = 0
|
28
|
+
cpu["cpustates"] = Mash.new
|
30
29
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
cpu[
|
37
|
-
|
38
|
-
|
30
|
+
currentcpu = 0
|
31
|
+
cpucores = Array.new
|
32
|
+
cpusockets = Array.new
|
33
|
+
processor_info.each_with_index do |processor, i|
|
34
|
+
desc,instance,record,keyvalue = processor.split(":")
|
35
|
+
cpu[instance] ||= Mash.new
|
36
|
+
if (currentcpu != instance)
|
37
|
+
cpu["total"] += 1
|
38
|
+
currentcpu = instance
|
39
|
+
end
|
40
|
+
kv = keyvalue.split(/\s+/)
|
41
|
+
key = kv.shift
|
42
|
+
value = kv.join(" ").chomp
|
43
|
+
case key
|
44
|
+
when /chip_id/
|
45
|
+
cpu[instance]["socket"] = value
|
46
|
+
cpusockets.push(value) if cpusockets.index(value).nil?
|
47
|
+
when /cpu_type/
|
48
|
+
cpu[instance]["arch"] = value
|
49
|
+
when /clock_MHz/
|
50
|
+
cpu[instance]["mhz"] = value
|
51
|
+
when /brand/
|
52
|
+
cpu[instance]["model_name"] = value.sub(/\s+/," ")
|
53
|
+
when /^state$/
|
54
|
+
cpu[instance]["state"] = value
|
55
|
+
cpu["cpustates"][value] ||= 0
|
56
|
+
cpu["cpustates"][value] += 1
|
57
|
+
when /core_id/
|
58
|
+
cpu[instance]["core_id"] = value
|
59
|
+
# Detect hyperthreading/multithreading
|
60
|
+
cpucores.push(value) if cpucores.index(value).nil?
|
61
|
+
when /family|fpu_type|model|stepping|vendor_id/
|
62
|
+
cpu[instance][key] = value
|
63
|
+
end
|
39
64
|
end
|
65
|
+
cpu["cores"] = cpucores.size
|
66
|
+
cpu["corethreads"] = (cpu["total"] / cpucores.size)
|
67
|
+
cpu["sockets"] = cpusockets.size
|
68
|
+
cpu["real"] = cpusockets.size
|
40
69
|
end
|
41
70
|
end
|
@@ -19,6 +19,14 @@ Ohai.plugin(:Memory) do
|
|
19
19
|
|
20
20
|
collect_data(:solaris2) do
|
21
21
|
memory Mash.new
|
22
|
-
memory[:
|
22
|
+
memory[:swap] = Mash.new
|
23
|
+
meminfo = shell_out("prtconf | grep Memory").stdout
|
24
|
+
memory[:total] = "#{meminfo.split[2].to_i * 1024}kB"
|
25
|
+
|
26
|
+
tokens = shell_out("swap -s").stdout.strip.split
|
27
|
+
used_swap = tokens[8][0..-1].to_i #strip k from end
|
28
|
+
free_swap = tokens[10][0..-1].to_i #strip k from end
|
29
|
+
memory[:swap][:total] = "#{used_swap + free_swap}kB"
|
30
|
+
memory[:swap][:free] = "#{free_swap}kB"
|
23
31
|
end
|
24
32
|
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
#
|
2
|
+
# Author:: "Dan Robinson" <drobinson@getchef.com>
|
3
|
+
# Author:: "Christopher M. Luciano" <cmlucian@us.ibm.com>
|
4
|
+
# Copyright:: Copyright (c) 2014 Chef Software, Inc.
|
5
|
+
# Copyright (C) 2015 IBM Corp.
|
6
|
+
# License:: Apache License, Version 2.0
|
7
|
+
#
|
8
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
9
|
+
# you may not use this file except in compliance with the License.
|
10
|
+
# You may obtain a copy of the License at
|
11
|
+
#
|
12
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
13
|
+
#
|
14
|
+
# Unless required by applicable law or agreed to in writing, software
|
15
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
16
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
17
|
+
# See the License for the specific language governing permissions and
|
18
|
+
# limitations under the License.
|
19
|
+
#
|
20
|
+
|
21
|
+
#
|
22
|
+
# Provides a set of attributes for a VMware ESX virtual machine with results
|
23
|
+
# obtained from vmware-toolbox-cmd. VMware Tools must be installed
|
24
|
+
# on the virtual machine.
|
25
|
+
#
|
26
|
+
# Modify the path to vmware-toolbox-cmd in the call to get_vm_attributes for
|
27
|
+
# your particular operating system and configuration
|
28
|
+
#
|
29
|
+
# Example:
|
30
|
+
#
|
31
|
+
# get_vm_attributes("/usr/bin/vmware-toolbox-cmd")
|
32
|
+
#
|
33
|
+
|
34
|
+
Ohai.plugin(:VMware) do
|
35
|
+
provides "vmware"
|
36
|
+
|
37
|
+
def from_cmd(cmd)
|
38
|
+
so = shell_out(cmd)
|
39
|
+
so.stdout.split($/)[0]
|
40
|
+
end
|
41
|
+
|
42
|
+
def get_vm_attributes(vmtools_path)
|
43
|
+
if !File.exist?(vmtools_path)
|
44
|
+
Ohai::Log.debug("#{vmtools_path} not found")
|
45
|
+
else
|
46
|
+
vmware Mash.new
|
47
|
+
begin
|
48
|
+
# vmware-toolbox-cmd stat <param> commands
|
49
|
+
# Iterate through each parameter supported by the "vwware-toolbox-cmd stat" command, assign value
|
50
|
+
# to attribute "vmware[:<parameter>]"
|
51
|
+
[ "hosttime", "speed", "sessionid", "balloon", "swap", "memlimit", "memres", "cpures", "cpulimit" ].each do |param|
|
52
|
+
vmware[param] = from_cmd("#{vmtools_path} stat #{param}")
|
53
|
+
if vmware[param] =~ /UpdateInfo failed/
|
54
|
+
vmware[param] = nil
|
55
|
+
end
|
56
|
+
end
|
57
|
+
# vmware-toolbox-cmd <param> status commands
|
58
|
+
# Iterate through each parameter supported by the "vwware-toolbox-cmd status" command, assign value
|
59
|
+
# to attribute "vmware[:<parameter>]"
|
60
|
+
[ "upgrade", "timesync" ].each do |param|
|
61
|
+
vmware[param] = from_cmd("#{vmtools_path} #{param} status")
|
62
|
+
end
|
63
|
+
rescue
|
64
|
+
Ohai::Log.debug("Error while collecting VMware guest attributes")
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
collect_data(:linux) do
|
70
|
+
get_vm_attributes("/usr/bin/vmware-toolbox-cmd")
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
#
|
2
|
+
# License:: Apache License, Version 2.0
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
#
|
16
|
+
Ohai.plugin(:Memory) do
|
17
|
+
provides "memory"
|
18
|
+
|
19
|
+
collect_data(:windows) do
|
20
|
+
require "wmi-lite/wmi"
|
21
|
+
|
22
|
+
memory Mash.new
|
23
|
+
memory[:swap] = Mash.new
|
24
|
+
|
25
|
+
wmi = WmiLite::Wmi.new
|
26
|
+
|
27
|
+
os = wmi.first_of("Win32_OperatingSystem")
|
28
|
+
|
29
|
+
# MemTotal
|
30
|
+
memory[:total] = os["TotalVisibleMemorySize"] + "kB"
|
31
|
+
# MemFree
|
32
|
+
memory[:free] = os["FreePhysicalMemory"] + "kB"
|
33
|
+
# SwapTotal
|
34
|
+
memory[:swap][:total] = os["SizeStoredInPagingFiles"] + "kB"
|
35
|
+
# SwapFree
|
36
|
+
memory[:swap][:free] = os["FreeSpaceInPagingFiles"] + "kB"
|
37
|
+
end
|
38
|
+
end
|
data/lib/ohai/version.rb
CHANGED
data/spec/unit/config_spec.rb
CHANGED
@@ -90,6 +90,34 @@ RSpec.describe Ohai::Config do
|
|
90
90
|
end
|
91
91
|
end
|
92
92
|
|
93
|
+
describe "config_context :ohai" do
|
94
|
+
describe "option :plugin" do
|
95
|
+
it "gets configured with a value" do
|
96
|
+
Ohai::Config.ohai[:plugin][:foo] = true
|
97
|
+
expect(Ohai::Config.ohai[:plugin]).to have_key(:foo)
|
98
|
+
expect(Ohai::Config.ohai[:plugin][:foo]).to be true
|
99
|
+
end
|
100
|
+
|
101
|
+
it "gets configured with a Hash" do
|
102
|
+
value = { :bar => true, :baz => true }
|
103
|
+
Ohai::Config.ohai[:plugin][:foo] = value
|
104
|
+
expect(Ohai::Config.ohai[:plugin]).to have_key(:foo)
|
105
|
+
expect(Ohai::Config.ohai[:plugin][:foo]).to eq(value)
|
106
|
+
end
|
107
|
+
|
108
|
+
it "raises an error if the plugin name is not a symbol" do
|
109
|
+
expect { Ohai::Config.ohai[:plugin]["foo"] = false }.
|
110
|
+
to raise_error(Ohai::Exceptions::PluginConfigError, /Expected Symbol/)
|
111
|
+
end
|
112
|
+
|
113
|
+
it "raises an error if the value Hash has non-Symbol key" do
|
114
|
+
value = { :bar => true, "baz" => true }
|
115
|
+
expect { Ohai::Config.ohai[:plugin][:foo] = value }.
|
116
|
+
to raise_error(Ohai::Exceptions::PluginConfigError, /Expected Symbol/)
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
93
121
|
describe "::merge_deprecated_config" do
|
94
122
|
before(:each) do
|
95
123
|
allow(Ohai::Log).to receive(:warn)
|
@@ -293,6 +293,79 @@ describe Ohai::DSL::Plugin::VersionVII do
|
|
293
293
|
end
|
294
294
|
end
|
295
295
|
|
296
|
+
describe "#configuration" do
|
297
|
+
let(:plugin) do
|
298
|
+
klass = Ohai.plugin(camel_name) { }
|
299
|
+
klass.new({})
|
300
|
+
end
|
301
|
+
|
302
|
+
shared_examples_for "plugin config lookup" do
|
303
|
+
it "returns the configuration option value" do
|
304
|
+
Ohai.config[:plugin][snake_name][:foo] = true
|
305
|
+
expect(plugin.configuration(:foo)).to eq(true)
|
306
|
+
end
|
307
|
+
end
|
308
|
+
|
309
|
+
describe "a plugin named Abc" do
|
310
|
+
let(:camel_name) { :Abc }
|
311
|
+
let(:snake_name) { :abc }
|
312
|
+
|
313
|
+
it "returns nil when the plugin is not configured" do
|
314
|
+
expect(plugin.configuration(:foo)).to eq(nil)
|
315
|
+
end
|
316
|
+
|
317
|
+
it "does not auto-vivify an un-configured plugin" do
|
318
|
+
plugin.configuration(:foo)
|
319
|
+
expect(Ohai.config[:plugin]).to_not have_key(:test)
|
320
|
+
end
|
321
|
+
|
322
|
+
it "returns nil when the option is not configured" do
|
323
|
+
Ohai.config[:plugin][snake_name][:foo] = true
|
324
|
+
expect(plugin.configuration(:bar)).to eq(nil)
|
325
|
+
end
|
326
|
+
|
327
|
+
it "returns nil when the suboption is not configured" do
|
328
|
+
Ohai.config[:plugin][snake_name][:foo] = { }
|
329
|
+
expect(plugin.configuration(:foo, :bar)).to eq(nil)
|
330
|
+
end
|
331
|
+
|
332
|
+
include_examples "plugin config lookup"
|
333
|
+
|
334
|
+
it "returns the configuration sub-option value" do
|
335
|
+
Ohai.config[:plugin][snake_name][:foo] = { :bar => true }
|
336
|
+
expect(plugin.configuration(:foo, :bar)).to eq(true)
|
337
|
+
end
|
338
|
+
end
|
339
|
+
|
340
|
+
describe "a plugin named ABC" do
|
341
|
+
let(:camel_name) { :ABC }
|
342
|
+
let(:snake_name) { :abc }
|
343
|
+
|
344
|
+
include_examples "plugin config lookup"
|
345
|
+
end
|
346
|
+
|
347
|
+
describe "a plugin named Abc2" do
|
348
|
+
let(:camel_name) { :Abc2 }
|
349
|
+
let(:snake_name) { :abc_2 }
|
350
|
+
|
351
|
+
include_examples "plugin config lookup"
|
352
|
+
end
|
353
|
+
|
354
|
+
describe "a plugin named AbcAbc" do
|
355
|
+
let(:camel_name) { :AbcXyz }
|
356
|
+
let(:snake_name) { :abc_xyz }
|
357
|
+
|
358
|
+
include_examples "plugin config lookup"
|
359
|
+
end
|
360
|
+
|
361
|
+
describe "a plugin named ABCLmnoXyz" do
|
362
|
+
let(:camel_name) { :ABCLmnoXyz }
|
363
|
+
let(:snake_name) { :abc_lmno_xyz }
|
364
|
+
|
365
|
+
include_examples "plugin config lookup"
|
366
|
+
end
|
367
|
+
end
|
368
|
+
|
296
369
|
it_behaves_like "Ohai::DSL::Plugin" do
|
297
370
|
let(:ohai) { Ohai::System.new }
|
298
371
|
let(:plugin) { Ohai::DSL::Plugin::VersionVII.new(ohai.data) }
|