ohai 7.0.4 → 7.2.0.alpha.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -28,6 +28,7 @@ describe Ohai::System, "Linux plugin platform" do
28
28
  File.stub(:exists?).with("/etc/debian_version").and_return(false)
29
29
  File.stub(:exists?).with("/etc/redhat-release").and_return(false)
30
30
  File.stub(:exists?).with("/etc/gentoo-release").and_return(false)
31
+ File.stub(:exists?).with("/etc/exherbo-release").and_return(false)
31
32
  File.stub(:exists?).with("/etc/SuSE-release").and_return(false)
32
33
  File.stub(:exists?).with("/etc/arch-release").and_return(false)
33
34
  File.stub(:exists?).with("/etc/system-release").and_return(false)
@@ -184,6 +185,19 @@ describe Ohai::System, "Linux plugin platform" do
184
185
  end
185
186
  end
186
187
 
188
+ describe "on exherbo" do
189
+ before(:each) do
190
+ @plugin.lsb = nil
191
+ File.should_receive(:exists?).with("/etc/exherbo-release").and_return(true)
192
+ end
193
+
194
+ it "should set platform and platform_family to exherbo" do
195
+ @plugin.run
196
+ @plugin[:platform].should == "exherbo"
197
+ @plugin[:platform_family].should == "exherbo"
198
+ end
199
+ end
200
+
187
201
  describe "on redhat breeds" do
188
202
  describe "with lsb_release results" do
189
203
  it "should set the platform to redhat and platform_family to rhel even if the LSB name is something absurd but redhat like" do
@@ -42,6 +42,7 @@ describe Ohai::System, "Linux virtualization platform" do
42
42
  @plugin.run
43
43
  @plugin[:virtualization][:system].should == "xen"
44
44
  @plugin[:virtualization][:role].should == "guest"
45
+ @plugin[:virtualization][:systems][:xen].should == "guest"
45
46
  end
46
47
 
47
48
  it "should set xen host if /proc/xen/capabilities contains control_d " do
@@ -51,6 +52,7 @@ describe Ohai::System, "Linux virtualization platform" do
51
52
  @plugin.run
52
53
  @plugin[:virtualization][:system].should == "xen"
53
54
  @plugin[:virtualization][:role].should == "host"
55
+ @plugin[:virtualization][:systems][:xen].should == "host"
54
56
  end
55
57
 
56
58
  it "should set xen guest if /proc/xen/capabilities exists but is empty" do
@@ -60,12 +62,13 @@ describe Ohai::System, "Linux virtualization platform" do
60
62
  @plugin.run
61
63
  @plugin[:virtualization][:system].should == "xen"
62
64
  @plugin[:virtualization][:role].should == "guest"
65
+ @plugin[:virtualization][:systems][:xen].should == "guest"
63
66
  end
64
67
 
65
68
  it "should not set virtualization if xen isn't there" do
66
69
  File.should_receive(:exists?).at_least(:once).and_return(false)
67
70
  @plugin.run
68
- @plugin[:virtualization].should == {}
71
+ @plugin[:virtualization].should == {'systems' => {}}
69
72
  end
70
73
  end
71
74
 
@@ -76,6 +79,7 @@ describe Ohai::System, "Linux virtualization platform" do
76
79
  @plugin.run
77
80
  @plugin[:virtualization][:system].should == "kvm"
78
81
  @plugin[:virtualization][:role].should == "host"
82
+ @plugin[:virtualization][:systems][:kvm].should == "host"
79
83
  end
80
84
 
81
85
  it "should set kvm guest if /proc/cpuinfo contains QEMU Virtual CPU" do
@@ -84,6 +88,7 @@ describe Ohai::System, "Linux virtualization platform" do
84
88
  @plugin.run
85
89
  @plugin[:virtualization][:system].should == "kvm"
86
90
  @plugin[:virtualization][:role].should == "guest"
91
+ @plugin[:virtualization][:systems][:kvm].should == "guest"
87
92
  end
88
93
 
89
94
  it "should set kvm guest if /proc/cpuinfo contains Common KVM processor" do
@@ -92,6 +97,7 @@ describe Ohai::System, "Linux virtualization platform" do
92
97
  @plugin.run
93
98
  @plugin[:virtualization][:system].should == "kvm"
94
99
  @plugin[:virtualization][:role].should == "guest"
100
+ @plugin[:virtualization][:systems][:kvm].should == "guest"
95
101
  end
96
102
 
97
103
  it "should set kvm guest if /proc/cpuinfo contains Common 32-bit KVM processor" do
@@ -100,12 +106,13 @@ describe Ohai::System, "Linux virtualization platform" do
100
106
  @plugin.run
101
107
  @plugin[:virtualization][:system].should == "kvm"
102
108
  @plugin[:virtualization][:role].should == "guest"
109
+ @plugin[:virtualization][:systems][:kvm].should == "guest"
103
110
  end
104
111
 
105
112
  it "should not set virtualization if kvm isn't there" do
106
113
  File.should_receive(:exists?).at_least(:once).and_return(false)
107
114
  @plugin.run
108
- @plugin[:virtualization].should == {}
115
+ @plugin[:virtualization].should == {'systems' => {}}
109
116
  end
110
117
  end
111
118
 
@@ -116,6 +123,7 @@ describe Ohai::System, "Linux virtualization platform" do
116
123
  @plugin.run
117
124
  @plugin[:virtualization][:system].should == "vbox"
118
125
  @plugin[:virtualization][:role].should == "host"
126
+ @plugin[:virtualization][:systems][:vbox].should == "host"
119
127
  end
120
128
 
121
129
  it "should set vbox gues if /proc/modules contains vboxguest" do
@@ -124,12 +132,13 @@ describe Ohai::System, "Linux virtualization platform" do
124
132
  @plugin.run
125
133
  @plugin[:virtualization][:system].should == "vbox"
126
134
  @plugin[:virtualization][:role].should == "guest"
135
+ @plugin[:virtualization][:systems][:vbox].should == "guest"
127
136
  end
128
137
 
129
138
  it "should not set virtualization if vbox isn't there" do
130
139
  File.should_receive(:exists?).at_least(:once).and_return(false)
131
140
  @plugin.run
132
- @plugin[:virtualization].should == {}
141
+ @plugin[:virtualization].should == {'systems' => {}}
133
142
  end
134
143
  end
135
144
 
@@ -152,6 +161,7 @@ MSVPC
152
161
  @plugin.run
153
162
  @plugin[:virtualization][:system].should == "virtualpc"
154
163
  @plugin[:virtualization][:role].should == "guest"
164
+ @plugin[:virtualization][:systems][:virtualpc].should == "guest"
155
165
  end
156
166
 
157
167
  it "should set vmware guest if dmidecode detects VMware Virtual Platform" do
@@ -170,6 +180,7 @@ VMWARE
170
180
  @plugin.run
171
181
  @plugin[:virtualization][:system].should == "vmware"
172
182
  @plugin[:virtualization][:role].should == "guest"
183
+ @plugin[:virtualization][:systems][:vmware].should == "guest"
173
184
  end
174
185
 
175
186
  it "should set vbox guest if dmidecode detects Oracle Corporation" do
@@ -190,12 +201,13 @@ VBOX
190
201
  @plugin.run
191
202
  @plugin[:virtualization][:system].should == "vbox"
192
203
  @plugin[:virtualization][:role].should == "guest"
204
+ @plugin[:virtualization][:systems][:vbox].should == "guest"
193
205
  end
194
206
 
195
207
  it "should run dmidecode and not set virtualization if nothing is detected" do
196
208
  @plugin.stub(:shell_out).with("dmidecode").and_return(mock_shell_out(0, "", ""))
197
209
  @plugin.run
198
- @plugin[:virtualization].should == {}
210
+ @plugin[:virtualization].should == {'systems' => {}}
199
211
  end
200
212
  end
201
213
 
@@ -206,6 +218,7 @@ VBOX
206
218
  @plugin.run
207
219
  @plugin[:virtualization][:system].should == "linux-vserver"
208
220
  @plugin[:virtualization][:role].should == "host"
221
+ @plugin[:virtualization][:systems]['linux-vserver'].should == "host"
209
222
  end
210
223
 
211
224
  it "should set Linux-VServer host if /proc/self/status contains VxID: 0" do
@@ -214,6 +227,7 @@ VBOX
214
227
  @plugin.run
215
228
  @plugin[:virtualization][:system].should == "linux-vserver"
216
229
  @plugin[:virtualization][:role].should == "host"
230
+ @plugin[:virtualization][:systems]['linux-vserver'].should == "host"
217
231
  end
218
232
 
219
233
  it "should set Linux-VServer guest if /proc/self/status contains s_context > 0" do
@@ -222,6 +236,7 @@ VBOX
222
236
  @plugin.run
223
237
  @plugin[:virtualization][:system].should == "linux-vserver"
224
238
  @plugin[:virtualization][:role].should == "guest"
239
+ @plugin[:virtualization][:systems]['linux-vserver'].should == "guest"
225
240
  end
226
241
 
227
242
  it "should set Linux-VServer guest if /proc/self/status contains VxID > 0" do
@@ -230,12 +245,13 @@ VBOX
230
245
  @plugin.run
231
246
  @plugin[:virtualization][:system].should == "linux-vserver"
232
247
  @plugin[:virtualization][:role].should == "guest"
248
+ @plugin[:virtualization][:systems]['linux-vserver'].should == "guest"
233
249
  end
234
250
 
235
251
  it "should not set virtualization if Linux-VServer isn't there" do
236
252
  File.should_receive(:exists?).at_least(:once).and_return(false)
237
253
  @plugin.run
238
- @plugin[:virtualization].should == {}
254
+ @plugin[:virtualization].should == {'systems' => {}}
239
255
  end
240
256
  end
241
257
 
@@ -245,6 +261,7 @@ VBOX
245
261
  @plugin.run
246
262
  @plugin[:virtualization][:system].should == "openvz"
247
263
  @plugin[:virtualization][:role].should == "host"
264
+ @plugin[:virtualization][:systems][:openvz].should == "host"
248
265
  end
249
266
 
250
267
  it "should set openvz guest if /proc/bc/0 doesn't exist and /proc/vz exists" do
@@ -253,13 +270,14 @@ VBOX
253
270
  @plugin.run
254
271
  @plugin[:virtualization][:system].should == "openvz"
255
272
  @plugin[:virtualization][:role].should == "guest"
273
+ @plugin[:virtualization][:systems][:openvz].should == "guest"
256
274
  end
257
275
 
258
276
  it "should not set virtualization if openvz isn't there" do
259
277
  File.should_receive(:exists?).with("/proc/bc/0").and_return(false)
260
278
  File.should_receive(:exists?).with("/proc/vz").and_return(false)
261
279
  @plugin.run
262
- @plugin[:virtualization].should == {}
280
+ @plugin[:virtualization].should == {'systems' => {}}
263
281
  end
264
282
  end
265
283
 
@@ -280,6 +298,7 @@ CGROUP
280
298
  @plugin.run
281
299
  @plugin[:virtualization][:system].should == "lxc"
282
300
  @plugin[:virtualization][:role].should == "guest"
301
+ @plugin[:virtualization][:systems][:lxc].should == "guest"
283
302
  end
284
303
 
285
304
  it "should set lxc guest if /proc/self/cgroup exist and there are /lxc/<name> mounts" do
@@ -298,6 +317,7 @@ CGROUP
298
317
  @plugin.run
299
318
  @plugin[:virtualization][:system].should == "lxc"
300
319
  @plugin[:virtualization][:role].should == "guest"
320
+ @plugin[:virtualization][:systems][:lxc].should == "guest"
301
321
  end
302
322
 
303
323
  it "should set lxc guest if /proc/self/cgroup exist and there are /docker/<name> mounts" do
@@ -318,6 +338,7 @@ CGROUP
318
338
  @plugin.run
319
339
  @plugin[:virtualization][:system].should == "lxc"
320
340
  @plugin[:virtualization][:role].should == "guest"
341
+ @plugin[:virtualization][:systems][:lxc].should == "guest"
321
342
  end
322
343
 
323
344
  it "should set not set anything if /proc/self/cgroup exist and the cgroup is named arbitrarily, it isn't necessarily lxc." do
@@ -334,11 +355,12 @@ CGROUP
334
355
  File.should_receive(:exists?).with("/proc/self/cgroup").and_return(true)
335
356
  File.stub(:read).with("/proc/self/cgroup").and_return(self_cgroup)
336
357
  @plugin.run
337
- @plugin[:virtualization].should == {}
358
+ @plugin[:virtualization].should == {'systems' => {}}
338
359
  end
339
360
 
340
- it "should set lxc host if /proc/self/cgroup only has / mounts" do
341
- self_cgroup=<<-CGROUP
361
+ context "/proc/self/cgroup only has / mounts" do
362
+ before(:each) do
363
+ self_cgroup=<<-CGROUP
342
364
  8:blkio:/
343
365
  7:net_cls:/
344
366
  6:freezer:/
@@ -348,22 +370,47 @@ CGROUP
348
370
  2:cpu:/
349
371
  1:cpuset:/
350
372
  CGROUP
351
- File.should_receive(:exists?).with("/proc/self/cgroup").and_return(true)
352
- File.stub(:read).with("/proc/self/cgroup").and_return(self_cgroup)
353
- @plugin.run
354
- @plugin[:virtualization][:system].should == "lxc"
355
- @plugin[:virtualization][:role].should == "host"
373
+ File.should_receive(:exists?).with("/proc/self/cgroup").and_return(true)
374
+ File.stub(:read).with("/proc/self/cgroup").and_return(self_cgroup)
375
+ end
376
+
377
+ it "sets lxc host if lxc-version exists" do
378
+ @plugin.stub(:lxc_version_exists?).and_return("/usr/bin/lxc-version")
379
+ @plugin.run
380
+ @plugin[:virtualization][:system].should == "lxc"
381
+ @plugin[:virtualization][:role].should == "host"
382
+ @plugin[:virtualization][:systems][:lxc].should == "host"
383
+ end
384
+
385
+ it "does not set the old virtualization attributes if they are already set" do
386
+ @plugin.stub(:lxc_version_exists?).and_return("/usr/bin/lxc-version")
387
+ @plugin[:virtualization] = Mash.new
388
+ @plugin[:virtualization][:system] = "the cloud"
389
+ @plugin[:virtualization][:role] = "cumulonimbus"
390
+ @plugin.run
391
+ @plugin[:virtualization][:system].should_not == "lxc"
392
+ @plugin[:virtualization][:role].should_not == "host"
393
+ end
394
+
395
+ it "does not set lxc host if lxc-version does not exist" do
396
+ @plugin.stub(:lxc_version_exists?).and_return(false)
397
+ @plugin.run
398
+ @plugin[:virtualization][:system].should be_nil
399
+ @plugin[:virtualization][:role].should be_nil
400
+ @plugin[:virtualization].should == {'systems' => {}}
401
+ end
402
+
356
403
  end
357
404
 
358
405
  it "should not set virtualization if /proc/self/cgroup isn't there" do
359
406
  File.should_receive(:exists?).with("/proc/self/cgroup").and_return(false)
360
407
  @plugin.run
361
- @plugin[:virtualization].should == {}
408
+ @plugin[:virtualization].should == {'systems' => {}}
362
409
  end
363
410
  end
364
411
 
365
412
  it "should not set virtualization if no tests match" do
366
413
  @plugin.run
367
- @plugin[:virtualization].should == {}
414
+ @plugin[:virtualization].should == {'systems' => {}}
368
415
  end
369
416
  end
@@ -16,6 +16,13 @@ describe Ohai::System, "plugin etc" do
16
16
  @plugin[:etc][:passwd]['www'].should == Mash.new(:shell => '/bin/false', :gecos => 'Serving the web since 1970', :gid => 800, :uid => 800, :dir => '/var/www')
17
17
  end
18
18
 
19
+ it "should ignore duplicate users" do
20
+ Etc.should_receive(:passwd).and_yield(PasswdEntry.new("root", 1, 1, '/root', '/bin/zsh', 'BOFH')).
21
+ and_yield(PasswdEntry.new('root', 1, 1, '/', '/bin/false', 'I do not belong'))
22
+ @plugin.run
23
+ @plugin[:etc][:passwd]['root'].should == Mash.new(:shell => '/bin/zsh', :gecos => 'BOFH', :gid => 1, :uid => 1, :dir => '/root')
24
+ end
25
+
19
26
  it "should set the current user" do
20
27
  Etc.should_receive(:getlogin).and_return('chef')
21
28
  @plugin.run
@@ -65,4 +65,44 @@ UNAME_X
65
65
 
66
66
  end
67
67
 
68
+ describe "on Solaris 11" do
69
+ before(:each) do
70
+ @uname_x = <<-UNAME_X
71
+ System = SunOS
72
+ Node = node.example.com
73
+ Release = 5.11
74
+ KernelID = 11.1
75
+ Machine = i86pc
76
+ BusType = <unknown>
77
+ Serial = <unknown>
78
+ Users = <unknown>
79
+ OEM# = 0
80
+ Origin# = 1
81
+ NumCPU = 1
82
+ UNAME_X
83
+
84
+ File.stub(:exists?).with("/sbin/uname").and_return(true)
85
+ @plugin.stub(:shell_out).with("/sbin/uname -X").and_return(mock_shell_out(0, @uname_x, ""))
86
+
87
+ @release = StringIO.new(" Oracle Solaris 11.1 X86\n")
88
+ File.stub(:open).with("/etc/release").and_yield(@release)
89
+ end
90
+
91
+ it "should run uname and set platform and build" do
92
+ @plugin.run
93
+ @plugin[:platform_build].should == "11.1"
94
+ end
95
+
96
+ it "should set the platform" do
97
+ @plugin.run
98
+ @plugin[:platform].should == "solaris2"
99
+ end
100
+
101
+ it "should set the platform_version" do
102
+ @plugin.run
103
+ @plugin[:platform_version].should == "5.11"
104
+ end
105
+
106
+ end
107
+
68
108
  end
@@ -0,0 +1,45 @@
1
+ # Author:: Bryan McLellan <btm@loftninjas.org>
2
+ #
3
+ # Copyright:: Copyright (c) 2014 Chef Software, Inc.
4
+ #
5
+ # License:: Apache License, Version 2.0
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+
19
+ require 'spec_helper'
20
+ require 'ohai/util/file_helper'
21
+
22
+ class FileHelperMock
23
+ include Ohai::Util::FileHelper
24
+ end
25
+
26
+
27
+ describe "Ohai::Util::FileHelper" do
28
+ let(:file_helper) { FileHelperMock.new }
29
+
30
+ before(:each) do
31
+ File.stub(:executable?).and_return(false)
32
+ end
33
+
34
+ describe "which" do
35
+ it "returns the path to an executable that is in the path" do
36
+ File.stub(:executable?).with('/usr/bin/skyhawk').and_return(true)
37
+
38
+ expect(file_helper.which('skyhawk')).to eql "/usr/bin/skyhawk"
39
+ end
40
+
41
+ it "returns false if the executable is not in the path" do
42
+ expect(file_helper.which('the_cake')).to be_false
43
+ end
44
+ end
45
+ 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: 7.0.4
4
+ version: 7.2.0.alpha.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Jacob
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-30 00:00:00.000000000 Z
11
+ date: 2014-05-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mime-types
@@ -122,6 +122,20 @@ dependencies:
122
122
  - - ">="
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: wmi-lite
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '1.0'
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '1.0'
125
139
  - !ruby/object:Gem::Dependency
126
140
  name: rake
127
141
  requirement: !ruby/object:Gem::Requirement
@@ -214,7 +228,7 @@ extensions: []
214
228
  extra_rdoc_files: []
215
229
  files:
216
230
  - LICENSE
217
- - README.rdoc
231
+ - README.md
218
232
  - Rakefile
219
233
  - bin/ohai
220
234
  - docs/man/man1/ohai.1
@@ -282,6 +296,7 @@ files:
282
296
  - lib/ohai/plugins/linux/cpu.rb
283
297
  - lib/ohai/plugins/linux/filesystem.rb
284
298
  - lib/ohai/plugins/linux/lsb.rb
299
+ - lib/ohai/plugins/linux/mdadm.rb
285
300
  - lib/ohai/plugins/linux/memory.rb
286
301
  - lib/ohai/plugins/linux/network.rb
287
302
  - lib/ohai/plugins/linux/platform.rb
@@ -340,6 +355,7 @@ files:
340
355
  - lib/ohai/provides_map.rb
341
356
  - lib/ohai/runner.rb
342
357
  - lib/ohai/system.rb
358
+ - lib/ohai/util/file_helper.rb
343
359
  - lib/ohai/version.rb
344
360
  - spec/data/plugins/___lib64___libc.so.6.output
345
361
  - spec/data/plugins/___lib___libc.so.6.output
@@ -397,6 +413,7 @@ files:
397
413
  - spec/unit/plugins/erlang_spec.rb
398
414
  - spec/unit/plugins/eucalyptus_spec.rb
399
415
  - spec/unit/plugins/fail_spec.rb
416
+ - spec/unit/plugins/freebsd/cpu_spec.rb
400
417
  - spec/unit/plugins/freebsd/hostname_spec.rb
401
418
  - spec/unit/plugins/freebsd/kernel_spec.rb
402
419
  - spec/unit/plugins/freebsd/os_spec.rb
@@ -415,6 +432,7 @@ files:
415
432
  - spec/unit/plugins/linux/hostname_spec.rb
416
433
  - spec/unit/plugins/linux/kernel_spec.rb
417
434
  - spec/unit/plugins/linux/lsb_spec.rb
435
+ - spec/unit/plugins/linux/mdadm_spec.rb
418
436
  - spec/unit/plugins/linux/network_spec.rb
419
437
  - spec/unit/plugins/linux/platform_spec.rb
420
438
  - spec/unit/plugins/linux/uptime_spec.rb
@@ -453,6 +471,7 @@ files:
453
471
  - spec/unit/provides_map_spec.rb
454
472
  - spec/unit/runner_spec.rb
455
473
  - spec/unit/system_spec.rb
474
+ - spec/unit/util/file_helper_spec.rb
456
475
  homepage: http://wiki.opscode.com/display/chef/Ohai
457
476
  licenses: []
458
477
  metadata: {}
@@ -467,9 +486,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
467
486
  version: '0'
468
487
  required_rubygems_version: !ruby/object:Gem::Requirement
469
488
  requirements:
470
- - - ">="
489
+ - - ">"
471
490
  - !ruby/object:Gem::Version
472
- version: '0'
491
+ version: 1.3.1
473
492
  requirements: []
474
493
  rubyforge_project:
475
494
  rubygems_version: 2.2.2