ohai 8.19.2 → 8.20.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/lib/ohai/common/dmi.rb +12 -12
- data/lib/ohai/config.rb +30 -28
- data/lib/ohai/loader.rb +1 -1
- data/lib/ohai/mixin/command.rb +2 -2
- data/lib/ohai/plugins/dmi.rb +1 -1
- data/lib/ohai/plugins/ip_scopes.rb +3 -3
- data/lib/ohai/plugins/kernel.rb +4 -0
- data/lib/ohai/plugins/linux/hostnamectl.rb +34 -0
- data/lib/ohai/plugins/linux/machineid.rb +35 -0
- data/lib/ohai/plugins/linux/network.rb +1 -1
- data/lib/ohai/plugins/linux/virtualization.rb +10 -0
- data/lib/ohai/plugins/rackspace.rb +4 -4
- data/lib/ohai/plugins/solaris2/dmi.rb +1 -1
- data/lib/ohai/plugins/solaris2/filesystem.rb +6 -6
- data/lib/ohai/plugins/solaris2/network.rb +8 -8
- data/lib/ohai/plugins/windows/cpu.rb +5 -3
- data/lib/ohai/plugins/windows/network.rb +59 -37
- data/lib/ohai/runner.rb +2 -2
- data/lib/ohai/system.rb +2 -2
- data/lib/ohai/version.rb +1 -1
- data/spec/functional/application_spec.rb +1 -1
- data/spec/support/integration_helper.rb +3 -3
- data/spec/unit/application_spec.rb +1 -1
- data/spec/unit/dsl/plugin_spec.rb +22 -22
- data/spec/unit/mixin/ec2_metadata_spec.rb +2 -2
- data/spec/unit/mixin/softlayer_metadata_spec.rb +2 -2
- data/spec/unit/plugin_config_spec.rb +6 -6
- data/spec/unit/plugins/aix/cpu_spec.rb +6 -6
- data/spec/unit/plugins/aix/filesystem_spec.rb +8 -8
- data/spec/unit/plugins/aix/virtualization_spec.rb +2 -2
- data/spec/unit/plugins/azure_spec.rb +2 -2
- data/spec/unit/plugins/darwin/hardware_spec.rb +3 -3
- data/spec/unit/plugins/darwin/hardware_system_profiler_output.rb +3 -3
- data/spec/unit/plugins/digital_ocean_spec.rb +2 -2
- data/spec/unit/plugins/init_package_spec.rb +2 -2
- data/spec/unit/plugins/ip_scopes_spec.rb +3 -2
- data/spec/unit/plugins/linux/hostnamectl_spec.rb +59 -0
- data/spec/unit/plugins/linux/machineid_spec.rb +46 -0
- data/spec/unit/plugins/linux/network_spec.rb +113 -77
- data/spec/unit/plugins/linux/platform_spec.rb +2 -2
- data/spec/unit/plugins/linux/virtualization_spec.rb +20 -0
- data/spec/unit/plugins/ruby_spec.rb +3 -2
- data/spec/unit/plugins/solaris2/kernel_spec.rb +23 -0
- data/spec/unit/runner_spec.rb +74 -74
- data/spec/unit/util/ip_helper_spec.rb +2 -2
- metadata +7 -3
@@ -699,7 +699,7 @@ CISCO_RELEASE
|
|
699
699
|
end
|
700
700
|
end
|
701
701
|
|
702
|
-
describe
|
702
|
+
describe "#read_os_release_info" do
|
703
703
|
let(:file_contents) { "COW=MOO\nDOG=\"BARK\"" }
|
704
704
|
it "returns nil if the file does not exist" do
|
705
705
|
allow(File).to receive(:exist?).with("/etc/test-release").and_return(false)
|
@@ -716,7 +716,7 @@ CISCO_RELEASE
|
|
716
716
|
end
|
717
717
|
end
|
718
718
|
|
719
|
-
describe
|
719
|
+
describe "#os_release_info" do
|
720
720
|
context "when CISCO_RELEASE_INFO is not populated" do
|
721
721
|
let(:release_info) { { "ID" => "os_id" } }
|
722
722
|
|
@@ -38,6 +38,8 @@ describe Ohai::System, "Linux virtualization platform" do
|
|
38
38
|
allow(File).to receive(:exist?).with("/.dockerinit").and_return(false)
|
39
39
|
allow(File).to receive(:exist?).with("/proc/bus/pci/devices").and_return(false)
|
40
40
|
allow(File).to receive(:exist?).with("/sys/devices/virtual/misc/kvm").and_return(false)
|
41
|
+
allow(File).to receive(:exist?).with("/dev/lxd/sock").and_return(false)
|
42
|
+
allow(File).to receive(:exist?).with("/var/lib/lxd/devlxd").and_return(false)
|
41
43
|
|
42
44
|
# default the which wrappers to nil
|
43
45
|
allow(plugin).to receive(:lxc_version_exists?).and_return(false)
|
@@ -464,6 +466,24 @@ OUTPUT
|
|
464
466
|
end
|
465
467
|
end
|
466
468
|
|
469
|
+
describe "when we are checking for lxd" do
|
470
|
+
it "sets lxc guest if /dev/lxd/sock exists" do
|
471
|
+
expect(File).to receive(:exist?).with("/dev/lxd/sock").and_return(true)
|
472
|
+
|
473
|
+
plugin.run
|
474
|
+
expect(plugin[:virtualization][:system]).to eq("lxd")
|
475
|
+
expect(plugin[:virtualization][:role]).to eq("guest")
|
476
|
+
end
|
477
|
+
|
478
|
+
it "setx lxd host if /var/lib/lxd/devlxd exists" do
|
479
|
+
expect(File).to receive(:exist?).with("/var/lib/lxd/devlxd").and_return(true)
|
480
|
+
|
481
|
+
plugin.run
|
482
|
+
expect(plugin[:virtualization][:system]).to eq("lxd")
|
483
|
+
expect(plugin[:virtualization][:role]).to eq("host")
|
484
|
+
end
|
485
|
+
end
|
486
|
+
|
467
487
|
describe "when we are checking for lxc" do
|
468
488
|
it "sets lxc guest if /proc/self/cgroup exist and there are /lxc/<hexadecimal> mounts" do
|
469
489
|
self_cgroup = <<-CGROUP
|
@@ -47,8 +47,9 @@ describe Ohai::System, "plugin ruby" do
|
|
47
47
|
:host_os => ::RbConfig::CONFIG["host_os"],
|
48
48
|
:host_vendor => ::RbConfig::CONFIG["host_vendor"],
|
49
49
|
:gems_dir => `#{ruby_bin} #{::RbConfig::CONFIG["bindir"]}/gem env gemdir`.chomp,
|
50
|
-
:gem_bin => [ ::Gem.default_exec_format % "gem", "gem" ].map
|
51
|
-
|
50
|
+
:gem_bin => [ ::Gem.default_exec_format % "gem", "gem" ].map do |bin|
|
51
|
+
"#{::RbConfig::CONFIG['bindir']}/#{bin}"
|
52
|
+
end.find { |bin| ::File.exists? bin },
|
52
53
|
:ruby_bin => ruby_bin,
|
53
54
|
}.each do |attribute, value|
|
54
55
|
it "should have #{attribute} set to #{value.inspect}" do
|
@@ -139,6 +139,29 @@ describe Ohai::System, "Solaris2.X kernel plugin" do
|
|
139
139
|
allow(@plugin).to receive(:init_kernel).and_return({})
|
140
140
|
allow(@plugin).to receive(:shell_out).with("uname -s").and_return(mock_shell_out(0, "SunOS\n", ""))
|
141
141
|
allow(@plugin).to receive(:shell_out).with("modinfo").and_return(mock_shell_out(0, MODINFO, ""))
|
142
|
+
@release = StringIO.new(" Oracle Solaris 10 1/13 s10s_u11wos_24a SPARC\n Assembled 17 January 2013")
|
143
|
+
allow(File).to receive(:open).with("/etc/release").and_yield(@release)
|
144
|
+
end
|
145
|
+
|
146
|
+
it "should give the Solaris update version information" do
|
147
|
+
@release = StringIO.new(" Solaris 10 10/08 s10s_u6wos_07b SPARC\n Use is subject to license terms.\n Assembled 27 October 2008")
|
148
|
+
allow(File).to receive(:open).with("/etc/release").and_yield(@release)
|
149
|
+
@plugin.run
|
150
|
+
expect(@plugin[:kernel][:update]).to eq("10 10/08 s10s_u6wos_07")
|
151
|
+
end
|
152
|
+
|
153
|
+
it "should give the Oracle Solaris update version information" do
|
154
|
+
@release = StringIO.new(" Oracle Solaris 10 1/13 s10s_u11wos_24a SPARC\n Assembled 17 January 2013")
|
155
|
+
allow(File).to receive(:open).with("/etc/release").and_yield(@release)
|
156
|
+
@plugin.run
|
157
|
+
expect(@plugin[:kernel][:update]).to eq("10 1/13 s10s_u11wos_24")
|
158
|
+
end
|
159
|
+
|
160
|
+
it "should give the Solaris 11 update version information" do
|
161
|
+
@release = StringIO.new(" Oracle Solaris 11.3 SPARC\n Assembled 25 July 2016")
|
162
|
+
allow(File).to receive(:open).with("/etc/release").and_yield(@release)
|
163
|
+
@plugin.run
|
164
|
+
expect(@plugin[:kernel][:update]).to eq("11.3")
|
142
165
|
end
|
143
166
|
|
144
167
|
it_should_check_from_deep_mash("solaris2::kernel", "kernel", "os", "uname -s", [0, "SunOS\n", ""])
|
data/spec/unit/runner_spec.rb
CHANGED
@@ -101,15 +101,15 @@ describe Ohai::Runner, "run_plugin" do
|
|
101
101
|
end
|
102
102
|
|
103
103
|
describe "when running a plugin with no dependencies, Ohai::Runner" do
|
104
|
-
let(:plugin)
|
105
|
-
klass = Ohai.plugin(:Test)
|
104
|
+
let(:plugin) do
|
105
|
+
klass = Ohai.plugin(:Test) do
|
106
106
|
provides("thing")
|
107
|
-
collect_data
|
107
|
+
collect_data do
|
108
108
|
thing(Mash.new)
|
109
|
-
|
110
|
-
|
109
|
+
end
|
110
|
+
end
|
111
111
|
klass.new(@ohai.data)
|
112
|
-
|
112
|
+
end
|
113
113
|
|
114
114
|
it "should run the plugin" do
|
115
115
|
@runner.run_plugin(plugin)
|
@@ -126,13 +126,13 @@ describe Ohai::Runner, "run_plugin" do
|
|
126
126
|
describe "when running a plugin with one dependency" do
|
127
127
|
describe "when the dependency does not exist" do
|
128
128
|
before(:each) do
|
129
|
-
klass = Ohai.plugin(:Test)
|
129
|
+
klass = Ohai.plugin(:Test) do
|
130
130
|
provides("thing")
|
131
131
|
depends("other_thing")
|
132
|
-
collect_data
|
132
|
+
collect_data do
|
133
133
|
thing(other_thing)
|
134
|
-
|
135
|
-
|
134
|
+
end
|
135
|
+
end
|
136
136
|
@plugin = klass.new(@ohai.data)
|
137
137
|
end
|
138
138
|
|
@@ -148,19 +148,19 @@ describe Ohai::Runner, "run_plugin" do
|
|
148
148
|
|
149
149
|
describe "when the dependency has a single provider" do
|
150
150
|
before(:each) do
|
151
|
-
klass1 = Ohai.plugin(:Thing)
|
151
|
+
klass1 = Ohai.plugin(:Thing) do
|
152
152
|
provides("thing")
|
153
|
-
collect_data
|
153
|
+
collect_data do
|
154
154
|
thing("thang")
|
155
|
-
|
156
|
-
|
157
|
-
klass2 = Ohai.plugin(:Other)
|
155
|
+
end
|
156
|
+
end
|
157
|
+
klass2 = Ohai.plugin(:Other) do
|
158
158
|
provides("other")
|
159
159
|
depends("thing")
|
160
|
-
collect_data
|
160
|
+
collect_data do
|
161
161
|
other(thing)
|
162
|
-
|
163
|
-
|
162
|
+
end
|
163
|
+
end
|
164
164
|
|
165
165
|
@plugins = []
|
166
166
|
[klass1, klass2].each do |klass|
|
@@ -181,19 +181,19 @@ describe Ohai::Runner, "run_plugin" do
|
|
181
181
|
|
182
182
|
describe "when the dependency has multiple providers" do
|
183
183
|
before(:each) do
|
184
|
-
klass1 = Ohai.plugin(:Thing)
|
184
|
+
klass1 = Ohai.plugin(:Thing) do
|
185
185
|
provides("thing")
|
186
|
-
collect_data
|
186
|
+
collect_data do
|
187
187
|
thing(Mash.new)
|
188
|
-
|
189
|
-
|
190
|
-
klass2 = Ohai.plugin(:Other)
|
188
|
+
end
|
189
|
+
end
|
190
|
+
klass2 = Ohai.plugin(:Other) do
|
191
191
|
provides("other")
|
192
192
|
depends("thing")
|
193
|
-
collect_data
|
193
|
+
collect_data do
|
194
194
|
other(thing)
|
195
|
-
|
196
|
-
|
195
|
+
end
|
196
|
+
end
|
197
197
|
|
198
198
|
@plugins = []
|
199
199
|
[klass1, klass1, klass2].each do |klass|
|
@@ -219,25 +219,25 @@ describe Ohai::Runner, "run_plugin" do
|
|
219
219
|
@ohai = Ohai::System.new
|
220
220
|
@runner = Ohai::Runner.new(@ohai, true)
|
221
221
|
|
222
|
-
klass1 = Ohai.plugin(:One)
|
222
|
+
klass1 = Ohai.plugin(:One) do
|
223
223
|
provides("one")
|
224
|
-
collect_data
|
224
|
+
collect_data do
|
225
225
|
one(1)
|
226
|
-
|
227
|
-
|
228
|
-
klass2 = Ohai.plugin(:Two)
|
226
|
+
end
|
227
|
+
end
|
228
|
+
klass2 = Ohai.plugin(:Two) do
|
229
229
|
provides("two")
|
230
|
-
collect_data
|
230
|
+
collect_data do
|
231
231
|
two(2)
|
232
|
-
|
233
|
-
|
234
|
-
klass3 = Ohai.plugin(:Three)
|
232
|
+
end
|
233
|
+
end
|
234
|
+
klass3 = Ohai.plugin(:Three) do
|
235
235
|
provides("three")
|
236
236
|
depends("one", "two")
|
237
|
-
collect_data
|
237
|
+
collect_data do
|
238
238
|
three(3)
|
239
|
-
|
240
|
-
|
239
|
+
end
|
240
|
+
end
|
241
241
|
|
242
242
|
@plugins = []
|
243
243
|
[klass1, klass2, klass3].each do |klass|
|
@@ -282,20 +282,20 @@ describe Ohai::Runner, "run_plugin" do
|
|
282
282
|
|
283
283
|
context "when there is one edge in the cycle (A->B and B->A)" do
|
284
284
|
before(:each) do
|
285
|
-
klass1 = Ohai.plugin(:Thing)
|
285
|
+
klass1 = Ohai.plugin(:Thing) do
|
286
286
|
provides("thing")
|
287
287
|
depends("other")
|
288
|
-
collect_data
|
288
|
+
collect_data do
|
289
289
|
thing(other)
|
290
|
-
|
291
|
-
|
292
|
-
klass2 = Ohai.plugin(:Other)
|
290
|
+
end
|
291
|
+
end
|
292
|
+
klass2 = Ohai.plugin(:Other) do
|
293
293
|
provides("other")
|
294
294
|
depends("thing")
|
295
|
-
collect_data
|
295
|
+
collect_data do
|
296
296
|
other(thing)
|
297
|
-
|
298
|
-
|
297
|
+
end
|
298
|
+
end
|
299
299
|
|
300
300
|
@plugins = []
|
301
301
|
[klass1, klass2].each_with_index do |klass, idx|
|
@@ -319,35 +319,35 @@ describe Ohai::Runner, "run_plugin" do
|
|
319
319
|
@ohai = Ohai::System.new
|
320
320
|
@runner = Ohai::Runner.new(@ohai, true)
|
321
321
|
|
322
|
-
|
322
|
+
klass_a = Ohai.plugin(:A) do
|
323
323
|
provides("A")
|
324
324
|
depends("B", "C")
|
325
325
|
collect_data {}
|
326
|
-
|
327
|
-
|
326
|
+
end
|
327
|
+
klass_b = Ohai.plugin(:B) do
|
328
328
|
provides("B")
|
329
329
|
depends("C")
|
330
330
|
collect_data {}
|
331
|
-
|
332
|
-
|
331
|
+
end
|
332
|
+
klass_c = Ohai.plugin(:C) do
|
333
333
|
provides("C")
|
334
334
|
collect_data {}
|
335
|
-
|
335
|
+
end
|
336
336
|
|
337
337
|
@plugins = []
|
338
|
-
[
|
338
|
+
[klass_a, klass_b, klass_c].each do |klass|
|
339
339
|
@plugins << klass.new(@ohai.data)
|
340
340
|
end
|
341
|
-
@
|
341
|
+
@plugin_a, @plugin_b, @plugin_c = @plugins
|
342
342
|
end
|
343
343
|
|
344
344
|
it "should not detect a cycle when B is the first provider returned" do
|
345
|
-
@ohai.provides_map.set_providers_for(@
|
346
|
-
@ohai.provides_map.set_providers_for(@
|
347
|
-
@ohai.provides_map.set_providers_for(@
|
345
|
+
@ohai.provides_map.set_providers_for(@plugin_a, ["A"])
|
346
|
+
@ohai.provides_map.set_providers_for(@plugin_b, ["B"])
|
347
|
+
@ohai.provides_map.set_providers_for(@plugin_c, ["C"])
|
348
348
|
|
349
349
|
expect(Ohai::Log).not_to receive(:error).with(/DependencyCycleError/)
|
350
|
-
@runner.run_plugin(@
|
350
|
+
@runner.run_plugin(@plugin_a)
|
351
351
|
|
352
352
|
@plugins.each do |plugin|
|
353
353
|
expect(plugin.has_run?).to be true
|
@@ -355,12 +355,12 @@ describe Ohai::Runner, "run_plugin" do
|
|
355
355
|
end
|
356
356
|
|
357
357
|
it "should not detect a cycle when C is the first provider returned" do
|
358
|
-
@ohai.provides_map.set_providers_for(@
|
359
|
-
@ohai.provides_map.set_providers_for(@
|
360
|
-
@ohai.provides_map.set_providers_for(@
|
358
|
+
@ohai.provides_map.set_providers_for(@plugin_a, ["A"])
|
359
|
+
@ohai.provides_map.set_providers_for(@plugin_c, ["C"])
|
360
|
+
@ohai.provides_map.set_providers_for(@plugin_b, ["B"])
|
361
361
|
|
362
362
|
expect(Ohai::Log).not_to receive(:error).with(/DependencyCycleError/)
|
363
|
-
@runner.run_plugin(@
|
363
|
+
@runner.run_plugin(@plugin_a)
|
364
364
|
|
365
365
|
@plugins.each do |plugin|
|
366
366
|
expect(plugin.has_run?).to be true
|
@@ -414,27 +414,27 @@ describe Ohai::Runner, "#get_cycle" do
|
|
414
414
|
@ohai = Ohai::System.new
|
415
415
|
@runner = Ohai::Runner.new(@ohai, true)
|
416
416
|
|
417
|
-
klass1 = Ohai.plugin(:One)
|
417
|
+
klass1 = Ohai.plugin(:One) do
|
418
418
|
provides("one")
|
419
419
|
depends("two")
|
420
|
-
collect_data
|
420
|
+
collect_data do
|
421
421
|
one(two)
|
422
|
-
|
423
|
-
|
424
|
-
klass2 = Ohai.plugin(:Two)
|
422
|
+
end
|
423
|
+
end
|
424
|
+
klass2 = Ohai.plugin(:Two) do
|
425
425
|
provides("two")
|
426
426
|
depends("one")
|
427
|
-
collect_data
|
427
|
+
collect_data do
|
428
428
|
two(one)
|
429
|
-
|
430
|
-
|
431
|
-
klass3 = Ohai.plugin(:Three)
|
429
|
+
end
|
430
|
+
end
|
431
|
+
klass3 = Ohai.plugin(:Three) do
|
432
432
|
provides("three")
|
433
433
|
depends("two")
|
434
|
-
collect_data
|
434
|
+
collect_data do
|
435
435
|
three(two)
|
436
|
-
|
437
|
-
|
436
|
+
end
|
437
|
+
end
|
438
438
|
|
439
439
|
plugins = []
|
440
440
|
[klass1, klass2, klass3].each_with_index do |klass, idx|
|
@@ -78,12 +78,12 @@ describe "Ohai::Util::IpHelper" do
|
|
78
78
|
allow(ip_helper).to receive(:private_address?)
|
79
79
|
end
|
80
80
|
|
81
|
-
it
|
81
|
+
it "should call #private_address?" do
|
82
82
|
expect(ip_helper).to receive(:private_address?)
|
83
83
|
ip_helper.public_address?(address)
|
84
84
|
end
|
85
85
|
|
86
|
-
it
|
86
|
+
it "should return the inverse of #private_address?" do
|
87
87
|
expect(ip_helper.public_address?(address)).to equal !ip_helper.private_address?(address)
|
88
88
|
end
|
89
89
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ohai
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 8.
|
4
|
+
version: 8.20.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Jacob
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-09-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: systemu
|
@@ -390,7 +390,9 @@ files:
|
|
390
390
|
- lib/ohai/plugins/linux/filesystem.rb
|
391
391
|
- lib/ohai/plugins/linux/filesystem2.rb
|
392
392
|
- lib/ohai/plugins/linux/fips.rb
|
393
|
+
- lib/ohai/plugins/linux/hostnamectl.rb
|
393
394
|
- lib/ohai/plugins/linux/lsb.rb
|
395
|
+
- lib/ohai/plugins/linux/machineid.rb
|
394
396
|
- lib/ohai/plugins/linux/mdadm.rb
|
395
397
|
- lib/ohai/plugins/linux/memory.rb
|
396
398
|
- lib/ohai/plugins/linux/network.rb
|
@@ -571,8 +573,10 @@ files:
|
|
571
573
|
- spec/unit/plugins/linux/filesystem_spec.rb
|
572
574
|
- spec/unit/plugins/linux/fips_spec.rb
|
573
575
|
- spec/unit/plugins/linux/hostname_spec.rb
|
576
|
+
- spec/unit/plugins/linux/hostnamectl_spec.rb
|
574
577
|
- spec/unit/plugins/linux/kernel_spec.rb
|
575
578
|
- spec/unit/plugins/linux/lsb_spec.rb
|
579
|
+
- spec/unit/plugins/linux/machineid_spec.rb
|
576
580
|
- spec/unit/plugins/linux/mdadm_spec.rb
|
577
581
|
- spec/unit/plugins/linux/memory_spec.rb
|
578
582
|
- spec/unit/plugins/linux/network_spec.rb
|
@@ -652,7 +656,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
652
656
|
version: '0'
|
653
657
|
requirements: []
|
654
658
|
rubyforge_project:
|
655
|
-
rubygems_version: 2.
|
659
|
+
rubygems_version: 2.5.1
|
656
660
|
signing_key:
|
657
661
|
specification_version: 4
|
658
662
|
summary: Ohai profiles your system and emits JSON
|