ohai 8.7.0 → 8.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +4 -3
  3. data/lib/ohai/application.rb +3 -1
  4. data/lib/ohai/loader.rb +4 -3
  5. data/lib/ohai/mixin/dmi_decode.rb +47 -0
  6. data/lib/ohai/mixin/os.rb +2 -0
  7. data/lib/ohai/plugins/aix/kernel.rb +2 -1
  8. data/lib/ohai/plugins/{freebsd → bsd}/filesystem.rb +21 -3
  9. data/lib/ohai/plugins/bsd/virtualization.rb +80 -0
  10. data/lib/ohai/plugins/dragonflybsd/cpu.rb +58 -0
  11. data/lib/ohai/plugins/dragonflybsd/memory.rb +60 -0
  12. data/lib/ohai/plugins/dragonflybsd/network.rb +126 -0
  13. data/lib/ohai/plugins/dragonflybsd/os.rb +32 -0
  14. data/lib/ohai/plugins/dragonflybsd/platform.rb +29 -0
  15. data/lib/ohai/plugins/freebsd/cpu.rb +14 -8
  16. data/lib/ohai/plugins/freebsd/os.rb +1 -1
  17. data/lib/ohai/plugins/hostname.rb +1 -1
  18. data/lib/ohai/plugins/kernel.rb +12 -0
  19. data/lib/ohai/plugins/linux/virtualization.rb +8 -37
  20. data/lib/ohai/plugins/network_listeners.rb +5 -0
  21. data/lib/ohai/plugins/ps.rb +2 -2
  22. data/lib/ohai/plugins/solaris2/filesystem.rb +9 -1
  23. data/lib/ohai/plugins/uptime.rb +1 -1
  24. data/lib/ohai/plugins/virtualbox.rb +44 -0
  25. data/lib/ohai/plugins/windows/cpu.rb +26 -27
  26. data/lib/ohai/plugins/windows/virtualization.rb +29 -17
  27. data/lib/ohai/system.rb +1 -1
  28. data/lib/ohai/version.rb +1 -1
  29. data/ohai.gemspec +50 -0
  30. data/spec/functional/loader_spec.rb +53 -0
  31. data/spec/unit/loader_spec.rb +51 -53
  32. data/spec/unit/plugins/aix/kernel_spec.rb +5 -0
  33. data/spec/unit/plugins/bsd/filesystem_spec.rb +126 -0
  34. data/spec/unit/plugins/{freebsd → bsd}/virtualization_spec.rb +7 -4
  35. data/spec/unit/plugins/freebsd/cpu_spec.rb +60 -14
  36. data/spec/unit/plugins/linux/virtualization_spec.rb +58 -5
  37. data/spec/unit/plugins/solaris2/filesystem.rb +84 -0
  38. data/spec/unit/plugins/virtualbox_spec.rb +88 -0
  39. data/spec/unit/plugins/windows/cpu_spec.rb +3 -1
  40. data/spec/unit/plugins/windows/virtualization_spec.rb +182 -32
  41. metadata +21 -26
  42. data/lib/ohai/plugins/freebsd/virtualization.rb +0 -94
  43. data/lib/ohai/plugins/netbsd/filesystem.rb +0 -57
  44. data/lib/ohai/plugins/netbsd/virtualization.rb +0 -68
  45. data/lib/ohai/plugins/openbsd/filesystem.rb +0 -57
  46. data/lib/ohai/plugins/openbsd/virtualization.rb +0 -68
@@ -18,9 +18,9 @@
18
18
 
19
19
  require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
20
20
 
21
- describe Ohai::System, "FreeBSD virtualization plugin" do
21
+ describe Ohai::System, "BSD virtualization plugin" do
22
22
  before(:each) do
23
- @plugin = get_plugin("freebsd/virtualization")
23
+ @plugin = get_plugin("bsd/virtualization")
24
24
  allow(@plugin).to receive(:collect_os).and_return(:freebsd)
25
25
  allow(@plugin).to receive(:shell_out).with("sysctl -n security.jail.jailed").and_return(mock_shell_out(0, "0", ""))
26
26
  allow(@plugin).to receive(:shell_out).with("#{ Ohai.abs_path( "/sbin/kldstat" )}").and_return(mock_shell_out(0, "", ""))
@@ -34,6 +34,7 @@ describe Ohai::System, "FreeBSD virtualization plugin" do
34
34
  @plugin.run
35
35
  expect(@plugin[:virtualization][:system]).to eq("jail")
36
36
  expect(@plugin[:virtualization][:role]).to eq("guest")
37
+ expect(@plugin[:virtualization][:systems][:jail]).to eq("guest")
37
38
  end
38
39
 
39
40
  it "detects we are hosting jails" do
@@ -43,6 +44,7 @@ describe Ohai::System, "FreeBSD virtualization plugin" do
43
44
  @plugin.run
44
45
  expect(@plugin[:virtualization][:system]).to eq("jail")
45
46
  expect(@plugin[:virtualization][:role]).to eq("host")
47
+ expect(@plugin[:virtualization][:systems][:jail]).to eq("host")
46
48
  end
47
49
  end
48
50
 
@@ -60,6 +62,7 @@ OUT
60
62
  @plugin.run
61
63
  expect(@plugin[:virtualization][:system]).to eq("vbox")
62
64
  expect(@plugin[:virtualization][:role]).to eq("guest")
65
+ expect(@plugin[:virtualization][:systems][:vbox]).to eq("guest")
63
66
  end
64
67
  end
65
68
 
@@ -77,6 +80,7 @@ OUT
77
80
  @plugin.run
78
81
  expect(@plugin[:virtualization][:system]).to eq("vbox")
79
82
  expect(@plugin[:virtualization][:role]).to eq("host")
83
+ expect(@plugin[:virtualization][:systems][:vbox]).to eq("host")
80
84
  end
81
85
  end
82
86
 
@@ -87,9 +91,8 @@ OUT
87
91
  @plugin.run
88
92
  expect(@plugin[:virtualization][:system]).to eq("kvm")
89
93
  expect(@plugin[:virtualization][:role]).to eq("guest")
94
+ expect(@plugin[:virtualization][:systems][:kvm]).to eq("guest")
90
95
  end
91
96
  end
92
97
  end
93
-
94
- # TODO upfactor tests from linux virtualization plugin for dmidecode
95
98
  end
@@ -18,51 +18,97 @@
18
18
 
19
19
  require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
20
20
 
21
- describe Ohai::System, "FreeBSD cpu plugin" do
21
+ describe Ohai::System, "FreeBSD cpu plugin on FreeBSD >=10.2" do
22
22
  before(:each) do
23
23
  @plugin = get_plugin("freebsd/cpu")
24
24
  allow(@plugin).to receive(:collect_os).and_return(:freebsd)
25
25
  allow(@plugin).to receive(:shell_out).with("sysctl -n hw.ncpu").and_return(mock_shell_out(0, "2", ""))
26
26
  @double_file = double("/var/run/dmesg.boot")
27
27
  allow(@double_file).to receive(:each).
28
- and_yield('CPU: Intel(R) Core(TM) i7-3615QM CPU @ 2.30GHz (3516.61-MHz K8-class CPU)').
29
- and_yield(' Origin = "GenuineIntel" Id = 0x306a9 Family = 6 Model = 3a Stepping = 9').
28
+ and_yield('CPU: Intel(R) Core(TM) i7-4980HQ CPU @ 2.80GHz (2793.59-MHz K8-class CPU)').
29
+ and_yield(' Origin="GenuineIntel" Id=0x40661 Family=0x6 Model=0x46 Stepping=1').
30
30
  and_yield(' Features=0x783fbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,MMX,FXSR,SSE,SSE2>').
31
- and_yield(' Features2=0x209<SSE3,MON,SSSE3>').
31
+ and_yield(' Features2=0x5ed8220b<SSE3,PCLMULQDQ,MON,SSSE3,CX16,SSE4.1,SSE4.2,MOVBE,POPCNT,AESNI,XSAVE,OSXSAVE,AVX,RDRAND>').
32
32
  and_yield(' AMD Features=0x28100800<SYSCALL,NX,RDTSCP,LM>').
33
- and_yield(' AMD Features2=0x1<LAHF>').
33
+ and_yield(' AMD Features2=0x21<LAHF,ABM>').
34
+ and_yield(' Structured Extended Features=0x2000<NFPUSG>').
34
35
  and_yield(' TSC: P-state invariant')
35
36
  allow(File).to receive(:open).with("/var/run/dmesg.boot").and_return(@double_file)
36
37
  end
37
38
 
38
39
  it "detects all CPU flags" do
39
40
  @plugin.run
40
- expect(@plugin[:cpu][:flags]).to eq(%w{fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 mmx fxsr sse sse2 sse3 mon ssse3 syscall nx rdtscp lm lahf})
41
+ expect(@plugin[:cpu][:flags]).to eq(%w{fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 mmx fxsr sse sse2 sse3 pclmulqdq mon ssse3 cx16 sse4.1 sse4.2 movbe popcnt aesni xsave osxsave avx rdrand syscall nx rdtscp lm lahf abm nfpusg})
41
42
  end
42
43
 
43
- it "detects all CPU model_name" do
44
+ it "detects CPU model_name" do
44
45
  @plugin.run
45
- expect(@plugin[:cpu][:model_name]).to eq("Intel(R) Core(TM) i7-3615QM CPU @ 2.30GHz")
46
+ expect(@plugin[:cpu][:model_name]).to eq("Intel(R) Core(TM) i7-4980HQ CPU @ 2.80GHz")
46
47
  end
47
48
 
48
- it "detects all CPU mhz" do
49
+ it "detects CPU mhz" do
49
50
  @plugin.run
50
- expect(@plugin[:cpu][:mhz]).to eq("3516.61")
51
+ expect(@plugin[:cpu][:mhz]).to eq("2793.59")
51
52
  end
52
53
 
53
- it "detects all CPU vendor_id" do
54
+ it "detects CPU vendor_id" do
54
55
  @plugin.run
55
56
  expect(@plugin[:cpu][:vendor_id]).to eq("GenuineIntel")
56
57
  end
57
58
 
58
- it "detects all CPU stepping" do
59
+ it "detects CPU family" do
59
60
  @plugin.run
60
- expect(@plugin[:cpu][:stepping]).to eq("9")
61
+ expect(@plugin[:cpu][:family]).to eq("6")
61
62
  end
62
63
 
63
- it "detects all CPU total" do
64
+ it "detects CPU model" do
65
+ @plugin.run
66
+ expect(@plugin[:cpu][:model]).to eq("70")
67
+ end
68
+
69
+ it "detects CPU stepping" do
70
+ @plugin.run
71
+ expect(@plugin[:cpu][:stepping]).to eq("1")
72
+ end
73
+
74
+ it "detects CPU total" do
64
75
  @plugin.run
65
76
  expect(@plugin[:cpu][:total]).to eq(2)
66
77
  end
67
78
 
68
79
  end
80
+
81
+ describe Ohai::System, "FreeBSD cpu plugin on FreeBSD <=10.1" do
82
+ before(:each) do
83
+ @plugin = get_plugin("freebsd/cpu")
84
+ allow(@plugin).to receive(:collect_os).and_return(:freebsd)
85
+ allow(@plugin).to receive(:shell_out).with("sysctl -n hw.ncpu").and_return(mock_shell_out(0, "2", ""))
86
+ @double_file = double("/var/run/dmesg.boot")
87
+ allow(@double_file).to receive(:each).
88
+ and_yield('CPU: Intel(R) Atom(TM) CPU N270 @ 1.60GHz (1596.03-MHz 686-class CPU)').
89
+ and_yield(' Origin = "GenuineIntel" Id = 0x106c2 Family = 0x6 Model = 0x1c Stepping = 2')
90
+ allow(File).to receive(:open).with("/var/run/dmesg.boot").and_return(@double_file)
91
+ end
92
+
93
+ it "detects CPU vendor_id" do
94
+ @plugin.run
95
+ expect(@plugin[:cpu][:vendor_id]).to eq("GenuineIntel")
96
+ end
97
+
98
+ it "detects CPU family" do
99
+ @plugin.run
100
+ expect(@plugin[:cpu][:family]).to eq("6")
101
+ end
102
+
103
+ it "detects CPU model" do
104
+ @plugin.run
105
+
106
+ expect(@plugin[:cpu][:model]).to eq("28")
107
+ end
108
+
109
+ it "detects CPU stepping" do
110
+ @plugin.run
111
+ expect(@plugin[:cpu][:stepping]).to eq("2")
112
+ end
113
+
114
+ end
@@ -168,7 +168,41 @@ MSVPC
168
168
  expect(plugin[:virtualization][:systems][:virtualpc]).to eq("guest")
169
169
  end
170
170
 
171
- it "sets vmware guest if dmidecode detects VMware Virtual Platform" do
171
+ it "sets hyperv guest if dmidecode detects Hyper-V or version 7.0" do
172
+ ms_hv_dmidecode=<<-MSHV
173
+ System Information
174
+ Manufacturer: Microsoft Corporation
175
+ Product Name: Virtual Machine
176
+ Version: 7.0
177
+ Serial Number: 9242-2608-7031-8934-2088-5216-61
178
+ UUID: C2431A2D-D69C-244F-9DE8-CD5D09E0DA39
179
+ Wake-up Type: Power Switch
180
+ MSHV
181
+ allow(plugin).to receive(:shell_out).with("dmidecode").and_return(mock_shell_out(0, ms_hv_dmidecode, ""))
182
+ plugin.run
183
+ expect(plugin[:virtualization][:system]).to eq("hyperv")
184
+ expect(plugin[:virtualization][:role]).to eq("guest")
185
+ expect(plugin[:virtualization][:systems][:hyperv]).to eq("guest")
186
+ end
187
+
188
+ it "sets virtualserver guest if dmidecode detects version 5.0" do
189
+ ms_vs_dmidecode=<<-MSVS
190
+ System Information
191
+ Manufacturer: Microsoft Corporation
192
+ Product Name: Virtual Machine
193
+ Version: 5.0
194
+ Serial Number: 1688-7189-5337-7903-2297-1012-52
195
+ UUID: D29974A4-BE51-044C-BDC6-EFBC4B87A8E9
196
+ Wake-up Type: Power Switch
197
+ MSVS
198
+ allow(plugin).to receive(:shell_out).with("dmidecode").and_return(mock_shell_out(0, ms_vs_dmidecode, ""))
199
+ plugin.run
200
+ expect(plugin[:virtualization][:system]).to eq("virtualserver")
201
+ expect(plugin[:virtualization][:role]).to eq("guest")
202
+ expect(plugin[:virtualization][:systems][:virtualserver]).to eq("guest")
203
+ end
204
+
205
+ it "sets vmware guest if dmidecode detects VMware" do
172
206
  vmware_dmidecode=<<-VMWARE
173
207
  System Information
174
208
  Manufacturer: VMware, Inc.
@@ -187,7 +221,7 @@ VMWARE
187
221
  expect(plugin[:virtualization][:systems][:vmware]).to eq("guest")
188
222
  end
189
223
 
190
- it "sets vbox guest if dmidecode detects Oracle Corporation" do
224
+ it "sets vbox guest if dmidecode detects VirtualBox" do
191
225
  vbox_dmidecode=<<-VBOX
192
226
  Base Board Information
193
227
  Manufacturer: Oracle Corporation
@@ -227,8 +261,8 @@ OPENSTACK
227
261
  expect(plugin[:virtualization][:systems][:openstack]).to eq("guest")
228
262
  end
229
263
 
230
- it "sets kvm guest if dmidecode detects KVM" do
231
- kvm_dmidecode=<<-KVM
264
+ it "sets kvm guest if dmidecode contains KVM" do
265
+ kvm_dmidecode=<<-RKVM
232
266
  System Information
233
267
  Manufacturer: Red Hat
234
268
  Product Name: KVM
@@ -238,7 +272,26 @@ System Information
238
272
  Wake-up Type: Power Switch
239
273
  SKU Number: Not Specified
240
274
  Family: Red Hat Enterprise Linux
241
- KVM
275
+ RKVM
276
+ allow(plugin).to receive(:shell_out).with("dmidecode").and_return(mock_shell_out(0, kvm_dmidecode, ""))
277
+ plugin.run
278
+ expect(plugin[:virtualization][:system]).to eq("kvm")
279
+ expect(plugin[:virtualization][:role]).to eq("guest")
280
+ expect(plugin[:virtualization][:systems][:kvm]).to eq("guest")
281
+ end
282
+
283
+ it "sets kvm guest if dmidecode detects RHEV" do
284
+ kvm_dmidecode=<<-RHEV
285
+ System Information
286
+ Manufacturer: Red Hat
287
+ Product Name: RHEV Hypervisor
288
+ Version: 6.7-20150911.0.el6ev
289
+ Serial Number: 00000000-0000-0000-0000-000000000000
290
+ UUID: E7F1DC93-3DA1-4EC3-A6AB-F6904BA87985
291
+ Wake-up Type: Power Switch
292
+ SKU Number: Not Specified
293
+ Family: Red Hat Enterprise Linux
294
+ RHEV
242
295
  allow(plugin).to receive(:shell_out).with("dmidecode").and_return(mock_shell_out(0, kvm_dmidecode, ""))
243
296
  plugin.run
244
297
  expect(plugin[:virtualization][:system]).to eq("kvm")
@@ -0,0 +1,84 @@
1
+ #
2
+ # Copyright:: Copyright (c) 2015 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
+
18
+ require_relative '../../../spec_helper'
19
+
20
+ describe Ohai::System, "Solaris2.X filesystem plugin" do
21
+ let(:plugin) { get_plugin("solaris2/filesystem") }
22
+
23
+ before(:each) do
24
+ allow(plugin).to receive(:collect_os).and_return("solaris2")
25
+ end
26
+
27
+ describe "filesystem properties" do
28
+ let(:plugin_config) { {} }
29
+
30
+ before(:each) do
31
+ @original_plugin_config = Ohai.config[:plugin]
32
+ Ohai.config[:plugin] = plugin_config
33
+ allow(plugin).to receive(:shell_out).with("df -Pka").and_return(mock_shell_out(0, "", ""))
34
+ allow(plugin).to receive(:shell_out).with("df -na").and_return(mock_shell_out(0, "", ""))
35
+ allow(plugin).to receive(:shell_out).with("mount").and_return(mock_shell_out(0, "", ""))
36
+ end
37
+
38
+ after(:each) do
39
+ Ohai.config[:plugin] = @original_plugin_config
40
+ end
41
+
42
+ context "when 'zfs get' properties are not configured" do
43
+ it "collects all filesystem properties" do
44
+ expect(plugin).to receive(:shell_out).
45
+ with("zfs get -p -H all").
46
+ and_return(mock_shell_out(0, "", ""))
47
+ plugin.run
48
+ end
49
+ end
50
+
51
+ context "when 'zfs get' properties are configured" do
52
+ shared_examples_for "configured zfs properties" do
53
+ let(:plugin_config) do
54
+ {
55
+ :filesystem => {
56
+ :zfs_properties => zfs_properties
57
+ }
58
+ }
59
+ end
60
+
61
+ it "collects configured filesystem properties" do
62
+ expect(plugin).to receive(:shell_out).
63
+ with("zfs get -p -H #{expected_cmd}").
64
+ and_return(mock_shell_out(0, "", ""))
65
+ plugin.run
66
+ end
67
+ end
68
+
69
+ context "as a String" do
70
+ include_examples "configured zfs properties" do
71
+ let(:zfs_properties) { 'mountpoint,creation,available,used' }
72
+ let(:expected_cmd) { 'mountpoint,creation,available,used' }
73
+ end
74
+ end
75
+
76
+ context "as an Array" do
77
+ include_examples "configured zfs properties" do
78
+ let(:zfs_properties) { ['mountpoint', 'creation', 'available', 'used'] }
79
+ let(:expected_cmd) { 'mountpoint,creation,available,used' }
80
+ end
81
+ end
82
+ end
83
+ end
84
+ end
@@ -0,0 +1,88 @@
1
+ # Author:: Tim Smith (<tsmith@chef.io>)
2
+ # Copyright:: Copyright (c) 2015 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
+
18
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '/spec_helper.rb'))
19
+
20
+ vbox_output = <<EOF
21
+ Oracle VM VirtualBox Guest Additions Command Line Management Interface Version 5.0.2
22
+ (C) 2008-2015 Oracle Corporation
23
+ All rights reserved.
24
+
25
+ Name: /VirtualBox/GuestInfo/OS/Product, value: Linux, timestamp: 1448390422246549000, flags: <NULL>
26
+ Name: /VirtualBox/GuestInfo/Net/0/V4/IP, value: 10.0.2.15, timestamp: 1448390422248366000, flags: <NULL>
27
+ Name: /VirtualBox/HostInfo/GUI/LanguageID, value: en_US, timestamp: 1448390412061749000, flags: <NULL>
28
+ Name: /VirtualBox/GuestInfo/Net/0/MAC, value: 080027FBB38C, timestamp: 1448390422248652000, flags: <NULL>
29
+ Name: /VirtualBox/GuestInfo/OS/ServicePack, value: <NULL>, timestamp: 1448390422246976000, flags: <NULL>
30
+ Name: /VirtualBox/HostInfo/VBoxVerExt, value: 5.0.10, timestamp: 1448390411701508000, flags: TRANSIENT, RDONLYGUEST
31
+ Name: /VirtualBox/GuestInfo/Net/0/V4/Netmask, value: 255.255.255.0, timestamp: 1448390422248569000, flags: <NULL>
32
+ Name: /VirtualBox/GuestInfo/OS/Version, value: #36~14.04.1-Ubuntu SMP Thu Oct 8 10:21:08 UTC 2015, timestamp: 1448390422246810000, flags: <NULL>
33
+ Name: /VirtualBox/GuestAdd/VersionExt, value: 5.0.2, timestamp: 1448390422247220000, flags: <NULL>
34
+ Name: /VirtualBox/GuestAdd/Revision, value: 102096, timestamp: 1448390422247266000, flags: <NULL>
35
+ Name: /VirtualBox/HostGuest/SysprepExec, value: <NULL>, timestamp: 1448390411701168000, flags: TRANSIENT, RDONLYGUEST
36
+ Name: /VirtualBox/GuestInfo/OS/LoggedInUsers, value: 1, timestamp: 1448390452251425000, flags: TRANSIENT, TRANSRESET
37
+ Name: /VirtualBox/GuestInfo/Net/0/Status, value: Up, timestamp: 1448390422248755000, flags: <NULL>
38
+ Name: /VirtualBox/GuestInfo/Net/0/Name, value: eth0, timestamp: 1448390422248814000, flags: <NULL>
39
+ Name: /VirtualBox/HostGuest/SysprepArgs, value: <NULL>, timestamp: 1448390411701220000, flags: TRANSIENT, RDONLYGUEST
40
+ Name: /VirtualBox/GuestAdd/Version, value: 5.0.2, timestamp: 1448390422247066000, flags: <NULL>
41
+ Name: /VirtualBox/HostInfo/VBoxRev, value: 104061, timestamp: 1448390411701536000, flags: TRANSIENT, RDONLYGUEST
42
+ Name: /VirtualBox/GuestInfo/Net/0/V4/Broadcast, value: 10.0.2.255, timestamp: 1448390422248498000, flags: <NULL>
43
+ Name: /VirtualBox/HostInfo/VBoxVer, value: 5.0.10, timestamp: 1448390411701485000, flags: TRANSIENT, RDONLYGUEST
44
+ Name: /VirtualBox/GuestInfo/OS/LoggedInUsersList, value: tim, timestamp: 1448390452251274000, flags: TRANSIENT, TRANSRESET
45
+ Name: /VirtualBox/GuestInfo/Net/Count, value: 1, timestamp: 1448391352440445000, flags: <NULL>
46
+ Name: /VirtualBox/GuestInfo/OS/Release, value: 3.19.0-31-generic, timestamp: 1448390422246638000, flags: <NULL>
47
+ Name: /VirtualBox/GuestInfo/OS/NoLoggedInUsers, value: false, timestamp: 1448390452251532000, flags: TRANSIENT, TRANSRESET
48
+ EOF
49
+
50
+ describe Ohai::System, 'plugin virtualbox' do
51
+ context 'when VBoxControl shellout fails' do
52
+ it 'should not set the virtualbox attribute' do
53
+ plugin = get_plugin('virtualbox')
54
+ allow(plugin).to receive(:shell_out).with('VBoxControl guestproperty enumerate').and_return(mock_shell_out(1, '', ''))
55
+ plugin.run
56
+ expect(plugin).not_to have_key(:virtualbox)
57
+ end
58
+ end
59
+
60
+ context 'when VBoxControl shellout succeeds' do
61
+ let(:plugin) { get_plugin('virtualbox') }
62
+
63
+ before(:each) do
64
+ allow(plugin).to receive(:shell_out).with('VBoxControl guestproperty enumerate').and_return(mock_shell_out(0, vbox_output, ''))
65
+ plugin.run
66
+ end
67
+
68
+ it 'should set the host version' do
69
+ expect(plugin[:virtualbox][:host][:version]).to eql('5.0.10')
70
+ end
71
+
72
+ it 'should set the host revision' do
73
+ expect(plugin[:virtualbox][:host][:revision]).to eql('104061')
74
+ end
75
+
76
+ it 'should set the host language' do
77
+ expect(plugin[:virtualbox][:host][:language]).to eql('en_US')
78
+ end
79
+
80
+ it 'should set the guest additions version' do
81
+ expect(plugin[:virtualbox][:guest][:guest_additions_version]).to eql('5.0.2')
82
+ end
83
+
84
+ it 'should set the guest additions revision' do
85
+ expect(plugin[:virtualbox][:guest][:guest_additions_revision]).to eql('102096')
86
+ end
87
+ end
88
+ end
@@ -70,6 +70,7 @@ describe Ohai::System, 'Windows cpu plugin' do
70
70
  'manufacturer' => 'GenuineIntel',
71
71
  'maxclockspeed' => 2793,
72
72
  'numberofcores' => 1,
73
+ 'numberoflogicalprocessors' => 2,
73
74
  'revision' => 17_921,
74
75
  'stepping' => 9,
75
76
  'l2cachesize' => 64 },
@@ -81,6 +82,7 @@ describe Ohai::System, 'Windows cpu plugin' do
81
82
  'manufacturer' => 'GenuineIntel',
82
83
  'maxclockspeed' => 2793,
83
84
  'numberofcores' => 1,
85
+ 'numberoflogicalprocessors' => 2,
84
86
  'revision' => 17_921,
85
87
  'stepping' => 9,
86
88
  'l2cachesize' => 64 }]
@@ -95,7 +97,7 @@ describe Ohai::System, 'Windows cpu plugin' do
95
97
  end
96
98
 
97
99
  it 'should set total cpu to 2' do
98
- expect(@plugin[:cpu][:total]).to eq(2)
100
+ expect(@plugin[:cpu][:total]).to eq(4)
99
101
  end
100
102
 
101
103
  it 'should set real cpu to 2' do