ohai 13.12.6 → 14.0.28
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +3 -12
- data/README.md +7 -12
- data/Rakefile +16 -23
- data/docs/man/man1/ohai.1 +97 -0
- data/lib/ohai/application.rb +9 -4
- data/lib/ohai/common/dmi.rb +4 -16
- data/lib/ohai/config.rb +5 -1
- data/lib/ohai/dsl.rb +0 -1
- data/lib/ohai/dsl/plugin.rb +12 -16
- data/lib/ohai/dsl/plugin/versionvii.rb +17 -5
- data/lib/ohai/hints.rb +2 -2
- data/lib/ohai/loader.rb +21 -70
- data/lib/ohai/log.rb +1 -1
- data/lib/ohai/mixin/azure_metadata.rb +4 -4
- data/lib/ohai/mixin/command.rb +3 -3
- data/lib/ohai/mixin/dmi_decode.rb +0 -2
- data/lib/ohai/mixin/do_metadata.rb +1 -1
- data/lib/ohai/mixin/ec2_metadata.rb +8 -8
- data/lib/ohai/mixin/gce_metadata.rb +1 -5
- data/lib/ohai/mixin/http_helper.rb +3 -3
- data/lib/ohai/mixin/scaleway_metadata.rb +46 -0
- data/lib/ohai/mixin/softlayer_metadata.rb +3 -3
- data/lib/ohai/plugins/aix/filesystem.rb +1 -1
- data/lib/ohai/plugins/aix/memory.rb +1 -1
- data/lib/ohai/plugins/aix/network.rb +2 -2
- data/lib/ohai/plugins/aix/virtualization.rb +1 -1
- data/lib/ohai/plugins/azure.rb +5 -5
- data/lib/ohai/plugins/bsd/virtualization.rb +11 -11
- data/lib/ohai/plugins/c.rb +8 -8
- data/lib/ohai/plugins/chef.rb +2 -1
- data/lib/ohai/plugins/cloud.rb +0 -3
- data/lib/ohai/plugins/darwin/cpu.rb +2 -2
- data/lib/ohai/plugins/darwin/filesystem.rb +0 -2
- data/lib/ohai/plugins/darwin/hardware.rb +9 -3
- data/lib/ohai/plugins/darwin/network.rb +2 -2
- data/lib/ohai/plugins/darwin/system_profiler.rb +19 -19
- data/lib/ohai/plugins/darwin/virtualization.rb +10 -0
- data/lib/ohai/plugins/digital_ocean.rb +4 -4
- data/lib/ohai/plugins/dmi.rb +15 -14
- data/lib/ohai/plugins/docker.rb +57 -0
- data/lib/ohai/plugins/ec2.rb +11 -11
- data/lib/ohai/plugins/elixir.rb +1 -1
- data/lib/ohai/plugins/erlang.rb +2 -2
- data/lib/ohai/plugins/eucalyptus.rb +5 -5
- data/lib/ohai/plugins/gce.rb +2 -2
- data/lib/ohai/plugins/go.rb +1 -1
- data/lib/ohai/plugins/groovy.rb +1 -1
- data/lib/ohai/plugins/haskell.rb +4 -4
- data/lib/ohai/plugins/hostname.rb +6 -6
- data/lib/ohai/plugins/init_package.rb +1 -1
- data/lib/ohai/plugins/java.rb +1 -1
- data/lib/ohai/plugins/kernel.rb +109 -40
- data/lib/ohai/plugins/libvirt.rb +113 -0
- data/lib/ohai/plugins/linode.rb +4 -4
- data/lib/ohai/plugins/linux/block_device.rb +4 -4
- data/lib/ohai/plugins/linux/cpu.rb +3 -3
- data/lib/ohai/plugins/linux/filesystem.rb +4 -6
- data/lib/ohai/plugins/linux/lsb.rb +3 -3
- data/lib/ohai/plugins/linux/lspci.rb +2 -1
- data/lib/ohai/plugins/linux/machineid.rb +4 -4
- data/lib/ohai/plugins/linux/network.rb +16 -16
- data/lib/ohai/plugins/linux/platform.rb +4 -10
- data/lib/ohai/plugins/linux/sessions.rb +2 -1
- data/lib/ohai/plugins/linux/virtualization.rb +53 -31
- data/lib/ohai/plugins/lua.rb +1 -1
- data/lib/ohai/plugins/mono.rb +2 -2
- data/lib/ohai/plugins/network.rb +11 -11
- data/lib/ohai/plugins/nodejs.rb +1 -1
- data/lib/ohai/plugins/ohai.rb +0 -2
- data/lib/ohai/plugins/openstack.rb +7 -10
- data/lib/ohai/plugins/packages.rb +1 -1
- data/lib/ohai/plugins/passwd.rb +1 -0
- data/lib/ohai/plugins/perl.rb +1 -1
- data/lib/ohai/plugins/php.rb +1 -1
- data/lib/ohai/plugins/powershell.rb +1 -1
- data/lib/ohai/plugins/python.rb +1 -1
- data/lib/ohai/plugins/rackspace.rb +5 -5
- data/lib/ohai/plugins/root_group.rb +6 -9
- data/lib/ohai/plugins/ruby.rb +2 -2
- data/lib/ohai/plugins/rust.rb +1 -1
- data/lib/ohai/plugins/scala.rb +1 -1
- data/lib/ohai/plugins/scaleway.rb +56 -0
- data/lib/ohai/plugins/shard.rb +1 -0
- data/lib/ohai/plugins/softlayer.rb +2 -2
- data/lib/ohai/plugins/solaris2/cpu.rb +1 -1
- data/lib/ohai/plugins/solaris2/dmi.rb +13 -13
- data/lib/ohai/plugins/solaris2/network.rb +6 -6
- data/lib/ohai/plugins/solaris2/platform.rb +2 -2
- data/lib/ohai/plugins/ssh_host_key.rb +7 -7
- data/lib/ohai/plugins/uptime.rb +2 -7
- data/lib/ohai/plugins/virtualbox.rb +1 -1
- data/lib/ohai/plugins/vmware.rb +2 -2
- data/lib/ohai/plugins/windows/cpu.rb +2 -16
- data/lib/ohai/plugins/windows/network.rb +4 -2
- data/lib/ohai/plugins/zpools.rb +3 -3
- data/lib/ohai/provides_map.rb +1 -1
- data/lib/ohai/runner.rb +11 -14
- data/lib/ohai/system.rb +8 -71
- data/lib/ohai/util/file_helper.rb +2 -2
- data/lib/ohai/util/win32/group_helper.rb +0 -2
- data/lib/ohai/version.rb +1 -1
- data/ohai.gemspec +6 -5
- data/spec/functional/plugins/root_group_spec.rb +2 -2
- data/spec/functional/plugins/windows/uptime_spec.rb +0 -29
- data/spec/unit/dsl/plugin_spec.rb +14 -46
- data/spec/unit/loader_spec.rb +8 -70
- data/spec/unit/mixin/azure_metadata_spec.rb +9 -4
- data/spec/unit/mixin/command_spec.rb +11 -8
- data/spec/unit/mixin/ec2_metadata_spec.rb +5 -0
- data/spec/unit/mixin/softlayer_metadata_spec.rb +6 -1
- data/spec/unit/plugins/aix/filesystem_spec.rb +10 -10
- data/spec/unit/plugins/aix/network_spec.rb +1 -1
- data/spec/unit/plugins/aix/virtualization_spec.rb +3 -3
- data/spec/unit/plugins/cloud_spec.rb +0 -12
- data/spec/unit/plugins/darwin/cpu_spec.rb +2 -2
- data/spec/unit/plugins/darwin/filesystem_spec.rb +1 -6
- data/spec/unit/plugins/darwin/hardware_spec.rb +1 -1
- data/spec/unit/plugins/darwin/virtualization_spec.rb +8 -0
- data/spec/unit/plugins/dmi_spec.rb +17 -25
- data/spec/unit/plugins/docker_spec.rb +100 -0
- data/spec/unit/plugins/fail_spec.rb +3 -58
- data/spec/unit/plugins/haskell_spec.rb +1 -1
- data/spec/unit/plugins/init_package_spec.rb +1 -1
- data/spec/unit/plugins/kernel_spec.rb +0 -52
- data/spec/unit/plugins/linux/block_device_spec.rb +2 -2
- data/spec/unit/plugins/linux/filesystem_spec.rb +2 -7
- data/spec/unit/plugins/linux/lsb_spec.rb +5 -5
- data/spec/unit/plugins/linux/lspci_spec.rb +2 -2
- data/spec/unit/plugins/linux/machineid_spec.rb +5 -5
- data/spec/unit/plugins/linux/network_spec.rb +16 -16
- data/spec/unit/plugins/linux/platform_spec.rb +1 -17
- data/spec/unit/plugins/linux/virtualization_spec.rb +21 -1
- data/spec/unit/plugins/network_spec.rb +58 -58
- data/spec/unit/plugins/openstack_spec.rb +5 -24
- data/spec/unit/plugins/rackspace_spec.rb +6 -6
- data/spec/unit/plugins/root_group_spec.rb +1 -1
- data/spec/unit/plugins/ruby_spec.rb +1 -1
- data/spec/unit/plugins/rust_spec.rb +1 -1
- data/spec/unit/plugins/scala_spec.rb +1 -1
- data/spec/unit/plugins/scaleway_spec.rb +91 -0
- data/spec/unit/plugins/solaris2/cpu_spec.rb +3 -3
- data/spec/unit/plugins/solaris2/platform_spec.rb +2 -2
- data/spec/unit/plugins/ssh_host_keys_spec.rb +8 -8
- data/spec/unit/plugins/sysconf_spec.rb +1 -0
- data/spec/unit/plugins/windows/kernel_spec.rb +79 -0
- data/spec/unit/plugins/windows/uptime_spec.rb +8 -58
- data/spec/unit/provides_map_spec.rb +4 -4
- data/spec/unit/runner_spec.rb +15 -54
- data/spec/unit/system_spec.rb +35 -348
- data/spec/unit/util/file_helper_spec.rb +2 -0
- metadata +28 -28
- data/lib/ohai/dsl/plugin/versionvi.rb +0 -61
- data/lib/ohai/plugins/bsd/filesystem2.rb +0 -121
- data/lib/ohai/plugins/ip_scopes.rb +0 -67
- data/lib/ohai/plugins/virtualization.rb +0 -83
- data/spec/data/plugins/messages.rb +0 -8
- data/spec/data/plugins/v6message.rb +0 -2
- data/spec/unit/plugins/bsd/filesystem2_spec.rb +0 -126
- data/spec/unit/plugins/ip_scopes_spec.rb +0 -139
data/spec/unit/system_spec.rb
CHANGED
@@ -35,10 +35,6 @@ describe "Ohai::System" do
|
|
35
35
|
expect(ohai.provides_map).to be_a_kind_of(Ohai::ProvidesMap)
|
36
36
|
end
|
37
37
|
|
38
|
-
it "sets @v6_dependency_solver to a Hash" do
|
39
|
-
expect(ohai.v6_dependency_solver).to be_a_kind_of(Hash)
|
40
|
-
end
|
41
|
-
|
42
38
|
it "merges provided configuration options into the ohai config context" do
|
43
39
|
config = {
|
44
40
|
disabled_plugins: [ :Foo, :Baz ],
|
@@ -90,29 +86,6 @@ describe "Ohai::System" do
|
|
90
86
|
end
|
91
87
|
end
|
92
88
|
|
93
|
-
when_plugins_directory "contains v6 and v7 plugins" do
|
94
|
-
with_plugin("zoo.rb", <<EOF)
|
95
|
-
Ohai.plugin(:Zoo) do
|
96
|
-
provides 'seals'
|
97
|
-
end
|
98
|
-
EOF
|
99
|
-
|
100
|
-
with_plugin("lake.rb", <<EOF)
|
101
|
-
provides 'fish'
|
102
|
-
EOF
|
103
|
-
|
104
|
-
before do
|
105
|
-
Ohai.config[:plugin_path] = [ path_to(".") ]
|
106
|
-
end
|
107
|
-
|
108
|
-
it "load_plugins() should load all the plugins" do
|
109
|
-
ohai.load_plugins
|
110
|
-
expect(ohai.provides_map.map.keys).to include("seals")
|
111
|
-
expect(ohai.v6_dependency_solver.keys).to include("lake.rb")
|
112
|
-
expect(Ohai::NamedPlugin.const_get(:Zoo)).to eq(Ohai::NamedPlugin::Zoo)
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
89
|
when_plugins_directory "contains directories inside" do
|
117
90
|
with_plugin("repo1/zoo.rb", <<EOF)
|
118
91
|
Ohai.plugin(:Zoo) do
|
@@ -121,7 +94,9 @@ end
|
|
121
94
|
EOF
|
122
95
|
|
123
96
|
with_plugin("repo1/lake.rb", <<EOF)
|
97
|
+
Ohai.plugin(:Nature) do
|
124
98
|
provides 'fish'
|
99
|
+
end
|
125
100
|
EOF
|
126
101
|
|
127
102
|
with_plugin("repo2/nature.rb", <<EOF)
|
@@ -131,7 +106,9 @@ end
|
|
131
106
|
EOF
|
132
107
|
|
133
108
|
with_plugin("repo2/mountain.rb", <<EOF)
|
109
|
+
Ohai.plugin(:Nature) do
|
134
110
|
provides 'bear'
|
111
|
+
end
|
135
112
|
EOF
|
136
113
|
|
137
114
|
before do
|
@@ -142,8 +119,6 @@ EOF
|
|
142
119
|
ohai.load_plugins
|
143
120
|
expect(ohai.provides_map.map.keys).to include("seals")
|
144
121
|
expect(ohai.provides_map.map.keys).to include("crabs")
|
145
|
-
expect(ohai.v6_dependency_solver.keys).to include("lake.rb")
|
146
|
-
expect(ohai.v6_dependency_solver.keys).to include("mountain.rb")
|
147
122
|
expect(Ohai::NamedPlugin.const_get(:Zoo)).to eq(Ohai::NamedPlugin::Zoo)
|
148
123
|
expect(Ohai::NamedPlugin.const_get(:Nature)).to eq(Ohai::NamedPlugin::Nature)
|
149
124
|
end
|
@@ -151,123 +126,6 @@ EOF
|
|
151
126
|
end
|
152
127
|
|
153
128
|
describe "when running plugins" do
|
154
|
-
when_plugins_directory "contains v6 plugins only" do
|
155
|
-
with_plugin("zoo.rb", <<EOF)
|
156
|
-
provides 'zoo'
|
157
|
-
zoo("animals")
|
158
|
-
EOF
|
159
|
-
|
160
|
-
with_plugin("park.rb", <<EOF)
|
161
|
-
provides 'park'
|
162
|
-
park("plants")
|
163
|
-
EOF
|
164
|
-
|
165
|
-
it "should collect data from all the plugins" do
|
166
|
-
Ohai.config[:plugin_path] = [ path_to(".") ]
|
167
|
-
ohai.all_plugins
|
168
|
-
expect(ohai.data[:zoo]).to eq("animals")
|
169
|
-
expect(ohai.data[:park]).to eq("plants")
|
170
|
-
expect(ohai.data[:zoo]).to be_frozen
|
171
|
-
expect(ohai.data[:park]).to be_frozen
|
172
|
-
end
|
173
|
-
|
174
|
-
describe "when using :disabled_plugins" do
|
175
|
-
before do
|
176
|
-
Ohai.config[:disabled_plugins] = [ "zoo" ]
|
177
|
-
end
|
178
|
-
|
179
|
-
after do
|
180
|
-
Ohai.config[:disabled_plugins] = [ ]
|
181
|
-
end
|
182
|
-
|
183
|
-
it "shouldn't run disabled version 6 plugins" do
|
184
|
-
Ohai.config[:plugin_path] = [ path_to(".") ]
|
185
|
-
ohai.all_plugins
|
186
|
-
expect(ohai.data[:zoo]).to be_nil
|
187
|
-
expect(ohai.data[:park]).to eq("plants")
|
188
|
-
end
|
189
|
-
end
|
190
|
-
|
191
|
-
describe "when running in whitelist mode" do
|
192
|
-
let(:ohai_system) { Ohai::System.new }
|
193
|
-
|
194
|
-
let(:primary_plugin_class) do
|
195
|
-
Ohai.plugin(:Primary) do
|
196
|
-
provides "primary"
|
197
|
-
depends "dependency/one"
|
198
|
-
depends "dependency/two"
|
199
|
-
collect_data {}
|
200
|
-
end
|
201
|
-
end
|
202
|
-
|
203
|
-
let(:dependency_plugin_one_class) do
|
204
|
-
Ohai.plugin(:DependencyOne) do
|
205
|
-
provides "dependency/one"
|
206
|
-
collect_data {}
|
207
|
-
end
|
208
|
-
end
|
209
|
-
|
210
|
-
let(:dependency_plugin_two_class) do
|
211
|
-
Ohai.plugin(:DependencyTwo) do
|
212
|
-
provides "dependency/two"
|
213
|
-
collect_data {}
|
214
|
-
end
|
215
|
-
end
|
216
|
-
|
217
|
-
let(:unrelated_plugin_class) do
|
218
|
-
Ohai.plugin(:Unrelated) do
|
219
|
-
provides "whatever"
|
220
|
-
collect_data {}
|
221
|
-
end
|
222
|
-
end
|
223
|
-
|
224
|
-
let(:v6_plugin_class) do
|
225
|
-
Class.new(Ohai::DSL::Plugin::VersionVI) { collect_contents("v6_key('v6_data')") }
|
226
|
-
end
|
227
|
-
|
228
|
-
let(:primary_plugin) { primary_plugin_class.new(ohai_system) }
|
229
|
-
let(:dependency_plugin_one) { dependency_plugin_one_class.new(ohai_system) }
|
230
|
-
let(:dependency_plugin_two) { dependency_plugin_two_class.new(ohai_system) }
|
231
|
-
let(:unrelated_plugin) { unrelated_plugin_class.new(ohai_system) }
|
232
|
-
let(:v6_plugin) { v6_plugin_class.new(ohai_system, "/v6_plugin.rb", "/") }
|
233
|
-
|
234
|
-
before do
|
235
|
-
allow(ohai_system).to receive(:load_plugins) # TODO: temporary hack - don't run unrelated plugins...
|
236
|
-
[ primary_plugin, dependency_plugin_one, dependency_plugin_two, unrelated_plugin].each do |plugin|
|
237
|
-
plugin_provides = plugin.class.provides_attrs
|
238
|
-
ohai_system.provides_map.set_providers_for(plugin, plugin_provides)
|
239
|
-
end
|
240
|
-
|
241
|
-
ohai_system.v6_dependency_solver["v6_plugin"] = v6_plugin
|
242
|
-
|
243
|
-
# Instead of calling all plugins we call load and run directly so that the information we setup is not cleared by all_plugins
|
244
|
-
ohai_system.load_plugins
|
245
|
-
ohai_system.run_plugins(true, "primary")
|
246
|
-
end
|
247
|
-
|
248
|
-
# This behavior choice is somewhat arbitrary, based on what creates the
|
249
|
-
# least code complexity in legacy v6 plugin format support. Once we
|
250
|
-
# ship 7.0, though, we need to stick to the same behavior.
|
251
|
-
it "runs v6 plugins" do
|
252
|
-
expect(v6_plugin.has_run?).to be true
|
253
|
-
end
|
254
|
-
|
255
|
-
it "runs plugins that provide the requested attributes" do
|
256
|
-
expect(primary_plugin.has_run?).to be true
|
257
|
-
end
|
258
|
-
|
259
|
-
it "runs dependencies of plugins that provide requested attributes" do
|
260
|
-
expect(dependency_plugin_one.has_run?).to be true
|
261
|
-
expect(dependency_plugin_two.has_run?).to be true
|
262
|
-
end
|
263
|
-
|
264
|
-
it "does not run plugins that are irrelevant to the requested attributes" do
|
265
|
-
expect(unrelated_plugin.has_run?).to be false
|
266
|
-
end
|
267
|
-
|
268
|
-
end
|
269
|
-
end
|
270
|
-
|
271
129
|
when_plugins_directory "contains a v7 plugins with :default and platform specific blocks" do
|
272
130
|
with_plugin("message.rb", <<EOF)
|
273
131
|
Ohai.plugin(:Message) do
|
@@ -317,6 +175,17 @@ Ohai.plugin(:Fails) do
|
|
317
175
|
fail 'thing'
|
318
176
|
end
|
319
177
|
end
|
178
|
+
EOF
|
179
|
+
|
180
|
+
with_plugin("optional.rb", <<EOF)
|
181
|
+
Ohai.plugin(:Optional) do
|
182
|
+
provides 'optional'
|
183
|
+
optional true
|
184
|
+
|
185
|
+
collect_data(:default) do
|
186
|
+
optional("canteloupe")
|
187
|
+
end
|
188
|
+
end
|
320
189
|
EOF
|
321
190
|
|
322
191
|
it "should collect data from all the plugins" do
|
@@ -333,7 +202,7 @@ EOF
|
|
333
202
|
# Make sure the stubbing of runner is not overriden with reset_system during test
|
334
203
|
allow(ohai).to receive(:reset_system)
|
335
204
|
allow(ohai.instance_variable_get("@runner")).to receive(:run_plugin).and_raise(Ohai::Exceptions::AttributeNotFound)
|
336
|
-
expect(
|
205
|
+
expect(ohai.logger).to receive(:error).with(/Encountered error while running plugins/)
|
337
206
|
expect { ohai.all_plugins }.to raise_error(Ohai::Exceptions::AttributeNotFound)
|
338
207
|
end
|
339
208
|
|
@@ -355,232 +224,50 @@ EOF
|
|
355
224
|
end
|
356
225
|
|
357
226
|
describe "when using :critical_plugins" do
|
227
|
+
# if called from cli is true, we'll exit these tests
|
228
|
+
let(:ohai) { Ohai::System.new() }
|
229
|
+
|
358
230
|
before do
|
359
231
|
Ohai.config[:critical_plugins] = [ :Fails ]
|
360
232
|
end
|
233
|
+
|
361
234
|
after do
|
362
235
|
Ohai.config[:critical_plugins] = []
|
363
236
|
end
|
364
237
|
|
365
238
|
it "should fail when critical plugins fail" do
|
366
239
|
Ohai.config[:plugin_path] = [ path_to(".") ]
|
367
|
-
expect
|
368
|
-
|
240
|
+
expect { ohai.all_plugins }.to raise_error(Ohai::Exceptions::CriticalPluginFailure,
|
241
|
+
"The following Ohai plugins marked as critical failed: [:Fails]. Failing Chef run.")
|
369
242
|
end
|
370
|
-
|
371
243
|
end
|
372
|
-
end
|
373
244
|
|
374
|
-
|
375
|
-
|
376
|
-
Ohai.plugin(:Zoo) do
|
377
|
-
provides 'zoo'
|
378
|
-
|
379
|
-
collect_data(:default) do
|
380
|
-
zoo("animals")
|
381
|
-
end
|
382
|
-
end
|
383
|
-
EOF
|
384
|
-
|
385
|
-
with_plugin("my_plugins/nature.rb", <<EOF)
|
386
|
-
Ohai.plugin(:Nature) do
|
387
|
-
provides 'nature'
|
388
|
-
|
389
|
-
collect_data(:default) do
|
390
|
-
nature("cougars")
|
391
|
-
end
|
392
|
-
end
|
393
|
-
EOF
|
394
|
-
|
395
|
-
with_plugin("my_plugins/park.rb", <<EOF)
|
396
|
-
provides 'park'
|
397
|
-
park("plants")
|
398
|
-
EOF
|
399
|
-
|
400
|
-
with_plugin("my_plugins/home.rb", <<EOF)
|
401
|
-
provides 'home'
|
402
|
-
home("dog")
|
403
|
-
EOF
|
404
|
-
|
405
|
-
describe "when using :disabled_plugins" do
|
406
|
-
before do
|
407
|
-
Ohai.config[:disabled_plugins] = [ :Zoo, "my_plugins::park" ]
|
408
|
-
end
|
409
|
-
|
410
|
-
after do
|
411
|
-
Ohai.config[:disabled_plugins] = [ ]
|
412
|
-
end
|
413
|
-
|
414
|
-
it "shouldn't run disabled plugins" do
|
245
|
+
describe "when using :optional_plugins" do
|
246
|
+
it "should not run optional plugins by default" do
|
415
247
|
Ohai.config[:plugin_path] = [ path_to(".") ]
|
416
248
|
ohai.all_plugins
|
417
|
-
expect(ohai.data[:
|
418
|
-
expect(ohai.data[:nature]).to eq("cougars")
|
419
|
-
expect(ohai.data[:park]).to be_nil
|
420
|
-
expect(ohai.data[:home]).to eq("dog")
|
249
|
+
expect(ohai.data[:optional]).to be_nil
|
421
250
|
end
|
422
|
-
end
|
423
|
-
end
|
424
|
-
|
425
|
-
when_plugins_directory "contains v6 plugins that depend on v7 plugins" do
|
426
|
-
with_plugin("messages.rb", <<EOF)
|
427
|
-
require_plugin 'v6message'
|
428
|
-
require_plugin 'v7message'
|
429
|
-
|
430
|
-
provides 'messages'
|
431
|
-
|
432
|
-
messages Mash.new
|
433
|
-
messages[:v6message] = v6message
|
434
|
-
messages[:v7message] = v7message
|
435
|
-
EOF
|
436
|
-
|
437
|
-
with_plugin("v6message.rb", <<EOF)
|
438
|
-
provides 'v6message'
|
439
|
-
v6message "update me!"
|
440
|
-
EOF
|
441
|
-
|
442
|
-
with_plugin("v7message.rb", <<EOF)
|
443
|
-
Ohai.plugin(:V7message) do
|
444
|
-
provides 'v7message'
|
445
|
-
|
446
|
-
collect_data(:default) do
|
447
|
-
v7message "v7 plugins are awesome!"
|
448
|
-
end
|
449
|
-
end
|
450
|
-
EOF
|
451
251
|
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
ohai.all_plugins
|
458
|
-
[:v6message, :v7message, :messages].each do |attribute|
|
459
|
-
expect(ohai.data).to have_key(attribute)
|
252
|
+
it "should run optional plugins when specifically enabled" do
|
253
|
+
Ohai.config[:optional_plugins] = [ :Optional ]
|
254
|
+
Ohai.config[:plugin_path] = [ path_to(".") ]
|
255
|
+
ohai.all_plugins
|
256
|
+
expect(ohai.data[:optional]).to eq("canteloupe")
|
460
257
|
end
|
461
258
|
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
expect(ohai.data[:
|
259
|
+
it "should run optional plugins when all plugins are enabled" do
|
260
|
+
Ohai.config[:run_all_plugins] = true
|
261
|
+
Ohai.config[:plugin_path] = [ path_to(".") ]
|
262
|
+
ohai.all_plugins
|
263
|
+
expect(ohai.data[:optional]).to eq("canteloupe")
|
467
264
|
end
|
468
265
|
end
|
469
266
|
end
|
470
267
|
end
|
471
268
|
|
472
|
-
describe "require_plugin()" do
|
473
|
-
when_plugins_directory "contains v6 and v7 plugin with the same name" do
|
474
|
-
with_plugin("message.rb", <<EOF)
|
475
|
-
provides 'message'
|
476
|
-
|
477
|
-
message "From Version 6"
|
478
|
-
EOF
|
479
|
-
|
480
|
-
with_plugin("v7/message.rb", <<EOF)
|
481
|
-
Ohai.plugin(:Message) do
|
482
|
-
provides 'message'
|
483
|
-
|
484
|
-
collect_data(:default) do
|
485
|
-
message "From Version 7"
|
486
|
-
end
|
487
|
-
end
|
488
|
-
EOF
|
489
|
-
|
490
|
-
before do
|
491
|
-
Ohai.config[:plugin_path] = [ path_to(".") ]
|
492
|
-
end
|
493
|
-
|
494
|
-
it "version 6 should run" do
|
495
|
-
ohai.load_plugins
|
496
|
-
ohai.require_plugin("message")
|
497
|
-
expect(ohai.data[:message]).to eql("From Version 6")
|
498
|
-
end
|
499
|
-
end
|
500
|
-
|
501
|
-
when_plugins_directory "a v6 plugin that requires a v7 plugin with dependencies" do
|
502
|
-
with_plugin("message.rb", <<EOF)
|
503
|
-
provides 'message'
|
504
|
-
|
505
|
-
require_plugin 'v7message'
|
506
|
-
|
507
|
-
message Mash.new
|
508
|
-
message[:v6message] = "Hellos from 6"
|
509
|
-
message[:copy_message] = v7message
|
510
|
-
EOF
|
511
|
-
|
512
|
-
with_plugin("v7message.rb", <<EOF)
|
513
|
-
Ohai.plugin(:V7message) do
|
514
|
-
provides 'v7message'
|
515
|
-
depends 'zoo'
|
516
|
-
|
517
|
-
collect_data(:default) do
|
518
|
-
v7message ("Hellos from 7: " + zoo)
|
519
|
-
end
|
520
|
-
end
|
521
|
-
EOF
|
522
|
-
|
523
|
-
with_plugin("zoo.rb", <<EOF)
|
524
|
-
Ohai.plugin(:Zoo) do
|
525
|
-
provides 'zoo'
|
526
|
-
|
527
|
-
collect_data(:default) do
|
528
|
-
zoo "animals"
|
529
|
-
end
|
530
|
-
end
|
531
|
-
EOF
|
532
|
-
|
533
|
-
before do
|
534
|
-
Ohai.config[:plugin_path] = [ path_to(".") ]
|
535
|
-
end
|
536
|
-
|
537
|
-
it "should collect all the data properly" do
|
538
|
-
ohai.all_plugins
|
539
|
-
expect(ohai.data[:v7message]).to eq("Hellos from 7: animals")
|
540
|
-
expect(ohai.data[:zoo]).to eq("animals")
|
541
|
-
expect(ohai.data[:message][:v6message]).to eq("Hellos from 6")
|
542
|
-
expect(ohai.data[:message][:copy_message]).to eq("Hellos from 7: animals")
|
543
|
-
end
|
544
|
-
end
|
545
|
-
|
546
|
-
when_plugins_directory "a v6 plugin that requires non-existing v7 plugin" do
|
547
|
-
with_plugin("message.rb", <<EOF)
|
548
|
-
provides 'message'
|
549
|
-
|
550
|
-
require_plugin 'v7message'
|
551
|
-
|
552
|
-
message v7message
|
553
|
-
EOF
|
554
|
-
|
555
|
-
before do
|
556
|
-
Ohai.config[:plugin_path] = [ path_to(".") ]
|
557
|
-
end
|
558
|
-
|
559
|
-
it "should raise DependencyNotFound" do
|
560
|
-
expect { ohai.all_plugins }.to raise_error(Ohai::Exceptions::DependencyNotFound)
|
561
|
-
end
|
562
|
-
end
|
563
|
-
end
|
564
|
-
|
565
269
|
describe "when Chef OHAI resource executes :reload action" do
|
566
270
|
|
567
|
-
when_plugins_directory "contains a v6 plugin" do
|
568
|
-
with_plugin("a_v6plugin.rb", <<-E)
|
569
|
-
plugin_data Mash.new
|
570
|
-
plugin_data[:foo] = :bar
|
571
|
-
E
|
572
|
-
|
573
|
-
before do
|
574
|
-
Ohai.config[:plugin_path] = [ path_to(".") ]
|
575
|
-
end
|
576
|
-
|
577
|
-
it "reloads only the v6 plugin when given a specific plugin to load" do
|
578
|
-
ohai.all_plugins
|
579
|
-
expect { ohai.all_plugins("a_v6plugin") }.not_to raise_error
|
580
|
-
end
|
581
|
-
|
582
|
-
end
|
583
|
-
|
584
271
|
when_plugins_directory "contains a random plugin" do
|
585
272
|
with_plugin("random.rb", <<-E)
|
586
273
|
Ohai.plugin(:Random) do
|