ohai 8.6.0.alpha.0 → 8.6.0.alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/ohai/config.rb +3 -7
- data/lib/ohai/plugins/linux/virtualization.rb +1 -1
- data/lib/ohai/plugins/solaris2/network.rb +1 -1
- data/lib/ohai/system.rb +9 -1
- data/lib/ohai/version.rb +1 -1
- data/spec/unit/plugins/linux/virtualization_spec.rb +236 -216
- data/spec/unit/system_spec.rb +8 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 12feba79315d30d742f71e9c26690a64ad71d11e
|
4
|
+
data.tar.gz: fcf8ae37a2db845807a95a41deccf634a3373ff8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a901bb634ac4cc771412dd23140c7c6af7d52e0123e9ba010d7debe478ccc678e7acfcf8302c7c9be972b4fcccc25c8a73d58872c985640ba66998be96785541
|
7
|
+
data.tar.gz: 4f792e178bf51309803110aad9c9ddb107aa7724417437013b845918d89244f09320389179bb12278ea3e57a86551d1ef2768592345f42a77d34eba40f8b4cff
|
data/lib/ohai/config.rb
CHANGED
@@ -17,12 +17,8 @@
|
|
17
17
|
# limitations under the License.
|
18
18
|
#
|
19
19
|
|
20
|
-
require 'ohai/log'
|
21
|
-
require 'chef-config/logger'
|
22
|
-
|
23
|
-
ChefConfig::Logger = Ohai::Log
|
24
|
-
|
25
20
|
require 'chef-config/config'
|
21
|
+
require 'ohai/log'
|
26
22
|
|
27
23
|
module Ohai
|
28
24
|
Config = ChefConfig::Config
|
@@ -58,7 +54,7 @@ module Ohai
|
|
58
54
|
# (e.g., Ohai::Config[:plugin_path] << some_path) in their config files.
|
59
55
|
default :disabled_plugins, []
|
60
56
|
default :hints_path, default_hints_path
|
61
|
-
default :log_level, :
|
57
|
+
default :log_level, :auto
|
62
58
|
default :log_location, STDERR
|
63
59
|
default :plugin_path, default_plugin_path
|
64
60
|
|
@@ -95,7 +91,7 @@ module Ohai
|
|
95
91
|
config_context :ohai do
|
96
92
|
default :disabled_plugins, []
|
97
93
|
default :hints_path, Ohai::Config.default_hints_path
|
98
|
-
default :log_level, :
|
94
|
+
default :log_level, :auto
|
99
95
|
default :log_location, STDERR
|
100
96
|
default :plugin_path, Ohai::Config.default_plugin_path
|
101
97
|
end
|
@@ -146,7 +146,7 @@ Ohai.plugin(:Virtualization) do
|
|
146
146
|
virtualization[:system] = "openstack"
|
147
147
|
virtualization[:role] = "guest"
|
148
148
|
virtualization[:systems][:openstack] = "guest"
|
149
|
-
when /Manufacturer: QEMU/
|
149
|
+
when /Manufacturer: QEMU|Product Name: KVM/
|
150
150
|
virtualization[:system] = "kvm"
|
151
151
|
virtualization[:role] = "guest"
|
152
152
|
virtualization[:systems][:kvm] = "guest"
|
@@ -58,7 +58,7 @@ ETHERNET_ENCAPS = %w{ afe amd8111s arn atge ath bfe bge bnx bnxe ce cxgbe
|
|
58
58
|
dmfe e1000g efe elxl emlxs eri hermon hme hxge igb
|
59
59
|
iprb ipw iwh iwi iwk iwp ixgb ixgbe mwl mxfe myri10ge
|
60
60
|
nge ntxn nxge pcn platform qfe qlc ral rge rtls rtw rwd
|
61
|
-
rwn sfe tavor vr wpi xge yge}
|
61
|
+
rwn sfe tavor vr wpi xge yge} unless defined?(ETHERNET_ENCAPS)
|
62
62
|
|
63
63
|
Ohai.plugin(:Network) do
|
64
64
|
provides "network", "network/interfaces"
|
data/lib/ohai/system.rb
CHANGED
@@ -50,6 +50,7 @@ module Ohai
|
|
50
50
|
@v6_dependency_solver = Hash.new
|
51
51
|
|
52
52
|
configure_ohai
|
53
|
+
configure_logging
|
53
54
|
|
54
55
|
@loader = Ohai::Loader.new(self)
|
55
56
|
@runner = Ohai::Runner.new(self, true)
|
@@ -213,9 +214,16 @@ module Ohai
|
|
213
214
|
!Ohai.config[:plugin_path].include?(Ohai::Config[:directory])
|
214
215
|
Ohai.config[:plugin_path] << Ohai.config[:directory]
|
215
216
|
end
|
217
|
+
end
|
216
218
|
|
219
|
+
def configure_logging
|
217
220
|
Ohai::Log.init(Ohai.config[:log_location])
|
218
|
-
|
221
|
+
|
222
|
+
if Ohai.config[:log_level] == :auto
|
223
|
+
Ohai::Log.level = :info
|
224
|
+
else
|
225
|
+
Ohai::Log.level = Ohai.config[:log_level]
|
226
|
+
end
|
219
227
|
end
|
220
228
|
end
|
221
229
|
end
|
data/lib/ohai/version.rb
CHANGED
@@ -19,9 +19,10 @@
|
|
19
19
|
require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
|
20
20
|
|
21
21
|
describe Ohai::System, "Linux virtualization platform" do
|
22
|
+
let(:plugin) { get_plugin("linux/virtualization") }
|
23
|
+
|
22
24
|
before(:each) do
|
23
|
-
|
24
|
-
allow(@plugin).to receive(:collect_os).and_return(:linux)
|
25
|
+
allow(plugin).to receive(:collect_os).and_return(:linux)
|
25
26
|
|
26
27
|
# default to all requested Files not existing
|
27
28
|
allow(File).to receive(:exists?).with("/proc/xen").and_return(false)
|
@@ -39,109 +40,109 @@ describe Ohai::System, "Linux virtualization platform" do
|
|
39
40
|
end
|
40
41
|
|
41
42
|
describe "when we are checking for xen" do
|
42
|
-
it "
|
43
|
+
it "sets xen guest if /proc/xen exists but /proc/xen/capabilities does not" do
|
43
44
|
expect(File).to receive(:exists?).with("/proc/xen").and_return(true)
|
44
45
|
expect(File).to receive(:exists?).with("/proc/xen/capabilities").and_return(false)
|
45
|
-
|
46
|
-
expect(
|
47
|
-
expect(
|
48
|
-
expect(
|
46
|
+
plugin.run
|
47
|
+
expect(plugin[:virtualization][:system]).to eq("xen")
|
48
|
+
expect(plugin[:virtualization][:role]).to eq("guest")
|
49
|
+
expect(plugin[:virtualization][:systems][:xen]).to eq("guest")
|
49
50
|
end
|
50
51
|
|
51
|
-
it "
|
52
|
+
it "sets xen host if /proc/xen/capabilities contains control_d " do
|
52
53
|
expect(File).to receive(:exists?).with("/proc/xen").and_return(true)
|
53
54
|
expect(File).to receive(:exists?).with("/proc/xen/capabilities").and_return(true)
|
54
55
|
allow(File).to receive(:read).with("/proc/xen/capabilities").and_return("control_d")
|
55
|
-
|
56
|
-
expect(
|
57
|
-
expect(
|
58
|
-
expect(
|
56
|
+
plugin.run
|
57
|
+
expect(plugin[:virtualization][:system]).to eq("xen")
|
58
|
+
expect(plugin[:virtualization][:role]).to eq("host")
|
59
|
+
expect(plugin[:virtualization][:systems][:xen]).to eq("host")
|
59
60
|
end
|
60
61
|
|
61
|
-
it "
|
62
|
+
it "sets xen guest if /proc/xen/capabilities exists but is empty" do
|
62
63
|
expect(File).to receive(:exists?).with("/proc/xen").and_return(true)
|
63
64
|
expect(File).to receive(:exists?).with("/proc/xen/capabilities").and_return(true)
|
64
65
|
allow(File).to receive(:read).with("/proc/xen/capabilities").and_return("")
|
65
|
-
|
66
|
-
expect(
|
67
|
-
expect(
|
68
|
-
expect(
|
66
|
+
plugin.run
|
67
|
+
expect(plugin[:virtualization][:system]).to eq("xen")
|
68
|
+
expect(plugin[:virtualization][:role]).to eq("guest")
|
69
|
+
expect(plugin[:virtualization][:systems][:xen]).to eq("guest")
|
69
70
|
end
|
70
71
|
|
71
|
-
it "
|
72
|
+
it "does not set virtualization if xen isn't there" do
|
72
73
|
expect(File).to receive(:exists?).at_least(:once).and_return(false)
|
73
|
-
|
74
|
-
expect(
|
74
|
+
plugin.run
|
75
|
+
expect(plugin[:virtualization]).to eq({'systems' => {}})
|
75
76
|
end
|
76
77
|
end
|
77
78
|
|
78
79
|
describe "when we are checking for kvm" do
|
79
|
-
it "
|
80
|
+
it "sets kvm host if /proc/modules contains kvm" do
|
80
81
|
expect(File).to receive(:exists?).with("/proc/modules").and_return(true)
|
81
82
|
allow(File).to receive(:read).with("/proc/modules").and_return("kvm 165872 1 kvm_intel")
|
82
|
-
|
83
|
-
expect(
|
84
|
-
expect(
|
85
|
-
expect(
|
83
|
+
plugin.run
|
84
|
+
expect(plugin[:virtualization][:system]).to eq("kvm")
|
85
|
+
expect(plugin[:virtualization][:role]).to eq("host")
|
86
|
+
expect(plugin[:virtualization][:systems][:kvm]).to eq("host")
|
86
87
|
end
|
87
88
|
|
88
|
-
it "
|
89
|
+
it "sets kvm guest if /proc/cpuinfo contains QEMU Virtual CPU" do
|
89
90
|
expect(File).to receive(:exists?).with("/proc/cpuinfo").and_return(true)
|
90
91
|
allow(File).to receive(:read).with("/proc/cpuinfo").and_return("QEMU Virtual CPU")
|
91
|
-
|
92
|
-
expect(
|
93
|
-
expect(
|
94
|
-
expect(
|
92
|
+
plugin.run
|
93
|
+
expect(plugin[:virtualization][:system]).to eq("kvm")
|
94
|
+
expect(plugin[:virtualization][:role]).to eq("guest")
|
95
|
+
expect(plugin[:virtualization][:systems][:kvm]).to eq("guest")
|
95
96
|
end
|
96
97
|
|
97
|
-
it "
|
98
|
+
it "sets kvm guest if /proc/cpuinfo contains Common KVM processor" do
|
98
99
|
expect(File).to receive(:exists?).with("/proc/cpuinfo").and_return(true)
|
99
100
|
allow(File).to receive(:read).with("/proc/cpuinfo").and_return("Common KVM processor")
|
100
|
-
|
101
|
-
expect(
|
102
|
-
expect(
|
103
|
-
expect(
|
101
|
+
plugin.run
|
102
|
+
expect(plugin[:virtualization][:system]).to eq("kvm")
|
103
|
+
expect(plugin[:virtualization][:role]).to eq("guest")
|
104
|
+
expect(plugin[:virtualization][:systems][:kvm]).to eq("guest")
|
104
105
|
end
|
105
106
|
|
106
|
-
it "
|
107
|
+
it "sets kvm guest if /proc/cpuinfo contains Common 32-bit KVM processor" do
|
107
108
|
expect(File).to receive(:exists?).with("/proc/cpuinfo").and_return(true)
|
108
109
|
allow(File).to receive(:read).with("/proc/cpuinfo").and_return("Common 32-bit KVM processor")
|
109
|
-
|
110
|
-
expect(
|
111
|
-
expect(
|
112
|
-
expect(
|
110
|
+
plugin.run
|
111
|
+
expect(plugin[:virtualization][:system]).to eq("kvm")
|
112
|
+
expect(plugin[:virtualization][:role]).to eq("guest")
|
113
|
+
expect(plugin[:virtualization][:systems][:kvm]).to eq("guest")
|
113
114
|
end
|
114
115
|
|
115
|
-
it "
|
116
|
+
it "does not set virtualization if kvm isn't there" do
|
116
117
|
expect(File).to receive(:exists?).at_least(:once).and_return(false)
|
117
|
-
|
118
|
-
expect(
|
118
|
+
plugin.run
|
119
|
+
expect(plugin[:virtualization]).to eq({'systems' => {}})
|
119
120
|
end
|
120
121
|
end
|
121
122
|
|
122
123
|
describe "when we are checking for VirtualBox" do
|
123
|
-
it "
|
124
|
+
it "sets vbox host if /proc/modules contains vboxdrv" do
|
124
125
|
expect(File).to receive(:exists?).with("/proc/modules").and_return(true)
|
125
126
|
allow(File).to receive(:read).with("/proc/modules").and_return("vboxdrv 268268 3 vboxnetadp,vboxnetflt")
|
126
|
-
|
127
|
-
expect(
|
128
|
-
expect(
|
129
|
-
expect(
|
127
|
+
plugin.run
|
128
|
+
expect(plugin[:virtualization][:system]).to eq("vbox")
|
129
|
+
expect(plugin[:virtualization][:role]).to eq("host")
|
130
|
+
expect(plugin[:virtualization][:systems][:vbox]).to eq("host")
|
130
131
|
end
|
131
132
|
|
132
|
-
it "
|
133
|
+
it "sets vbox gues if /proc/modules contains vboxguest" do
|
133
134
|
expect(File).to receive(:exists?).with("/proc/modules").and_return(true)
|
134
135
|
allow(File).to receive(:read).with("/proc/modules").and_return("vboxguest 214901 2 vboxsf, Live 0xffffffffa00db000 (OF)")
|
135
|
-
|
136
|
-
expect(
|
137
|
-
expect(
|
138
|
-
expect(
|
136
|
+
plugin.run
|
137
|
+
expect(plugin[:virtualization][:system]).to eq("vbox")
|
138
|
+
expect(plugin[:virtualization][:role]).to eq("guest")
|
139
|
+
expect(plugin[:virtualization][:systems][:vbox]).to eq("guest")
|
139
140
|
end
|
140
141
|
|
141
|
-
it "
|
142
|
+
it "does not set virtualization if vbox isn't there" do
|
142
143
|
expect(File).to receive(:exists?).at_least(:once).and_return(false)
|
143
|
-
|
144
|
-
expect(
|
144
|
+
plugin.run
|
145
|
+
expect(plugin[:virtualization]).to eq({'systems' => {}})
|
145
146
|
end
|
146
147
|
end
|
147
148
|
|
@@ -150,7 +151,7 @@ describe Ohai::System, "Linux virtualization platform" do
|
|
150
151
|
expect(File).to receive(:exists?).with("/usr/sbin/dmidecode").and_return(true)
|
151
152
|
end
|
152
153
|
|
153
|
-
it "
|
154
|
+
it "sets virtualpc guest if dmidecode detects Microsoft Virtual Machine" do
|
154
155
|
ms_vpc_dmidecode=<<-MSVPC
|
155
156
|
System Information
|
156
157
|
Manufacturer: Microsoft Corporation
|
@@ -160,14 +161,14 @@ System Information
|
|
160
161
|
UUID: D29974A4-BE51-044C-BDC6-EFBC4B87A8E9
|
161
162
|
Wake-up Type: Power Switch
|
162
163
|
MSVPC
|
163
|
-
allow(
|
164
|
-
|
165
|
-
expect(
|
166
|
-
expect(
|
167
|
-
expect(
|
164
|
+
allow(plugin).to receive(:shell_out).with("dmidecode").and_return(mock_shell_out(0, ms_vpc_dmidecode, ""))
|
165
|
+
plugin.run
|
166
|
+
expect(plugin[:virtualization][:system]).to eq("virtualpc")
|
167
|
+
expect(plugin[:virtualization][:role]).to eq("guest")
|
168
|
+
expect(plugin[:virtualization][:systems][:virtualpc]).to eq("guest")
|
168
169
|
end
|
169
170
|
|
170
|
-
it "
|
171
|
+
it "sets vmware guest if dmidecode detects VMware Virtual Platform" do
|
171
172
|
vmware_dmidecode=<<-VMWARE
|
172
173
|
System Information
|
173
174
|
Manufacturer: VMware, Inc.
|
@@ -179,14 +180,14 @@ System Information
|
|
179
180
|
SKU Number: Not Specified
|
180
181
|
Family: Not Specified
|
181
182
|
VMWARE
|
182
|
-
allow(
|
183
|
-
|
184
|
-
expect(
|
185
|
-
expect(
|
186
|
-
expect(
|
183
|
+
allow(plugin).to receive(:shell_out).with("dmidecode").and_return(mock_shell_out(0, vmware_dmidecode, ""))
|
184
|
+
plugin.run
|
185
|
+
expect(plugin[:virtualization][:system]).to eq("vmware")
|
186
|
+
expect(plugin[:virtualization][:role]).to eq("guest")
|
187
|
+
expect(plugin[:virtualization][:systems][:vmware]).to eq("guest")
|
187
188
|
end
|
188
189
|
|
189
|
-
it "
|
190
|
+
it "sets vbox guest if dmidecode detects Oracle Corporation" do
|
190
191
|
vbox_dmidecode=<<-VBOX
|
191
192
|
Base Board Information
|
192
193
|
Manufacturer: Oracle Corporation
|
@@ -200,14 +201,14 @@ Base Board Information
|
|
200
201
|
Type: Motherboard
|
201
202
|
Contained Object Handles: 0
|
202
203
|
VBOX
|
203
|
-
allow(
|
204
|
-
|
205
|
-
expect(
|
206
|
-
expect(
|
207
|
-
expect(
|
204
|
+
allow(plugin).to receive(:shell_out).with("dmidecode").and_return(mock_shell_out(0, vbox_dmidecode, ""))
|
205
|
+
plugin.run
|
206
|
+
expect(plugin[:virtualization][:system]).to eq("vbox")
|
207
|
+
expect(plugin[:virtualization][:role]).to eq("guest")
|
208
|
+
expect(plugin[:virtualization][:systems][:vbox]).to eq("guest")
|
208
209
|
end
|
209
210
|
|
210
|
-
it "
|
211
|
+
it "sets openstack guest if dmidecode detects OpenStack" do
|
211
212
|
openstack_dmidecode=<<-OPENSTACK
|
212
213
|
System Information
|
213
214
|
Manufacturer: Red Hat Inc.
|
@@ -219,136 +220,155 @@ System Information
|
|
219
220
|
SKU Number: Not Specified
|
220
221
|
Family: Red Hat Enterprise Linux
|
221
222
|
OPENSTACK
|
222
|
-
allow(
|
223
|
-
|
224
|
-
expect(
|
225
|
-
expect(
|
226
|
-
expect(
|
223
|
+
allow(plugin).to receive(:shell_out).with("dmidecode").and_return(mock_shell_out(0, openstack_dmidecode, ""))
|
224
|
+
plugin.run
|
225
|
+
expect(plugin[:virtualization][:system]).to eq("openstack")
|
226
|
+
expect(plugin[:virtualization][:role]).to eq("guest")
|
227
|
+
expect(plugin[:virtualization][:systems][:openstack]).to eq("guest")
|
228
|
+
end
|
229
|
+
|
230
|
+
it "sets kvm guest if dmidecode detects KVM" do
|
231
|
+
kvm_dmidecode=<<-KVM
|
232
|
+
System Information
|
233
|
+
Manufacturer: Red Hat
|
234
|
+
Product Name: KVM
|
235
|
+
Version: RHEL 7.0.0 PC (i440FX + PIIX, 1996)
|
236
|
+
Serial Number: Not Specified
|
237
|
+
UUID: 6E56CFE2-2088-4A46-906A-FC49EDC4072C
|
238
|
+
Wake-up Type: Power Switch
|
239
|
+
SKU Number: Not Specified
|
240
|
+
Family: Red Hat Enterprise Linux
|
241
|
+
KVM
|
242
|
+
allow(plugin).to receive(:shell_out).with("dmidecode").and_return(mock_shell_out(0, kvm_dmidecode, ""))
|
243
|
+
plugin.run
|
244
|
+
expect(plugin[:virtualization][:system]).to eq("kvm")
|
245
|
+
expect(plugin[:virtualization][:role]).to eq("guest")
|
246
|
+
expect(plugin[:virtualization][:systems][:kvm]).to eq("guest")
|
227
247
|
end
|
228
248
|
|
229
249
|
it "should run dmidecode and not set virtualization if nothing is detected" do
|
230
|
-
allow(
|
231
|
-
|
232
|
-
expect(
|
250
|
+
allow(plugin).to receive(:shell_out).with("dmidecode").and_return(mock_shell_out(0, "", ""))
|
251
|
+
plugin.run
|
252
|
+
expect(plugin[:virtualization]).to eq({'systems' => {}})
|
233
253
|
end
|
234
254
|
end
|
235
255
|
|
236
256
|
describe "when we are checking for Linux-VServer" do
|
237
|
-
it "
|
257
|
+
it "sets Linux-VServer host if /proc/self/status contains s_context: 0" do
|
238
258
|
expect(File).to receive(:exists?).with("/proc/self/status").and_return(true)
|
239
259
|
allow(File).to receive(:read).with("/proc/self/status").and_return("s_context: 0")
|
240
|
-
|
241
|
-
expect(
|
242
|
-
expect(
|
243
|
-
expect(
|
260
|
+
plugin.run
|
261
|
+
expect(plugin[:virtualization][:system]).to eq("linux-vserver")
|
262
|
+
expect(plugin[:virtualization][:role]).to eq("host")
|
263
|
+
expect(plugin[:virtualization][:systems]['linux-vserver']).to eq("host")
|
244
264
|
end
|
245
265
|
|
246
|
-
it "
|
266
|
+
it "sets Linux-VServer host if /proc/self/status contains VxID: 0" do
|
247
267
|
expect(File).to receive(:exists?).with("/proc/self/status").and_return(true)
|
248
268
|
allow(File).to receive(:read).with("/proc/self/status").and_return("VxID: 0")
|
249
|
-
|
250
|
-
expect(
|
251
|
-
expect(
|
252
|
-
expect(
|
269
|
+
plugin.run
|
270
|
+
expect(plugin[:virtualization][:system]).to eq("linux-vserver")
|
271
|
+
expect(plugin[:virtualization][:role]).to eq("host")
|
272
|
+
expect(plugin[:virtualization][:systems]['linux-vserver']).to eq("host")
|
253
273
|
end
|
254
274
|
|
255
|
-
it "
|
275
|
+
it "sets Linux-VServer host if /proc/self/status contains multiple space VxID: 0" do
|
256
276
|
expect(File).to receive(:exists?).with("/proc/self/status").and_return(true)
|
257
277
|
allow(File).to receive(:read).with("/proc/self/status").and_return("VxID: 0")
|
258
|
-
|
259
|
-
expect(
|
260
|
-
expect(
|
261
|
-
expect(
|
278
|
+
plugin.run
|
279
|
+
expect(plugin[:virtualization][:system]).to eq("linux-vserver")
|
280
|
+
expect(plugin[:virtualization][:role]).to eq("host")
|
281
|
+
expect(plugin[:virtualization][:systems]['linux-vserver']).to eq("host")
|
262
282
|
end
|
263
283
|
|
264
|
-
it "
|
284
|
+
it "sets Linux-VServer host if /proc/self/status contains tabbed VxID:\t0" do
|
265
285
|
expect(File).to receive(:exists?).with("/proc/self/status").and_return(true)
|
266
286
|
allow(File).to receive(:read).with("/proc/self/status").and_return("VxID:\t0")
|
267
|
-
|
268
|
-
expect(
|
269
|
-
expect(
|
270
|
-
expect(
|
287
|
+
plugin.run
|
288
|
+
expect(plugin[:virtualization][:system]).to eq("linux-vserver")
|
289
|
+
expect(plugin[:virtualization][:role]).to eq("host")
|
290
|
+
expect(plugin[:virtualization][:systems]['linux-vserver']).to eq("host")
|
271
291
|
end
|
272
292
|
|
273
|
-
it "
|
293
|
+
it "sets Linux-VServer guest if /proc/self/status contains s_context > 0" do
|
274
294
|
expect(File).to receive(:exists?).with("/proc/self/status").and_return(true)
|
275
295
|
allow(File).to receive(:read).with("/proc/self/status").and_return("s_context: 2")
|
276
|
-
|
277
|
-
expect(
|
278
|
-
expect(
|
279
|
-
expect(
|
296
|
+
plugin.run
|
297
|
+
expect(plugin[:virtualization][:system]).to eq("linux-vserver")
|
298
|
+
expect(plugin[:virtualization][:role]).to eq("guest")
|
299
|
+
expect(plugin[:virtualization][:systems]['linux-vserver']).to eq("guest")
|
280
300
|
end
|
281
301
|
|
282
|
-
it "
|
302
|
+
it "sets Linux-VServer guest if /proc/self/status contains VxID > 0" do
|
283
303
|
expect(File).to receive(:exists?).with("/proc/self/status").and_return(true)
|
284
304
|
allow(File).to receive(:read).with("/proc/self/status").and_return("VxID: 2")
|
285
|
-
|
286
|
-
expect(
|
287
|
-
expect(
|
288
|
-
expect(
|
305
|
+
plugin.run
|
306
|
+
expect(plugin[:virtualization][:system]).to eq("linux-vserver")
|
307
|
+
expect(plugin[:virtualization][:role]).to eq("guest")
|
308
|
+
expect(plugin[:virtualization][:systems]['linux-vserver']).to eq("guest")
|
289
309
|
end
|
290
310
|
|
291
|
-
it "
|
311
|
+
it "does not set virtualization if Linux-VServer isn't there" do
|
292
312
|
expect(File).to receive(:exists?).at_least(:once).and_return(false)
|
293
|
-
|
294
|
-
expect(
|
313
|
+
plugin.run
|
314
|
+
expect(plugin[:virtualization]).to eq({'systems' => {}})
|
295
315
|
end
|
296
316
|
end
|
297
317
|
|
298
318
|
describe "when we are checking for openvz" do
|
299
|
-
it "
|
319
|
+
it "sets openvz host if /proc/bc/0 exists" do
|
300
320
|
expect(File).to receive(:exists?).with("/proc/bc/0").and_return(true)
|
301
|
-
|
302
|
-
expect(
|
303
|
-
expect(
|
304
|
-
expect(
|
321
|
+
plugin.run
|
322
|
+
expect(plugin[:virtualization][:system]).to eq("openvz")
|
323
|
+
expect(plugin[:virtualization][:role]).to eq("host")
|
324
|
+
expect(plugin[:virtualization][:systems][:openvz]).to eq("host")
|
305
325
|
end
|
306
326
|
|
307
|
-
it "
|
327
|
+
it "sets openvz guest if /proc/bc/0 does not exist and /proc/vz exists" do
|
308
328
|
expect(File).to receive(:exists?).with("/proc/bc/0").and_return(false)
|
309
329
|
expect(File).to receive(:exists?).with("/proc/vz").and_return(true)
|
310
|
-
|
311
|
-
expect(
|
312
|
-
expect(
|
313
|
-
expect(
|
330
|
+
plugin.run
|
331
|
+
expect(plugin[:virtualization][:system]).to eq("openvz")
|
332
|
+
expect(plugin[:virtualization][:role]).to eq("guest")
|
333
|
+
expect(plugin[:virtualization][:systems][:openvz]).to eq("guest")
|
314
334
|
end
|
315
335
|
|
316
|
-
it "
|
336
|
+
it "does not set virtualization if openvz isn't there" do
|
317
337
|
expect(File).to receive(:exists?).with("/proc/bc/0").and_return(false)
|
318
338
|
expect(File).to receive(:exists?).with("/proc/vz").and_return(false)
|
319
|
-
|
320
|
-
expect(
|
339
|
+
plugin.run
|
340
|
+
expect(plugin[:virtualization]).to eq({'systems' => {}})
|
321
341
|
end
|
322
342
|
end
|
323
343
|
|
324
344
|
describe "when we are checking for parallels" do
|
325
|
-
it "
|
345
|
+
it "sets parallels guest if /proc/bus/pci/devices contains 1ab84000" do
|
326
346
|
devices=<<-DEVICES
|
327
347
|
0018 1ab84000 1f 8001 0 0 0 0 0 0 20 0 0 0 0 0 0 prl_tg
|
328
348
|
0028 1af41000 17 8201 ee000000 0 0 0 0 0 40 1000 0 0 0 0 0 virtio-pci
|
329
349
|
DEVICES
|
330
350
|
expect(File).to receive(:exists?).with("/proc/bus/pci/devices").and_return(true)
|
331
351
|
allow(File).to receive(:read).with("/proc/bus/pci/devices").and_return(devices)
|
332
|
-
|
333
|
-
expect(
|
334
|
-
expect(
|
335
|
-
expect(
|
352
|
+
plugin.run
|
353
|
+
expect(plugin[:virtualization][:system]).to eq("parallels")
|
354
|
+
expect(plugin[:virtualization][:role]).to eq("guest")
|
355
|
+
expect(plugin[:virtualization][:systems][:parallels]).to eq("guest")
|
336
356
|
end
|
337
357
|
|
338
|
-
it "
|
358
|
+
it "does not set virtualization if /proc/bus/pci/devices not contains 1ab84000" do
|
339
359
|
devices=<<-DEVICES
|
340
360
|
0030 1af41000 a 8401 ee040000 0 0 0 0 0 40 1000 0 0 0 0 0 virtio-pci
|
341
361
|
0050 10110022 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
342
362
|
DEVICES
|
343
363
|
expect(File).to receive(:exists?).with("/proc/bus/pci/devices").and_return(true)
|
344
364
|
allow(File).to receive(:read).with("/proc/bus/pci/devices").and_return(devices)
|
345
|
-
|
346
|
-
expect(
|
365
|
+
plugin.run
|
366
|
+
expect(plugin[:virtualization]).to eq({'systems' => {}})
|
347
367
|
end
|
348
368
|
end
|
349
369
|
|
350
370
|
describe "when we are checking for lxc" do
|
351
|
-
it "
|
371
|
+
it "sets lxc guest if /proc/self/cgroup exist and there are /lxc/<hexadecimal> mounts" do
|
352
372
|
self_cgroup=<<-CGROUP
|
353
373
|
8:blkio:/lxc/baa660ed81bc81d262ac6e19486142aeec5fce2043e2a173eb2505c6fbed89bc
|
354
374
|
7:net_cls:/lxc/baa660ed81bc81d262ac6e19486142aeec5fce2043e2a173eb2505c6fbed89bc
|
@@ -361,13 +381,13 @@ OPENSTACK
|
|
361
381
|
CGROUP
|
362
382
|
expect(File).to receive(:exists?).with("/proc/self/cgroup").and_return(true)
|
363
383
|
allow(File).to receive(:read).with("/proc/self/cgroup").and_return(self_cgroup)
|
364
|
-
|
365
|
-
expect(
|
366
|
-
expect(
|
367
|
-
expect(
|
384
|
+
plugin.run
|
385
|
+
expect(plugin[:virtualization][:system]).to eq("lxc")
|
386
|
+
expect(plugin[:virtualization][:role]).to eq("guest")
|
387
|
+
expect(plugin[:virtualization][:systems][:lxc]).to eq("guest")
|
368
388
|
end
|
369
389
|
|
370
|
-
it "
|
390
|
+
it "sets lxc guest if /proc/self/cgroup exist and there are /lxc/<name> mounts" do
|
371
391
|
self_cgroup=<<-CGROUP
|
372
392
|
8:blkio:/lxc/vanilla
|
373
393
|
7:net_cls:/lxc/vanilla
|
@@ -380,13 +400,13 @@ CGROUP
|
|
380
400
|
CGROUP
|
381
401
|
expect(File).to receive(:exists?).with("/proc/self/cgroup").and_return(true)
|
382
402
|
allow(File).to receive(:read).with("/proc/self/cgroup").and_return(self_cgroup)
|
383
|
-
|
384
|
-
expect(
|
385
|
-
expect(
|
386
|
-
expect(
|
403
|
+
plugin.run
|
404
|
+
expect(plugin[:virtualization][:system]).to eq("lxc")
|
405
|
+
expect(plugin[:virtualization][:role]).to eq("guest")
|
406
|
+
expect(plugin[:virtualization][:systems][:lxc]).to eq("guest")
|
387
407
|
end
|
388
408
|
|
389
|
-
it "
|
409
|
+
it "sets not set anything if /proc/self/cgroup exist and the cgroup is named arbitrarily, it isn't necessarily lxc." do
|
390
410
|
self_cgroup=<<-CGROUP
|
391
411
|
8:blkio:/Charlie
|
392
412
|
7:net_cls:/Charlie
|
@@ -399,8 +419,8 @@ CGROUP
|
|
399
419
|
CGROUP
|
400
420
|
expect(File).to receive(:exists?).with("/proc/self/cgroup").and_return(true)
|
401
421
|
allow(File).to receive(:read).with("/proc/self/cgroup").and_return(self_cgroup)
|
402
|
-
|
403
|
-
expect(
|
422
|
+
plugin.run
|
423
|
+
expect(plugin[:virtualization]).to eq({'systems' => {}})
|
404
424
|
end
|
405
425
|
|
406
426
|
context "/proc/self/cgroup only has / mounts" do
|
@@ -420,42 +440,42 @@ CGROUP
|
|
420
440
|
end
|
421
441
|
|
422
442
|
it "sets lxc host if lxc-version exists" do
|
423
|
-
allow(
|
424
|
-
|
425
|
-
expect(
|
426
|
-
expect(
|
427
|
-
expect(
|
443
|
+
allow(plugin).to receive(:lxc_version_exists?).and_return("/usr/bin/lxc-version")
|
444
|
+
plugin.run
|
445
|
+
expect(plugin[:virtualization][:system]).to eq("lxc")
|
446
|
+
expect(plugin[:virtualization][:role]).to eq("host")
|
447
|
+
expect(plugin[:virtualization][:systems][:lxc]).to eq("host")
|
428
448
|
end
|
429
449
|
|
430
450
|
it "does not set the old virtualization attributes if they are already set" do
|
431
|
-
allow(
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
expect(
|
437
|
-
expect(
|
451
|
+
allow(plugin).to receive(:lxc_version_exists?).and_return("/usr/bin/lxc-version")
|
452
|
+
plugin[:virtualization] = Mash.new
|
453
|
+
plugin[:virtualization][:system] = "the cloud"
|
454
|
+
plugin[:virtualization][:role] = "cumulonimbus"
|
455
|
+
plugin.run
|
456
|
+
expect(plugin[:virtualization][:system]).not_to eq("lxc")
|
457
|
+
expect(plugin[:virtualization][:role]).not_to eq("host")
|
438
458
|
end
|
439
459
|
|
440
460
|
it "does not set lxc host if lxc-version does not exist" do
|
441
|
-
allow(
|
442
|
-
|
443
|
-
expect(
|
444
|
-
expect(
|
445
|
-
expect(
|
461
|
+
allow(plugin).to receive(:lxc_version_exists?).and_return(false)
|
462
|
+
plugin.run
|
463
|
+
expect(plugin[:virtualization][:system]).to be_nil
|
464
|
+
expect(plugin[:virtualization][:role]).to be_nil
|
465
|
+
expect(plugin[:virtualization]).to eq({'systems' => {}})
|
446
466
|
end
|
447
467
|
|
448
468
|
end
|
449
469
|
|
450
|
-
it "
|
470
|
+
it "does not set virtualization if /proc/self/cgroup isn't there" do
|
451
471
|
expect(File).to receive(:exists?).with("/proc/self/cgroup").and_return(false)
|
452
|
-
|
453
|
-
expect(
|
472
|
+
plugin.run
|
473
|
+
expect(plugin[:virtualization]).to eq({'systems' => {}})
|
454
474
|
end
|
455
475
|
end
|
456
476
|
|
457
477
|
describe "when we are checking for docker" do
|
458
|
-
it "
|
478
|
+
it "sets docker guest if /proc/self/cgroup exist and there are /docker/<hexadecimal> mounts" do
|
459
479
|
self_cgroup=<<-CGROUP
|
460
480
|
8:blkio:/docker/baa660ed81bc81d262ac6e19486142aeec5fce2043e2a173eb2505c6fbed89bc
|
461
481
|
7:net_cls:/docker/baa660ed81bc81d262ac6e19486142aeec5fce2043e2a173eb2505c6fbed89bc
|
@@ -468,13 +488,13 @@ CGROUP
|
|
468
488
|
CGROUP
|
469
489
|
allow(File).to receive(:exists?).with("/proc/self/cgroup").and_return(true)
|
470
490
|
allow(File).to receive(:read).with("/proc/self/cgroup").and_return(self_cgroup)
|
471
|
-
|
472
|
-
expect(
|
473
|
-
expect(
|
474
|
-
expect(
|
491
|
+
plugin.run
|
492
|
+
expect(plugin[:virtualization][:system]).to eq("docker")
|
493
|
+
expect(plugin[:virtualization][:role]).to eq("guest")
|
494
|
+
expect(plugin[:virtualization][:systems][:docker]).to eq("guest")
|
475
495
|
end
|
476
496
|
|
477
|
-
it "
|
497
|
+
it "sets docker guest if /proc/self/cgroup exist and there are /docker/<name> mounts" do
|
478
498
|
self_cgroup=<<-CGROUP
|
479
499
|
8:blkio:/docker/vanilla
|
480
500
|
7:net_cls:/docker/vanilla
|
@@ -487,13 +507,13 @@ CGROUP
|
|
487
507
|
CGROUP
|
488
508
|
allow(File).to receive(:exists?).with("/proc/self/cgroup").and_return(true)
|
489
509
|
allow(File).to receive(:read).with("/proc/self/cgroup").and_return(self_cgroup)
|
490
|
-
|
491
|
-
expect(
|
492
|
-
expect(
|
493
|
-
expect(
|
510
|
+
plugin.run
|
511
|
+
expect(plugin[:virtualization][:system]).to eq("docker")
|
512
|
+
expect(plugin[:virtualization][:role]).to eq("guest")
|
513
|
+
expect(plugin[:virtualization][:systems][:docker]).to eq("guest")
|
494
514
|
end
|
495
515
|
|
496
|
-
it "
|
516
|
+
it "sets not set anything if /proc/self/cgroup exist and the cgroup is named arbitrarily, it isn't necessarily lxc." do
|
497
517
|
self_cgroup=<<-CGROUP
|
498
518
|
8:blkio:/Charlie
|
499
519
|
7:net_cls:/Charlie
|
@@ -506,8 +526,8 @@ CGROUP
|
|
506
526
|
CGROUP
|
507
527
|
allow(File).to receive(:exists?).with("/proc/self/cgroup").and_return(true)
|
508
528
|
allow(File).to receive(:read).with("/proc/self/cgroup").and_return(self_cgroup)
|
509
|
-
|
510
|
-
expect(
|
529
|
+
plugin.run
|
530
|
+
expect(plugin[:virtualization]).to eq({'systems' => {}})
|
511
531
|
end
|
512
532
|
|
513
533
|
context "/proc/self/cgroup only has / mounts" do
|
@@ -524,63 +544,63 @@ CGROUP
|
|
524
544
|
CGROUP
|
525
545
|
allow(File).to receive(:exists?).with("/proc/self/cgroup").and_return(true)
|
526
546
|
allow(File).to receive(:read).with("/proc/self/cgroup").and_return(self_cgroup)
|
527
|
-
|
528
|
-
expect(
|
547
|
+
plugin.run
|
548
|
+
expect(plugin[:virtualization]).to eq({'systems' => {}})
|
529
549
|
end
|
530
550
|
|
531
551
|
end
|
532
552
|
|
533
553
|
it "does not set the old virtualization attributes if they are already set" do
|
534
|
-
allow(
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
expect(
|
540
|
-
expect(
|
554
|
+
allow(plugin).to receive(:docker_exists?).and_return("/usr/bin/docker")
|
555
|
+
plugin[:virtualization] = Mash.new
|
556
|
+
plugin[:virtualization][:system] = "the cloud"
|
557
|
+
plugin[:virtualization][:role] = "cumulonimbus"
|
558
|
+
plugin.run
|
559
|
+
expect(plugin[:virtualization][:system]).not_to eq("docker")
|
560
|
+
expect(plugin[:virtualization][:role]).not_to eq("host")
|
541
561
|
end
|
542
562
|
|
543
563
|
it "does not set docker host if docker does not exist" do
|
544
|
-
allow(
|
545
|
-
|
546
|
-
expect(
|
547
|
-
expect(
|
548
|
-
expect(
|
564
|
+
allow(plugin).to receive(:docker_exists?).and_return(false)
|
565
|
+
plugin.run
|
566
|
+
expect(plugin[:virtualization][:system]).to be_nil
|
567
|
+
expect(plugin[:virtualization][:role]).to be_nil
|
568
|
+
expect(plugin[:virtualization]).to eq({'systems' => {}})
|
549
569
|
end
|
550
570
|
|
551
|
-
it "
|
571
|
+
it "does not set virtualization if /proc/self/cgroup isn't there" do
|
552
572
|
allow(File).to receive(:exists?).with("/proc/self/cgroup").and_return(false)
|
553
|
-
|
554
|
-
expect(
|
573
|
+
plugin.run
|
574
|
+
expect(plugin[:virtualization]).to eq({'systems' => {}})
|
555
575
|
end
|
556
576
|
|
557
|
-
it "
|
577
|
+
it "sets virtualization if /.dockerenv exists" do
|
558
578
|
allow(File).to receive(:exists?).with("/.dockerenv").and_return(true)
|
559
|
-
|
560
|
-
expect(
|
561
|
-
expect(
|
562
|
-
expect(
|
579
|
+
plugin.run
|
580
|
+
expect(plugin[:virtualization][:system]).to eq("docker")
|
581
|
+
expect(plugin[:virtualization][:role]).to eq("guest")
|
582
|
+
expect(plugin[:virtualization][:systems][:docker]).to eq("guest")
|
563
583
|
end
|
564
584
|
|
565
|
-
it "
|
585
|
+
it "sets virtualization if /.dockerinit exists" do
|
566
586
|
allow(File).to receive(:exists?).with("/.dockerinit").and_return(true)
|
567
|
-
|
568
|
-
expect(
|
569
|
-
expect(
|
570
|
-
expect(
|
587
|
+
plugin.run
|
588
|
+
expect(plugin[:virtualization][:system]).to eq("docker")
|
589
|
+
expect(plugin[:virtualization][:role]).to eq("guest")
|
590
|
+
expect(plugin[:virtualization][:systems][:docker]).to eq("guest")
|
571
591
|
end
|
572
592
|
|
573
|
-
it "
|
593
|
+
it "does not set virtualization if /.dockerenv or /.dockerinit does not exists" do
|
574
594
|
allow(File).to receive(:exists?).with("/.dockerenv").and_return(false)
|
575
595
|
allow(File).to receive(:exists?).with("/.dockerinit").and_return(false)
|
576
|
-
|
577
|
-
expect(
|
596
|
+
plugin.run
|
597
|
+
expect(plugin[:virtualization]).to eq({'systems' => {}})
|
578
598
|
end
|
579
599
|
|
580
600
|
end
|
581
601
|
|
582
|
-
it "
|
583
|
-
|
584
|
-
expect(
|
602
|
+
it "does not set virtualization if no tests match" do
|
603
|
+
plugin.run
|
604
|
+
expect(plugin[:virtualization]).to eq({'systems' => {}})
|
585
605
|
end
|
586
606
|
end
|
data/spec/unit/system_spec.rb
CHANGED
@@ -96,8 +96,15 @@ describe "Ohai::System" do
|
|
96
96
|
end
|
97
97
|
|
98
98
|
it 'configures logging' do
|
99
|
+
log_level = :debug
|
100
|
+
Ohai.config[:log_level] = log_level
|
99
101
|
expect(Ohai::Log).to receive(:init).with(Ohai.config[:log_location])
|
100
|
-
expect(Ohai::Log).to receive(:level=).with(
|
102
|
+
expect(Ohai::Log).to receive(:level=).with(log_level)
|
103
|
+
Ohai::System.new
|
104
|
+
end
|
105
|
+
|
106
|
+
it 'resolves log_level when set to :auto' do
|
107
|
+
expect(Ohai::Log).to receive(:level=).with(:info)
|
101
108
|
Ohai::System.new
|
102
109
|
end
|
103
110
|
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.6.0.alpha.
|
4
|
+
version: 8.6.0.alpha.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Jacob
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07
|
11
|
+
date: 2015-08-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mime-types
|