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
@@ -101,16 +101,15 @@ Chassis Information
|
|
101
101
|
EOS
|
102
102
|
|
103
103
|
describe Ohai::System, "plugin dmi" do
|
104
|
-
let(:plugin) { get_plugin("dmi") }
|
105
|
-
let(:stdout) { DMI_OUT }
|
106
|
-
|
107
104
|
before(:each) do
|
108
|
-
|
105
|
+
@plugin = get_plugin("dmi")
|
106
|
+
@stdout = DMI_OUT
|
107
|
+
allow(@plugin).to receive(:shell_out).with("dmidecode").and_return(mock_shell_out(0, @stdout, ""))
|
109
108
|
end
|
110
109
|
|
111
|
-
it "
|
112
|
-
expect(plugin).to receive(:shell_out).with("dmidecode").and_return(mock_shell_out(0, stdout, ""))
|
113
|
-
plugin.run
|
110
|
+
it "should run dmidecode" do
|
111
|
+
expect(@plugin).to receive(:shell_out).with("dmidecode").and_return(mock_shell_out(0, @stdout, ""))
|
112
|
+
@plugin.run
|
114
113
|
end
|
115
114
|
|
116
115
|
# Test some simple sample data
|
@@ -129,28 +128,21 @@ describe Ohai::System, "plugin dmi" do
|
|
129
128
|
},
|
130
129
|
}.each do |id, data|
|
131
130
|
data.each do |attribute, value|
|
132
|
-
it "
|
133
|
-
plugin.run
|
134
|
-
expect(plugin[:dmi][id][attribute]).to eql(value)
|
131
|
+
it "should have [:dmi][:#{id}][:#{attribute}] set" do
|
132
|
+
@plugin.run
|
133
|
+
expect(@plugin[:dmi][id][attribute]).to eql(value)
|
135
134
|
end
|
136
|
-
it "
|
137
|
-
stdout = convert_windows_output(DMI_OUT)
|
138
|
-
expect(plugin).to receive(:shell_out).with("dmidecode").and_return(mock_shell_out(0, stdout, ""))
|
139
|
-
plugin.run
|
140
|
-
expect(plugin[:dmi][id][attribute]).to eql(value)
|
135
|
+
it "should have [:dmi][:#{id}][:#{attribute}] set for windows output" do
|
136
|
+
@stdout = convert_windows_output(DMI_OUT)
|
137
|
+
expect(@plugin).to receive(:shell_out).with("dmidecode").and_return(mock_shell_out(0, @stdout, ""))
|
138
|
+
@plugin.run
|
139
|
+
expect(@plugin[:dmi][id][attribute]).to eql(value)
|
141
140
|
end
|
142
141
|
end
|
143
142
|
end
|
144
143
|
|
145
|
-
it "
|
146
|
-
|
147
|
-
plugin.
|
148
|
-
expect(plugin[:dmi]).to have_key(:physical_memory_array)
|
149
|
-
end
|
150
|
-
|
151
|
-
it "correctly ignores data in excluded DMI IDs" do
|
152
|
-
expect(plugin).to receive(:shell_out).with("dmidecode").and_return(mock_shell_out(0, stdout, ""))
|
153
|
-
plugin.run
|
154
|
-
expect(plugin[:dmi]).not_to have_key(:physical_memory_array)
|
144
|
+
it "should correctly ignore unwanted data" do
|
145
|
+
@plugin.run
|
146
|
+
expect(@plugin[:dmi][:base_board]).not_to have_key(:error_correction_type)
|
155
147
|
end
|
156
148
|
end
|
@@ -0,0 +1,100 @@
|
|
1
|
+
#
|
2
|
+
# Copyright:: 2018 Chef Software, Inc.
|
3
|
+
# License:: Apache License, Version 2.0
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
require_relative "../../spec_helper.rb"
|
18
|
+
|
19
|
+
docker_output = <<EOF
|
20
|
+
{"ID":"KZET:VDFN:2V2G:JS5Z:HAKO:SOGI:AFSZ:HDMT:GVEM:V2NT:DUSW:J3Z6","Containers":11,"ContainersRunning":0,"ContainersPaused":0,"ContainersStopped":11,"Images":30,"Driver":"overlay2","DriverStatus":[["Backing Filesystem","extfs"],["Supports d_type","true"],["Native Overlay Diff","true"]],"SystemStatus":null,"Plugins":{"Volume":["local"],"Network":["bridge","host","ipvlan","macvlan","null","overlay"],"Authorization":null,"Log":["awslogs","fluentd","gcplogs","gelf","journald","json-file","logentries","splunk","syslog"]},"MemoryLimit":true,"SwapLimit":true,"KernelMemory":true,"CpuCfsPeriod":true,"CpuCfsQuota":true,"CPUShares":true,"CPUSet":true,"IPv4Forwarding":true,"BridgeNfIptables":true,"BridgeNfIp6tables":true,"Debug":true,"NFd":21,"OomKillDisable":true,"NGoroutines":39,"SystemTime":"2018-02-15T19:12:40.214106068Z","LoggingDriver":"json-file","CgroupDriver":"cgroupfs","NEventsListener":2,"KernelVersion":"4.9.60-linuxkit-aufs","OperatingSystem":"Docker for Mac","OSType":"linux","Architecture":"x86_64","IndexServerAddress":"https://index.docker.io/v1/","RegistryConfig":{"AllowNondistributableArtifactsCIDRs":[],"AllowNondistributableArtifactsHostnames":[],"InsecureRegistryCIDRs":["127.0.0.0/8"],"IndexConfigs":{"docker.io":{"Name":"docker.io","Mirrors":[],"Secure":true,"Official":true}},"Mirrors":[]},"NCPU":4,"MemTotal":2095816704,"GenericResources":null,"DockerRootDir":"/var/lib/docker","HttpProxy":"docker.for.mac.http.internal:3128","HttpsProxy":"docker.for.mac.http.internal:3129","NoProxy":"","Name":"linuxkit-025000000001","Labels":[],"ExperimentalBuild":true,"ServerVersion":"17.12.0-ce","ClusterStore":"","ClusterAdvertise":"","Runtimes":{"runc":{"path":"docker-runc"}},"DefaultRuntime":"runc","Swarm":{"NodeID":"","NodeAddr":"","LocalNodeState":"inactive","ControlAvailable":false,"Error":"","RemoteManagers":null},"LiveRestoreEnabled":false,"Isolation":"","InitBinary":"docker-init","ContainerdCommit":{"ID":"89623f28b87a6004d4b785663257362d1658a729","Expected":"89623f28b87a6004d4b785663257362d1658a729"},"RuncCommit":{"ID":"b2567b37d7b75eb4cf325b77297b140ea686ce8f","Expected":"b2567b37d7b75eb4cf325b77297b140ea686ce8f"},"InitCommit":{"ID":"949e6fa","Expected":"949e6fa"},"SecurityOptions":["name=seccomp,profile=default"]}
|
21
|
+
EOF
|
22
|
+
|
23
|
+
expected_output = {
|
24
|
+
"version_string" => "17.12.0-ce",
|
25
|
+
"version" => "17.12.0",
|
26
|
+
"runtimes" => {
|
27
|
+
"runc" => {
|
28
|
+
"path" => "docker-runc",
|
29
|
+
},
|
30
|
+
},
|
31
|
+
"root_dir" => "/var/lib/docker",
|
32
|
+
"containers" => {
|
33
|
+
"total" => 11,
|
34
|
+
"running" => 0,
|
35
|
+
"paused" => 0,
|
36
|
+
"stopped" => 11,
|
37
|
+
},
|
38
|
+
"plugins" => {
|
39
|
+
"Volume" => [
|
40
|
+
"local",
|
41
|
+
],
|
42
|
+
"Network" => %w{
|
43
|
+
bridge
|
44
|
+
host
|
45
|
+
ipvlan
|
46
|
+
macvlan
|
47
|
+
null
|
48
|
+
overlay},
|
49
|
+
"Authorization" => nil,
|
50
|
+
"Log" => [
|
51
|
+
"awslogs",
|
52
|
+
"fluentd",
|
53
|
+
"gcplogs",
|
54
|
+
"gelf",
|
55
|
+
"journald",
|
56
|
+
"json-file",
|
57
|
+
"logentries",
|
58
|
+
"splunk",
|
59
|
+
"syslog",
|
60
|
+
],
|
61
|
+
},
|
62
|
+
"networking" => {
|
63
|
+
"ipv4_forwarding" => true,
|
64
|
+
"bridge_nf_iptables" => true,
|
65
|
+
"bridge_nf_ipv6_iptables" => true,
|
66
|
+
},
|
67
|
+
"swarm" => {
|
68
|
+
"NodeID" => "",
|
69
|
+
"NodeAddr" => "",
|
70
|
+
"LocalNodeState" => "inactive",
|
71
|
+
"ControlAvailable" => false,
|
72
|
+
"Error" => "",
|
73
|
+
"RemoteManagers" => nil,
|
74
|
+
},
|
75
|
+
}
|
76
|
+
|
77
|
+
describe Ohai::System, "plugin docker" do
|
78
|
+
let(:plugin) { get_plugin("docker") }
|
79
|
+
|
80
|
+
context "if the machine does not have docker installed" do
|
81
|
+
it "should not create a docker attribute" do
|
82
|
+
plugin[:virtualization] = Mash.new
|
83
|
+
plugin[:virtualization][:systems] = Mash.new
|
84
|
+
plugin.run
|
85
|
+
expect(plugin).not_to have_key(:docker)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
context "if the machine has docker installed" do
|
90
|
+
it "should create a docker attribute with correct data" do
|
91
|
+
plugin[:virtualization] = Mash.new
|
92
|
+
plugin[:virtualization][:systems] = Mash.new
|
93
|
+
plugin[:virtualization][:systems][:docker] = "host"
|
94
|
+
allow(plugin).to receive(:shell_out).with("docker info --format '{{json .}}'").and_return(mock_shell_out(0, docker_output, ""))
|
95
|
+
plugin.run
|
96
|
+
expect(plugin).to have_key(:docker)
|
97
|
+
expect(plugin[:docker]).to eq(expected_output)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
@@ -59,13 +59,8 @@ shared_examples "a v7 loading failure" do
|
|
59
59
|
expect { @ohai.provides_map.find_providers_for(["fail"]) }.to raise_error(Ohai::Exceptions::AttributeNotFound)
|
60
60
|
end
|
61
61
|
|
62
|
-
it "should not have source key" do
|
63
|
-
@loader.load_plugin("#{tmp}/plugins/fail.rb")
|
64
|
-
expect(@ohai.v6_dependency_solver).not_to have_key("#{tmp}/plugins/fail.rb")
|
65
|
-
end
|
66
|
-
|
67
62
|
it "should write to Ohai::Log" do
|
68
|
-
expect(
|
63
|
+
expect(@loader.logger).to receive(:warn).once
|
69
64
|
@loader.load_plugin("#{tmp}/plugins/fail.rb")
|
70
65
|
end
|
71
66
|
end
|
@@ -107,13 +102,8 @@ shared_examples "a v7 loading success" do
|
|
107
102
|
expect(@ohai.provides_map).to have_key("fail")
|
108
103
|
end
|
109
104
|
|
110
|
-
it "should have source key" do
|
111
|
-
@loader.load_plugin("#{tmp}/plugins/fail.rb")
|
112
|
-
expect(@ohai.v6_dependency_solver).to have_key("#{tmp}/plugins/fail.rb")
|
113
|
-
end
|
114
|
-
|
115
105
|
it "should not write to Ohai::Log" do
|
116
|
-
expect(
|
106
|
+
expect(@loader.logger).not_to receive(:warn)
|
117
107
|
@loader.load_plugin("#{tmp}/plugins/fail.rb")
|
118
108
|
end
|
119
109
|
end
|
@@ -156,56 +146,11 @@ shared_examples "a v7 run failure" do
|
|
156
146
|
end
|
157
147
|
|
158
148
|
it "should write to Ohai::Log" do
|
159
|
-
expect(
|
149
|
+
expect(@loader.logger).to receive(:warn).once
|
160
150
|
@loader.load_plugin("#{tmp}/plugins/fail.rb").new(@ohai).run
|
161
151
|
end
|
162
152
|
end
|
163
153
|
|
164
|
-
=begin
|
165
|
-
shared_examples "a v6 run failure" do
|
166
|
-
before(:all) do
|
167
|
-
begin
|
168
|
-
Dir.mkdir("#{tmp}/plugins")
|
169
|
-
rescue Errno::EEXIST
|
170
|
-
# ignore
|
171
|
-
end
|
172
|
-
end
|
173
|
-
|
174
|
-
before(:each) do
|
175
|
-
fail_file = File.open("#{tmp}/plugins/fail.rb", "w+")
|
176
|
-
fail_file.write(failstr)
|
177
|
-
fail_file.close
|
178
|
-
end
|
179
|
-
|
180
|
-
after(:each) do
|
181
|
-
File.delete("#{tmp}/plugins/fail.rb")
|
182
|
-
end
|
183
|
-
|
184
|
-
after(:all) do
|
185
|
-
begin
|
186
|
-
Dir.delete("#{tmp}/plugins")
|
187
|
-
rescue
|
188
|
-
# ignore
|
189
|
-
end
|
190
|
-
end
|
191
|
-
|
192
|
-
before(:each) do
|
193
|
-
@ohai = Ohai::System.new
|
194
|
-
@loader = Ohai::Loader.new(@ohai)
|
195
|
-
end
|
196
|
-
|
197
|
-
it "should not add data keys" do
|
198
|
-
@loader.load_plugin("#{tmp}/plugins/fail.rb")
|
199
|
-
@ohai.data.should_not have_key("fail")
|
200
|
-
end
|
201
|
-
|
202
|
-
it "should write to Ohai::Log" do
|
203
|
-
Ohai::Log.should_receive(:warn).once
|
204
|
-
@loader.load_plugin("#{tmp}/plugins/fail.rb").new(@ohai).run
|
205
|
-
end
|
206
|
-
end
|
207
|
-
=end
|
208
|
-
|
209
154
|
describe "when using DSL commands outside Ohai.plugin block" do
|
210
155
|
failstr1 = <<EOF
|
211
156
|
provides "fail"
|
@@ -31,7 +31,7 @@ describe Ohai::System, "Init package" do
|
|
31
31
|
let(:proc_1_file) { double(proc_1_file_path, :gets => proc1_content) }
|
32
32
|
|
33
33
|
before(:each) do
|
34
|
-
allow(File).to receive(:
|
34
|
+
allow(File).to receive(:exist?).with(proc_1_file_path).and_return(proc1_exists)
|
35
35
|
allow(File).to receive(:open).with(proc_1_file_path).and_return(proc_1_file)
|
36
36
|
end
|
37
37
|
|
@@ -35,56 +35,4 @@ describe Ohai::System, "plugin kernel" do
|
|
35
35
|
it_should_check_from_mash("kernel", "version", "uname -v", [0, "Darwin Kernel Version 9.5.0: Wed Sep 3 11:29:43 PDT 2008; root:xnu-1228.7.58~1\/RELEASE_I386\n", ""])
|
36
36
|
it_should_check_from_mash("kernel", "machine", "uname -m", [0, "i386\n", ""])
|
37
37
|
it_should_check_from_mash("kernel", "processor", "uname -p", [0, "i386\n", ""])
|
38
|
-
|
39
|
-
describe "when running on windows", :windows_only do
|
40
|
-
before do
|
41
|
-
require "wmi-lite/wmi"
|
42
|
-
|
43
|
-
@ohai_system = Ohai::System.new
|
44
|
-
@plugin = get_plugin("kernel", @ohai_system)
|
45
|
-
|
46
|
-
# Mock a Win32_OperatingSystem OLE32 WMI object
|
47
|
-
caption = double("WIN32OLE", :name => "Caption")
|
48
|
-
version = double("WIN32OLE", :name => "Version")
|
49
|
-
build_number = double("WIN32OLE", :name => "BuildNumber")
|
50
|
-
csd_version = double("WIN32OLE", :name => "CsdVersion")
|
51
|
-
os_type = double("WIN32OLE", :name => "OsType")
|
52
|
-
os_properties = [ caption, version, build_number, csd_version, os_type ]
|
53
|
-
|
54
|
-
os = double( "WIN32OLE",
|
55
|
-
:properties_ => os_properties)
|
56
|
-
|
57
|
-
allow(os).to receive(:invoke).with(build_number.name).and_return("7601")
|
58
|
-
allow(os).to receive(:invoke).with(csd_version.name).and_return("Service Pack 1")
|
59
|
-
allow(os).to receive(:invoke).with(os_type.name).and_return(18)
|
60
|
-
allow(os).to receive(:invoke).with(caption.name).and_return("Microsoft Windows 7 Ultimate")
|
61
|
-
allow(os).to receive(:invoke).with(version.name).and_return("6.1.7601")
|
62
|
-
|
63
|
-
os_wmi = WmiLite::Wmi::Instance.new(os)
|
64
|
-
|
65
|
-
expect_any_instance_of(WmiLite::Wmi).to receive(:first_of).with("Win32_OperatingSystem").and_return(os_wmi)
|
66
|
-
|
67
|
-
# Mock a Win32_ComputerSystem OLE32 WMI object
|
68
|
-
x64_system_type = "x64-based PC"
|
69
|
-
|
70
|
-
cs = double("WIN32OLE",
|
71
|
-
:properties_ => [ double("WIN32OLE", :name => "SystemType") ])
|
72
|
-
|
73
|
-
allow(cs).to receive(:invoke).with("SystemType").and_return(x64_system_type)
|
74
|
-
|
75
|
-
cs_wmi = WmiLite::Wmi::Instance.new(cs)
|
76
|
-
|
77
|
-
expect_any_instance_of(WmiLite::Wmi).to receive(:first_of).with("Win32_ComputerSystem").and_return(cs_wmi)
|
78
|
-
|
79
|
-
@plugin.run
|
80
|
-
end
|
81
|
-
it "should set the correct system information" do
|
82
|
-
expect(@ohai_system.data[:kernel][:name]).to eq("Microsoft Windows 7 Ultimate")
|
83
|
-
expect(@ohai_system.data[:kernel][:release]).to eq("6.1.7601")
|
84
|
-
expect(@ohai_system.data[:kernel][:version]).to eq("6.1.7601 Service Pack 1 Build 7601")
|
85
|
-
expect(@ohai_system.data[:kernel][:os]).to eq("WINNT")
|
86
|
-
expect(@ohai_system.data[:kernel][:machine]).to eq("x86_64")
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
38
|
end
|
@@ -45,7 +45,7 @@ describe Ohai::System, "Linux Block Device Plugin" do
|
|
45
45
|
@plugin = get_plugin("linux/block_device")
|
46
46
|
allow(@plugin).to receive(:collect_os).and_return(:linux)
|
47
47
|
|
48
|
-
allow(File).to receive(:
|
48
|
+
allow(File).to receive(:exist?).with("/sys/block").and_return(true)
|
49
49
|
allow(Dir).to receive(:[]).with("/sys/block/*") do
|
50
50
|
DISKS.collect { |disk, _files| "/sys/block/#{disk}" }
|
51
51
|
end
|
@@ -55,7 +55,7 @@ describe Ohai::System, "Linux Block Device Plugin" do
|
|
55
55
|
allow(File).to receive(:open).with(Regexp.new("#{disk}.*#{check}")).and_yield(file_double(value))
|
56
56
|
end
|
57
57
|
|
58
|
-
allow(File).to receive(:
|
58
|
+
allow(File).to receive(:exist?).with(Regexp.new(disk)) do |arg|
|
59
59
|
filepath = arg.split("/")
|
60
60
|
checks[filepath.last].nil? ? false : true
|
61
61
|
end
|
@@ -19,7 +19,7 @@
|
|
19
19
|
require_relative "../../../spec_helper.rb"
|
20
20
|
|
21
21
|
describe Ohai::System, "Linux filesystem plugin" do
|
22
|
-
let
|
22
|
+
let(:plugin) { get_plugin("linux/filesystem") }
|
23
23
|
before(:each) do
|
24
24
|
allow(plugin).to receive(:collect_os).and_return(:linux)
|
25
25
|
|
@@ -55,11 +55,6 @@ describe Ohai::System, "Linux filesystem plugin" do
|
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
|
-
it "sets both filesystem and filesystem2 attributes" do
|
59
|
-
plugin.run
|
60
|
-
expect(plugin[:filesystem]).to eq(plugin[:filesystem2])
|
61
|
-
end
|
62
|
-
|
63
58
|
describe "when gathering filesystem usage data from df" do
|
64
59
|
before(:each) do
|
65
60
|
@stdout = <<-DF
|
@@ -545,7 +540,7 @@ BLKID_TYPE
|
|
545
540
|
it "logs warning about #{command} missing" do
|
546
541
|
Ohai.config[:plugin][:filesystem][:allow_partial_data] = true
|
547
542
|
allow(plugin).to receive(:shell_out).with(/#{command}/).and_raise(Ohai::Exceptions::Exec)
|
548
|
-
|
543
|
+
expect_any_instance_of(Mixlib::Log::Child).to receive(:warn).with("Plugin Filesystem: #{command} binary is not available. Some data will not be available.")
|
549
544
|
plugin.run
|
550
545
|
end
|
551
546
|
end
|
@@ -35,8 +35,8 @@ describe Ohai::System, "Linux lsb plugin" do
|
|
35
35
|
and_yield("DISTRIB_CODENAME=hardy").
|
36
36
|
and_yield('DISTRIB_DESCRIPTION="Ubuntu 8.04"')
|
37
37
|
allow(File).to receive(:open).with("/etc/lsb-release").and_return(@double_file)
|
38
|
-
allow(File).to receive(:
|
39
|
-
allow(File).to receive(:
|
38
|
+
allow(File).to receive(:exist?).with("/usr/bin/lsb_release").and_return(false)
|
39
|
+
allow(File).to receive(:exist?).with("/etc/lsb-release").and_return(true)
|
40
40
|
end
|
41
41
|
|
42
42
|
it "should set lsb[:id]" do
|
@@ -62,7 +62,7 @@ describe Ohai::System, "Linux lsb plugin" do
|
|
62
62
|
|
63
63
|
describe "on systems with /usr/bin/lsb_release" do
|
64
64
|
before(:each) do
|
65
|
-
allow(File).to receive(:
|
65
|
+
allow(File).to receive(:exist?).with("/usr/bin/lsb_release").and_return(true)
|
66
66
|
|
67
67
|
@stdin = double("STDIN", { :close => true })
|
68
68
|
@pid = 10
|
@@ -140,8 +140,8 @@ LSB_RELEASE
|
|
140
140
|
end
|
141
141
|
|
142
142
|
it "should not set any lsb values if /etc/lsb-release or /usr/bin/lsb_release do not exist " do
|
143
|
-
allow(File).to receive(:
|
144
|
-
allow(File).to receive(:
|
143
|
+
allow(File).to receive(:exist?).with("/etc/lsb-release").and_return(false)
|
144
|
+
allow(File).to receive(:exist?).with("/usr/bin/lsb_release").and_return(false)
|
145
145
|
expect(@plugin.attribute?(:lsb)).to be(false)
|
146
146
|
end
|
147
147
|
end
|
@@ -19,9 +19,9 @@
|
|
19
19
|
require_relative "../../../spec_helper.rb"
|
20
20
|
|
21
21
|
describe Ohai::System, "Linux lspci plugin" do
|
22
|
-
let
|
23
|
-
|
22
|
+
let(:plugin) { get_plugin("linux/lspci") }
|
24
23
|
before(:each) do
|
24
|
+
allow(plugin).to receive(:collect_os).and_return(:linux)
|
25
25
|
@stdout = <<LSPCI
|
26
26
|
Device: 00:1f.3
|
27
27
|
Class: Audio device [0403]
|
@@ -28,8 +28,8 @@ describe Ohai::System, "Machine id plugin" do
|
|
28
28
|
it "should read /etc/machine-id if available" do
|
29
29
|
machine_id = "6f702523e2fc7499eb1dc68e5314dacf"
|
30
30
|
|
31
|
-
allow(File).to receive(:
|
32
|
-
allow(File).to receive(:read).with("/etc/machine-id").and_return(machine_id)
|
31
|
+
allow(::File).to receive(:exist?).with("/etc/machine-id").and_return(true)
|
32
|
+
allow(::File).to receive(:read).with("/etc/machine-id").and_return(machine_id)
|
33
33
|
plugin.run
|
34
34
|
expect(plugin[:machine_id]).to eq(machine_id)
|
35
35
|
end
|
@@ -37,9 +37,9 @@ describe Ohai::System, "Machine id plugin" do
|
|
37
37
|
it "should read /var/lib/dbus/machine-id if available" do
|
38
38
|
machine_id = "6f702523e2fc7499eb1dc68e5314dacf"
|
39
39
|
|
40
|
-
allow(File).to receive(:
|
41
|
-
allow(File).to receive(:
|
42
|
-
allow(File).to receive(:read).with("/var/lib/dbus/machine-id").and_return(machine_id)
|
40
|
+
allow(::File).to receive(:exist?).with("/etc/machine-id").and_return(false)
|
41
|
+
allow(::File).to receive(:exist?).with("/var/lib/dbus/machine-id").and_return(true)
|
42
|
+
allow(::File).to receive(:read).with("/var/lib/dbus/machine-id").and_return(machine_id)
|
43
43
|
plugin.run
|
44
44
|
expect(plugin[:machine_id]).to eq(machine_id)
|
45
45
|
end
|
@@ -552,7 +552,7 @@ EOM
|
|
552
552
|
end
|
553
553
|
|
554
554
|
it "completes the run" do
|
555
|
-
expect(
|
555
|
+
expect(plugin.logger).not_to receive(:trace).with(/Plugin linux::network threw exception/)
|
556
556
|
expect(plugin["network"]).not_to be_nil
|
557
557
|
end
|
558
558
|
|
@@ -814,7 +814,7 @@ EOM
|
|
814
814
|
end
|
815
815
|
|
816
816
|
it "completes the run" do
|
817
|
-
expect(
|
817
|
+
expect(plugin.logger).not_to receive(:trace).with(/Plugin linux::network threw exception/)
|
818
818
|
expect(plugin["network"]).not_to be_nil
|
819
819
|
end
|
820
820
|
|
@@ -934,7 +934,7 @@ EOM
|
|
934
934
|
end
|
935
935
|
|
936
936
|
it "completes the run" do
|
937
|
-
expect(
|
937
|
+
expect(plugin.logger).not_to receive(:trace).with(/Plugin linux::network threw exception/)
|
938
938
|
expect(plugin["network"]).not_to be_nil
|
939
939
|
end
|
940
940
|
|
@@ -975,7 +975,7 @@ EOM
|
|
975
975
|
end
|
976
976
|
|
977
977
|
it "completes the run" do
|
978
|
-
expect(
|
978
|
+
expect(plugin.logger).not_to receive(:trace).with(/Plugin linux::network threw exception/)
|
979
979
|
expect(plugin["network"]).not_to be_nil
|
980
980
|
end
|
981
981
|
|
@@ -1018,7 +1018,7 @@ EOM
|
|
1018
1018
|
end
|
1019
1019
|
|
1020
1020
|
it "completes the run" do
|
1021
|
-
expect(
|
1021
|
+
expect(plugin.logger).not_to receive(:trace).with(/Plugin linux::network threw exception/)
|
1022
1022
|
expect(plugin["network"]).not_to be_nil
|
1023
1023
|
end
|
1024
1024
|
|
@@ -1053,7 +1053,7 @@ EOM
|
|
1053
1053
|
end
|
1054
1054
|
|
1055
1055
|
it "completes the run" do
|
1056
|
-
expect(
|
1056
|
+
expect(plugin.logger).not_to receive(:trace).with(/Plugin linux::network threw exception/)
|
1057
1057
|
plugin.run
|
1058
1058
|
expect(plugin["network"]).not_to be_nil
|
1059
1059
|
end
|
@@ -1094,7 +1094,7 @@ EOM
|
|
1094
1094
|
let(:linux_ip_route_inet6) { "" }
|
1095
1095
|
|
1096
1096
|
it "completes the run" do
|
1097
|
-
expect(
|
1097
|
+
expect(plugin.logger).not_to receive(:trace).with(/Plugin linux::network threw exception/)
|
1098
1098
|
plugin.run
|
1099
1099
|
expect(plugin["network"]).not_to be_nil
|
1100
1100
|
end
|
@@ -1119,7 +1119,7 @@ EOM
|
|
1119
1119
|
end
|
1120
1120
|
|
1121
1121
|
it "completes the run" do
|
1122
|
-
expect(
|
1122
|
+
expect(plugin.logger).not_to receive(:trace).with(/Plugin linux::network threw exception/)
|
1123
1123
|
expect(plugin["network"]).not_to be_nil
|
1124
1124
|
end
|
1125
1125
|
|
@@ -1140,7 +1140,7 @@ EOM
|
|
1140
1140
|
end
|
1141
1141
|
|
1142
1142
|
it "completes the run" do
|
1143
|
-
expect(
|
1143
|
+
expect(plugin.logger).not_to receive(:trace).with(/Plugin linux::network threw exception/)
|
1144
1144
|
expect(plugin["network"]).not_to be_nil
|
1145
1145
|
end
|
1146
1146
|
|
@@ -1165,7 +1165,7 @@ EOM
|
|
1165
1165
|
end
|
1166
1166
|
|
1167
1167
|
it "completes the run" do
|
1168
|
-
expect(
|
1168
|
+
expect(plugin.logger).not_to receive(:trace).with(/Plugin linux::network threw exception/)
|
1169
1169
|
expect(plugin["network"]).not_to be_nil
|
1170
1170
|
end
|
1171
1171
|
|
@@ -1190,7 +1190,7 @@ EOM
|
|
1190
1190
|
end
|
1191
1191
|
|
1192
1192
|
it "completes the run" do
|
1193
|
-
expect(
|
1193
|
+
expect(plugin.logger).not_to receive(:trace).with(/Plugin linux::network threw exception/)
|
1194
1194
|
expect(plugin["network"]).not_to be_nil
|
1195
1195
|
end
|
1196
1196
|
|
@@ -1224,7 +1224,7 @@ EOM
|
|
1224
1224
|
end
|
1225
1225
|
|
1226
1226
|
it "completes the run" do
|
1227
|
-
expect(
|
1227
|
+
expect(plugin.logger).not_to receive(:trace).with(/Plugin linux::network threw exception/)
|
1228
1228
|
expect(plugin["network"]).not_to be_nil
|
1229
1229
|
end
|
1230
1230
|
|
@@ -1265,7 +1265,7 @@ EOM
|
|
1265
1265
|
end
|
1266
1266
|
|
1267
1267
|
it "completes the run" do
|
1268
|
-
expect(
|
1268
|
+
expect(plugin.logger).not_to receive(:trace).with(/Plugin linux::network threw exception/)
|
1269
1269
|
expect(plugin["network"]).not_to be_nil
|
1270
1270
|
end
|
1271
1271
|
|
@@ -1308,7 +1308,7 @@ EOM
|
|
1308
1308
|
end
|
1309
1309
|
|
1310
1310
|
it "completes the run" do
|
1311
|
-
expect(
|
1311
|
+
expect(plugin.logger).not_to receive(:trace).with(/Plugin linux::network threw exception/)
|
1312
1312
|
expect(plugin["network"]).not_to be_nil
|
1313
1313
|
end
|
1314
1314
|
|
@@ -1336,8 +1336,8 @@ EOM
|
|
1336
1336
|
end
|
1337
1337
|
|
1338
1338
|
it "logs a message and skips previously unseen interfaces in 'ip route show'" do
|
1339
|
-
expect(
|
1340
|
-
allow(
|
1339
|
+
expect(plugin.logger).to receive(:trace).with(/Skipping previously unseen interface from 'ip route show': virbr0/).once
|
1340
|
+
allow(plugin.logger).to receive(:trace) # Catches the 'Loading plugin network' type messages
|
1341
1341
|
plugin.run
|
1342
1342
|
end
|
1343
1343
|
end
|