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/loader_spec.rb
CHANGED
@@ -23,7 +23,7 @@ describe Ohai::Loader do
|
|
23
23
|
extend IntegrationSupport
|
24
24
|
|
25
25
|
let(:loader) { Ohai::Loader.new(ohai) }
|
26
|
-
let(:ohai) { double("Ohai::System", :data => Mash.new, :provides_map => provides_map) }
|
26
|
+
let(:ohai) { double("Ohai::System", :data => Mash.new, :provides_map => provides_map, logger: Ohai::Log) }
|
27
27
|
let(:provides_map) { Ohai::ProvidesMap.new }
|
28
28
|
|
29
29
|
describe "#initialize" do
|
@@ -33,68 +33,6 @@ describe Ohai::Loader do
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
-
when_plugins_directory "contains both V6 & V7 plugins" do
|
37
|
-
with_plugin("zoo.rb", <<EOF)
|
38
|
-
Ohai.plugin(:Zoo) do
|
39
|
-
provides 'seals'
|
40
|
-
end
|
41
|
-
EOF
|
42
|
-
|
43
|
-
with_plugin("zoo_too.rb", <<EOF)
|
44
|
-
Ohai.plugin(:Zoo) do
|
45
|
-
provides 'elephants'
|
46
|
-
end
|
47
|
-
EOF
|
48
|
-
|
49
|
-
with_plugin("lake.rb", <<EOF)
|
50
|
-
provides 'fish'
|
51
|
-
EOF
|
52
|
-
|
53
|
-
describe "load_plugin() method" do
|
54
|
-
describe "when loading a v7 plugin" do
|
55
|
-
let(:plugin) { loader.load_plugin(path_to("zoo.rb")) }
|
56
|
-
|
57
|
-
it "saves the plugin according to its attribute" do
|
58
|
-
plugin
|
59
|
-
expect(provides_map.map.keys).to include("seals")
|
60
|
-
end
|
61
|
-
|
62
|
-
it "saves a single plugin source" do
|
63
|
-
expect(plugin.source).to eql([path_to("zoo.rb")])
|
64
|
-
end
|
65
|
-
|
66
|
-
it "saves all plugin sources" do
|
67
|
-
plugin
|
68
|
-
loader.load_plugin(path_to("zoo_too.rb"))
|
69
|
-
expect(plugin.source).to eql([path_to("zoo.rb"), path_to("zoo_too.rb")])
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
describe "when loading a v6 plugin" do
|
74
|
-
let(:plugin) { loader.load_plugin(path_to("lake.rb"), path_to(".")) }
|
75
|
-
|
76
|
-
before(:each) do
|
77
|
-
expect(Ohai::Log).to receive(:warn).with(/\[DEPRECATION\]/)
|
78
|
-
end
|
79
|
-
|
80
|
-
it "does not add this plugin's provided attributes to the provides map" do
|
81
|
-
plugin
|
82
|
-
expect(provides_map.map).to be_empty
|
83
|
-
end
|
84
|
-
|
85
|
-
it "saves the plugin's source" do
|
86
|
-
expect(plugin.source).to eql(path_to("lake.rb"))
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
it "logs a warning if a plugin doesn't exist" do
|
91
|
-
expect(Ohai::Log).to receive(:warn).with(/Unable to open or read plugin/)
|
92
|
-
loader.load_plugin(path_to("rainier.rb"), path_to("."))
|
93
|
-
expect(provides_map.map).to be_empty
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
36
|
when_plugins_directory "is an additional plugin path" do
|
99
37
|
with_plugin("cookbook_a/alpha.rb", <<EOF)
|
100
38
|
Ohai.plugin(:Alpha) do
|
@@ -170,7 +108,7 @@ EOF
|
|
170
108
|
describe "load_plugin() method" do
|
171
109
|
describe "when the plugin uses Ohai.plugin instead of Ohai.plugins" do
|
172
110
|
it "logs an unsupported operation warning" do
|
173
|
-
expect(
|
111
|
+
expect(loader.logger).to receive(:warn).with(/Plugin Method Error: <#{path_to("extra_s.rb")}>:/)
|
174
112
|
loader.load_plugin(path_to("extra_s.rb"))
|
175
113
|
end
|
176
114
|
|
@@ -181,7 +119,7 @@ EOF
|
|
181
119
|
|
182
120
|
describe "when the plugin tries to call an unexisting method" do
|
183
121
|
it "shoud log an unsupported operation warning" do
|
184
|
-
expect(
|
122
|
+
expect(loader.logger).to receive(:warn).with(/Plugin Method Error: <#{path_to("no_method.rb")}>:/)
|
185
123
|
loader.load_plugin(path_to("no_method.rb"))
|
186
124
|
end
|
187
125
|
|
@@ -192,7 +130,7 @@ EOF
|
|
192
130
|
|
193
131
|
describe "when the plugin defines collect_data on the same platform more than once" do
|
194
132
|
it "shoud log an illegal plugin definition warning" do
|
195
|
-
expect(
|
133
|
+
expect(loader.logger).to receive(:warn).with(/Plugin Definition Error: <#{path_to("illegal_def.rb")}>:/)
|
196
134
|
loader.load_plugin(path_to("illegal_def.rb"))
|
197
135
|
end
|
198
136
|
|
@@ -203,7 +141,7 @@ EOF
|
|
203
141
|
|
204
142
|
describe "when an unexpected error is encountered" do
|
205
143
|
it "logs a warning" do
|
206
|
-
expect(
|
144
|
+
expect(loader.logger).to receive(:warn).with(/Plugin Error: <#{path_to("unexpected_error.rb")}>:/)
|
207
145
|
loader.load_plugin(path_to("unexpected_error.rb"))
|
208
146
|
end
|
209
147
|
|
@@ -214,7 +152,7 @@ EOF
|
|
214
152
|
|
215
153
|
describe "when the plugin name symbol has bad syntax" do
|
216
154
|
it "logs a syntax error warning" do
|
217
|
-
expect(
|
155
|
+
expect(loader.logger).to receive(:warn).with(/Plugin Syntax Error: <#{path_to("bad_symbol.rb")}>:/)
|
218
156
|
loader.load_plugin(path_to("bad_symbol.rb"))
|
219
157
|
end
|
220
158
|
|
@@ -225,7 +163,7 @@ EOF
|
|
225
163
|
|
226
164
|
describe "when the plugin forgets an 'end'" do
|
227
165
|
it "logs a syntax error warning" do
|
228
|
-
expect(
|
166
|
+
expect(loader.logger).to receive(:warn).with(/Plugin Syntax Error: <#{path_to("no_end.rb")}>:/)
|
229
167
|
loader.load_plugin(path_to("no_end.rb"))
|
230
168
|
end
|
231
169
|
|
@@ -236,7 +174,7 @@ EOF
|
|
236
174
|
|
237
175
|
describe "when the plugin has an invalid name" do
|
238
176
|
it "logs an invalid plugin name warning" do
|
239
|
-
expect(
|
177
|
+
expect(loader.logger).to receive(:warn).with(/Plugin Name Error: <#{path_to("bad_name.rb")}>:/)
|
240
178
|
loader.load_plugin(path_to("bad_name.rb"))
|
241
179
|
end
|
242
180
|
|
@@ -25,13 +25,18 @@ describe Ohai::Mixin::AzureMetadata do
|
|
25
25
|
mixin
|
26
26
|
end
|
27
27
|
|
28
|
+
before do
|
29
|
+
logger = instance_double("Mixlib::Log::Child", trace: nil, debug: nil, warn: nil)
|
30
|
+
allow(mixin).to receive(:logger).and_return(logger)
|
31
|
+
end
|
32
|
+
|
28
33
|
describe "#http_get" do
|
29
34
|
it "gets the passed URI" do
|
30
35
|
http_mock = double("http")
|
31
36
|
allow(http_mock).to receive(:read_timeout=)
|
32
37
|
allow(Net::HTTP).to receive(:start).with("169.254.169.254").and_return(http_mock)
|
33
38
|
|
34
|
-
expect(http_mock).to receive(:get).with("http://www.chef.io",
|
39
|
+
expect(http_mock).to receive(:get).with("http://www.chef.io", { "Metadata" => "true" })
|
35
40
|
mixin.http_get("http://www.chef.io")
|
36
41
|
end
|
37
42
|
end
|
@@ -41,7 +46,7 @@ describe Ohai::Mixin::AzureMetadata do
|
|
41
46
|
http_mock = double("http", { :code => "500" })
|
42
47
|
allow(mixin).to receive(:http_get).and_return(http_mock)
|
43
48
|
|
44
|
-
expect(
|
49
|
+
expect(mixin.logger).to receive(:warn)
|
45
50
|
vals = mixin.fetch_metadata
|
46
51
|
expect(vals).to eq(nil)
|
47
52
|
end
|
@@ -50,7 +55,7 @@ describe Ohai::Mixin::AzureMetadata do
|
|
50
55
|
http_mock = double("http", { :code => "200", :body => '{ "foo" "bar"}' })
|
51
56
|
allow(mixin).to receive(:http_get).and_return(http_mock)
|
52
57
|
|
53
|
-
expect(
|
58
|
+
expect(mixin.logger).to receive(:warn)
|
54
59
|
vals = mixin.fetch_metadata
|
55
60
|
expect(vals).to eq(nil)
|
56
61
|
end
|
@@ -59,7 +64,7 @@ describe Ohai::Mixin::AzureMetadata do
|
|
59
64
|
http_mock = double("http", { :code => "200", :body => '{ "foo": "bar"}' })
|
60
65
|
allow(mixin).to receive(:http_get).and_return(http_mock)
|
61
66
|
|
62
|
-
expect(
|
67
|
+
expect(mixin.logger).not_to receive(:warn)
|
63
68
|
vals = mixin.fetch_metadata
|
64
69
|
expect(vals).to eq({ "foo" => "bar" })
|
65
70
|
end
|
@@ -28,7 +28,10 @@ describe Ohai::Mixin::Command, "shell_out" do
|
|
28
28
|
|
29
29
|
let(:options) { windows? ? { timeout: 30 } : { timeout: 30, env: { "PATH" => "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" } } }
|
30
30
|
|
31
|
+
let(:logger) { instance_double("Mixlib::Log::Child", trace: nil, debug: nil, warn: nil) }
|
32
|
+
|
31
33
|
before(:each) do
|
34
|
+
allow(Ohai::Mixin::Command).to receive(:logger).and_return(logger)
|
32
35
|
allow(Ohai::Mixin::Command).to receive(:name).and_return(plugin_name)
|
33
36
|
@original_env = ENV.to_hash
|
34
37
|
ENV.clear
|
@@ -53,7 +56,7 @@ describe Ohai::Mixin::Command, "shell_out" do
|
|
53
56
|
to receive(:exitstatus).
|
54
57
|
and_return(256)
|
55
58
|
|
56
|
-
expect(
|
59
|
+
expect(logger).to receive(:trace).
|
57
60
|
with("Plugin OSSparkleDream: ran 'sparkle-dream --version' and returned 256")
|
58
61
|
|
59
62
|
Ohai::Mixin::Command.shell_out(cmd)
|
@@ -71,8 +74,8 @@ describe Ohai::Mixin::Command, "shell_out" do
|
|
71
74
|
to receive(:run_command).
|
72
75
|
and_raise(Errno::ENOENT, "sparkle-dream")
|
73
76
|
|
74
|
-
expect(
|
75
|
-
to receive(:
|
77
|
+
expect(logger).
|
78
|
+
to receive(:trace).
|
76
79
|
with("Plugin OSSparkleDream: ran 'sparkle-dream --version' and failed " \
|
77
80
|
"#<Errno::ENOENT: No such file or directory - sparkle-dream>")
|
78
81
|
|
@@ -92,8 +95,8 @@ describe Ohai::Mixin::Command, "shell_out" do
|
|
92
95
|
to receive(:run_command).
|
93
96
|
and_raise(Mixlib::ShellOut::CommandTimeout)
|
94
97
|
|
95
|
-
expect(
|
96
|
-
to receive(:
|
98
|
+
expect(logger).
|
99
|
+
to receive(:trace).
|
97
100
|
with("Plugin OSSparkleDream: ran 'sparkle-dream --version' and timed " \
|
98
101
|
"out after 30 seconds")
|
99
102
|
|
@@ -118,7 +121,7 @@ describe Ohai::Mixin::Command, "shell_out" do
|
|
118
121
|
to receive(:exitstatus).
|
119
122
|
and_return(256)
|
120
123
|
|
121
|
-
expect(
|
124
|
+
expect(logger).to receive(:trace).
|
122
125
|
with("Plugin OSSparkleDream: ran 'sparkle-dream --version' and returned 256")
|
123
126
|
|
124
127
|
Ohai::Mixin::Command.shell_out(cmd, options)
|
@@ -135,8 +138,8 @@ describe Ohai::Mixin::Command, "shell_out" do
|
|
135
138
|
to receive(:run_command).
|
136
139
|
and_raise(Mixlib::ShellOut::CommandTimeout)
|
137
140
|
|
138
|
-
expect(
|
139
|
-
to receive(:
|
141
|
+
expect(logger).
|
142
|
+
to receive(:trace).
|
140
143
|
with("Plugin OSSparkleDream: ran 'sparkle-dream --version' and timed " \
|
141
144
|
"out after 10 seconds")
|
142
145
|
|
@@ -28,6 +28,11 @@ describe Ohai::Mixin::Ec2Metadata do
|
|
28
28
|
metadata_object
|
29
29
|
end
|
30
30
|
|
31
|
+
before do
|
32
|
+
logger = instance_double("Mixlib::Log::Child", trace: nil, debug: nil, warn: nil)
|
33
|
+
allow(mixin).to receive(:logger).and_return(logger)
|
34
|
+
end
|
35
|
+
|
31
36
|
context "#best_api_version" do
|
32
37
|
context "with a sorted list of metadata versions" do
|
33
38
|
let(:response) { double("Net::HTTP Response", :body => "1.0\n2011-05-01\n2012-01-12\nUnsupported", :code => "200") }
|
@@ -27,6 +27,11 @@ describe ::Ohai::Mixin::SoftlayerMetadata do
|
|
27
27
|
mixin
|
28
28
|
end
|
29
29
|
|
30
|
+
before do
|
31
|
+
logger = instance_double("Mixlib::Log::Child", trace: nil, debug: nil, warn: nil)
|
32
|
+
allow(mixin).to receive(:logger).and_return(logger)
|
33
|
+
end
|
34
|
+
|
30
35
|
def make_request(item)
|
31
36
|
"/rest/v3.1/SoftLayer_Resource_Metadata/#{item}"
|
32
37
|
end
|
@@ -41,7 +46,7 @@ describe ::Ohai::Mixin::SoftlayerMetadata do
|
|
41
46
|
allow(http_mock).to receive(:get).and_raise(StandardError.new("API return fake error"))
|
42
47
|
allow(::Net::HTTP).to receive(:new).with("api.service.softlayer.com", 443).and_return(http_mock)
|
43
48
|
|
44
|
-
expect(
|
49
|
+
expect(mixin.logger).to receive(:error).at_least(:once)
|
45
50
|
expect { mixin.fetch_metadata }.to raise_error(StandardError)
|
46
51
|
end
|
47
52
|
|
@@ -69,7 +69,7 @@ DF_PK
|
|
69
69
|
/dev/hd11admin /admin jfs2 Jul 17 13:22 rw,log=/dev/hd8
|
70
70
|
/proc /proc procfs Jul 17 13:22 rw
|
71
71
|
/dev/hd10opt /opt jfs2 Jul 17 13:22 rw,log=/dev/hd8
|
72
|
-
192.168.1.11 /stage/
|
72
|
+
192.168.1.11 /stage/middleware /stage/middleware nfs3 Jul 17 13:24 ro,bg,hard,intr,sec=sys
|
73
73
|
MOUNT
|
74
74
|
|
75
75
|
@mount_wpar = <<-MOUNT
|
@@ -82,7 +82,7 @@ MOUNT
|
|
82
82
|
Global /tmp jfs2 Nov 23 21:03 rw,log=NULL
|
83
83
|
Global /usr jfs2 Nov 23 21:03 rw,log=NULL
|
84
84
|
Global /var jfs2 Nov 23 21:03 rw,log=NULL
|
85
|
-
192.168.1.11 /stage/
|
85
|
+
192.168.1.11 /stage/middleware /stage/middleware nfs3 Jul 17 13:24 ro,bg,hard,intr,sec=sys
|
86
86
|
MOUNT
|
87
87
|
|
88
88
|
@plugin = get_plugin("aix/filesystem")
|
@@ -134,19 +134,19 @@ MOUNT
|
|
134
134
|
expect(@plugin[:filesystem]["/dev/hd4"]["mount_options"]).to eq(["rw", "log=/dev/hd8"])
|
135
135
|
end
|
136
136
|
|
137
|
-
# For entries like 192.168.1.11 /stage/
|
137
|
+
# For entries like 192.168.1.11 /stage/middleware /stage/middleware nfs3 Jul 17 13:24 ro,bg,hard,intr,sec=sys
|
138
138
|
context "having node values" do
|
139
139
|
|
140
140
|
it "returns the filesystem mount location" do
|
141
|
-
expect(@plugin[:filesystem]["192.168.1.11:/stage/
|
141
|
+
expect(@plugin[:filesystem]["192.168.1.11:/stage/middleware"]["mount"]).to eq("/stage/middleware")
|
142
142
|
end
|
143
143
|
|
144
144
|
it "returns the filesystem type" do
|
145
|
-
expect(@plugin[:filesystem]["192.168.1.11:/stage/
|
145
|
+
expect(@plugin[:filesystem]["192.168.1.11:/stage/middleware"]["fs_type"]).to eq("nfs3")
|
146
146
|
end
|
147
147
|
|
148
148
|
it "returns the filesystem mount options" do
|
149
|
-
expect(@plugin[:filesystem]["192.168.1.11:/stage/
|
149
|
+
expect(@plugin[:filesystem]["192.168.1.11:/stage/middleware"]["mount_options"]).to eq(["ro", "bg", "hard", "intr", "sec=sys"])
|
150
150
|
end
|
151
151
|
end
|
152
152
|
end
|
@@ -196,19 +196,19 @@ MOUNT
|
|
196
196
|
expect(@plugin[:filesystem]["Global:/"]["mount_options"]).to eq(["rw", "log=NULL"])
|
197
197
|
end
|
198
198
|
|
199
|
-
# For entries like 192.168.1.11 /stage/
|
199
|
+
# For entries like 192.168.1.11 /stage/middleware /stage/middleware nfs3 Jul 17 13:24 ro,bg,hard,intr,sec=sys
|
200
200
|
context "having node values" do
|
201
201
|
|
202
202
|
it "returns the filesystem mount location" do
|
203
|
-
expect(@plugin[:filesystem]["192.168.1.11:/stage/
|
203
|
+
expect(@plugin[:filesystem]["192.168.1.11:/stage/middleware"]["mount"]).to eq("/stage/middleware")
|
204
204
|
end
|
205
205
|
|
206
206
|
it "returns the filesystem type" do
|
207
|
-
expect(@plugin[:filesystem]["192.168.1.11:/stage/
|
207
|
+
expect(@plugin[:filesystem]["192.168.1.11:/stage/middleware"]["fs_type"]).to eq("nfs3")
|
208
208
|
end
|
209
209
|
|
210
210
|
it "returns the filesystem mount options" do
|
211
|
-
expect(@plugin[:filesystem]["192.168.1.11:/stage/
|
211
|
+
expect(@plugin[:filesystem]["192.168.1.11:/stage/middleware"]["mount_options"]).to eq(["ro", "bg", "hard", "intr", "sec=sys"])
|
212
212
|
end
|
213
213
|
end
|
214
214
|
end
|
@@ -272,12 +272,12 @@ LSWPAR_L
|
|
272
272
|
end
|
273
273
|
|
274
274
|
context "when collecting WPAR info" do
|
275
|
-
it
|
275
|
+
it "finds the WPAR's hostname correctly" do
|
276
276
|
expect(wpar1[:hostname]).to eq("applejack-pony-541ba3.ponyville.com")
|
277
277
|
expect(wpar2[:hostname]).to eq("fluttershy-pony-5c969f.ponyville.com")
|
278
278
|
end
|
279
279
|
|
280
|
-
it
|
280
|
+
it "finds the WPAR's IP correctly" do
|
281
281
|
expect(wpar1[:address]).to eq("192.168.0.231")
|
282
282
|
expect(wpar2[:address]).to eq("192.168.0.18")
|
283
283
|
end
|
@@ -289,7 +289,7 @@ LSWPAR_L
|
|
289
289
|
end
|
290
290
|
end
|
291
291
|
|
292
|
-
context
|
292
|
+
context "when WPARs don't exist on the LPAR" do
|
293
293
|
before do
|
294
294
|
allow(plugin).to receive(:shell_out).with("lswpar -L").and_return(mock_shell_out(0, "", nil))
|
295
295
|
plugin.run
|
@@ -89,18 +89,6 @@ describe Ohai::System, "plugin cloud" do
|
|
89
89
|
@plugin[:softlayer] = nil
|
90
90
|
@plugin.run
|
91
91
|
expect(@plugin[:cloud]).to be_nil
|
92
|
-
expect(@plugin[:cloud_v2]).to be_nil
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
describe "with a cloud mash" do
|
97
|
-
before do
|
98
|
-
@plugin[:ec2] = Mash.new
|
99
|
-
end
|
100
|
-
|
101
|
-
it "populates cloud public ip" do
|
102
|
-
@plugin.run
|
103
|
-
expect(@plugin[:cloud]).to eq(@plugin[:cloud_v2])
|
104
92
|
end
|
105
93
|
end
|
106
94
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Nathan L Smith (<nlloyds@gmail.com>)
|
3
|
-
# Copyright:: Copyright (c) 2013-
|
3
|
+
# Copyright:: Copyright (c) 2013-2016 Chef Software, Inc.
|
4
4
|
# License:: Apache License, Version 2.0
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -78,7 +78,7 @@ machdep.cpu.max_basic: 13
|
|
78
78
|
CTL
|
79
79
|
|
80
80
|
allow(@plugin).to receive(:collect_os).and_return(:darwin)
|
81
|
-
allow(@plugin).to receive(:shell_out).with("sysctl
|
81
|
+
allow(@plugin).to receive(:shell_out).with("sysctl -a").and_return(mock_shell_out(0, @stdout, ""))
|
82
82
|
@plugin.run
|
83
83
|
end
|
84
84
|
|
@@ -19,7 +19,7 @@
|
|
19
19
|
require_relative "../../../spec_helper.rb"
|
20
20
|
|
21
21
|
describe Ohai::System, "darwin filesystem plugin" do
|
22
|
-
let
|
22
|
+
let(:plugin) { get_plugin("darwin/filesystem") }
|
23
23
|
before(:each) do
|
24
24
|
allow(plugin).to receive(:collect_os).and_return(:darwin)
|
25
25
|
|
@@ -27,11 +27,6 @@ describe Ohai::System, "darwin filesystem plugin" do
|
|
27
27
|
allow(plugin).to receive(:shell_out).with("mount").and_return(mock_shell_out(0, "", ""))
|
28
28
|
end
|
29
29
|
|
30
|
-
it "sets both filesystem and filesystem2 attributes" do
|
31
|
-
plugin.run
|
32
|
-
expect(plugin[:filesystem]).to eq(plugin[:filesystem2])
|
33
|
-
end
|
34
|
-
|
35
30
|
describe "when gathering filesystem usage data from df" do
|
36
31
|
before(:each) do
|
37
32
|
@stdout = <<-DF
|
@@ -20,7 +20,7 @@ require_relative "../../../spec_helper.rb"
|
|
20
20
|
require_relative "hardware_system_profiler_output.rb"
|
21
21
|
|
22
22
|
describe Ohai::System, "Darwin hardware plugin", :unix_only do
|
23
|
-
let
|
23
|
+
let(:plugin) { get_plugin("darwin/hardware") }
|
24
24
|
before(:each) do
|
25
25
|
allow(plugin).to receive(:collect_os).and_return(:darwin)
|
26
26
|
# Make sure it always runs correct commands and mock the data as it calls them
|
@@ -40,6 +40,14 @@ describe Ohai::System, "Darwin virtualization platform" do
|
|
40
40
|
expect(plugin[:virtualization]).to eq({ "systems" => {} })
|
41
41
|
end
|
42
42
|
|
43
|
+
it "should set docker host if docker exists" do
|
44
|
+
allow(plugin).to receive(:docker_exists?).and_return(true)
|
45
|
+
plugin.run
|
46
|
+
expect(plugin[:virtualization][:system]).to eq("docker")
|
47
|
+
expect(plugin[:virtualization][:role]).to eq("host")
|
48
|
+
expect(plugin[:virtualization][:systems][:docker]).to eq("host")
|
49
|
+
end
|
50
|
+
|
43
51
|
it "should set vmware host if /Applications/VMware\ Fusion.app exists" do
|
44
52
|
allow(plugin).to receive(:fusion_exists?).and_return(true)
|
45
53
|
plugin.run
|