ohai 8.9.0 → 8.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ohai/mixin/dmi_decode.rb +1 -1
- data/lib/ohai/plugins/bsd/virtualization.rb +1 -1
- data/lib/ohai/plugins/ec2.rb +20 -2
- data/lib/ohai/plugins/linux/virtualization.rb +17 -17
- data/lib/ohai/plugins/packages.rb +45 -39
- data/lib/ohai/plugins/windows/drivers.rb +21 -17
- data/lib/ohai/version.rb +1 -1
- data/spec/unit/plugins/ec2_spec.rb +16 -0
- data/spec/unit/plugins/linux/virtualization_spec.rb +57 -57
- data/spec/unit/plugins/packages_spec.rb +203 -173
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: df97b8b25c82b3afc5230e4be648989481aa4082
|
4
|
+
data.tar.gz: b6814cfa34071bd5e11bee94c417c0e57035c32e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa2aa6235d8baf1371e4a40c6fb3b7d2e238a6d3da7a460cb312519ed24d4a8edd9d9188b0f02b9c77e47bcc838583fffe2422aba57663750b4003c8945386ea
|
7
|
+
data.tar.gz: 8578b6b564b23aef84eea2efcc356df71f4a410ae212a25ee213542eab8ce63c4f82a026741c2f78cef647729e405289f71ac641df52f30f7cd9c3d68bc04364
|
@@ -69,7 +69,7 @@ Ohai.plugin(:Virtualization) do
|
|
69
69
|
|
70
70
|
# parse dmidecode to discover various virtualization guests
|
71
71
|
if File.exist?('/usr/local/sbin/dmidecode') || File.exist?('/usr/pkg/sbin/dmidecode')
|
72
|
-
guest =
|
72
|
+
guest = guest_from_dmi(shell_out('dmidecode').stdout)
|
73
73
|
if guest
|
74
74
|
virtualization[:system] = guest
|
75
75
|
virtualization[:role] = 'guest'
|
data/lib/ohai/plugins/ec2.rb
CHANGED
@@ -26,7 +26,9 @@ Ohai.plugin(:EC2) do
|
|
26
26
|
provides "ec2"
|
27
27
|
|
28
28
|
depends "network/interfaces"
|
29
|
+
depends "dmi"
|
29
30
|
|
31
|
+
# look for arp address that non-VPC hosts will have
|
30
32
|
def has_ec2_mac?
|
31
33
|
network[:interfaces].values.each do |iface|
|
32
34
|
unless iface[:arp].nil?
|
@@ -40,10 +42,26 @@ Ohai.plugin(:EC2) do
|
|
40
42
|
false
|
41
43
|
end
|
42
44
|
|
45
|
+
# look for amazon string in dmi bios data
|
46
|
+
# this only works on hvm instances as paravirt instances have no dmi data
|
47
|
+
def has_ec2_dmi?
|
48
|
+
begin
|
49
|
+
# detect a version of '4.2.amazon'
|
50
|
+
if dmi[:bios][:all_records][0][:Version] =~ /amazon/
|
51
|
+
Ohai::Log.debug("has_ec2_dmi? == true")
|
52
|
+
true
|
53
|
+
end
|
54
|
+
rescue NoMethodError
|
55
|
+
Ohai::Log.debug("has_ec2_dmi? == false")
|
56
|
+
false
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
|
43
61
|
def looks_like_ec2?
|
44
62
|
# Try non-blocking connect so we don't "block" if
|
45
63
|
# the Xen environment is *not* EC2
|
46
|
-
hint?('ec2') || has_ec2_mac? && can_metadata_connect?(Ohai::Mixin::Ec2Metadata::EC2_METADATA_ADDR,80)
|
64
|
+
hint?('ec2') || ( has_ec2_dmi? || has_ec2_mac?) && can_metadata_connect?(Ohai::Mixin::Ec2Metadata::EC2_METADATA_ADDR,80)
|
47
65
|
end
|
48
66
|
|
49
67
|
collect_data do
|
@@ -60,7 +78,7 @@ Ohai.plugin(:EC2) do
|
|
60
78
|
end
|
61
79
|
ec2[:userdata] = self.fetch_userdata
|
62
80
|
#ASCII-8BIT is equivalent to BINARY in this case
|
63
|
-
if ec2[:userdata].encoding.to_s == "ASCII-8BIT"
|
81
|
+
if ec2[:userdata] && ec2[:userdata].encoding.to_s == "ASCII-8BIT"
|
64
82
|
Ohai::Log.debug("Binary UserData Found. Storing in base64")
|
65
83
|
ec2[:userdata] = Base64.encode64(ec2[:userdata])
|
66
84
|
end
|
@@ -41,15 +41,15 @@ Ohai.plugin(:Virtualization) do
|
|
41
41
|
# virtualization[:mechanism]
|
42
42
|
|
43
43
|
## Xen
|
44
|
-
# /proc/xen is an empty dir for EL6 + Linode Guests
|
45
|
-
if File.
|
44
|
+
# /proc/xen is an empty dir for EL6 + Linode Guests + Paravirt EC2 instances
|
45
|
+
if File.exist?("/proc/xen")
|
46
46
|
virtualization[:system] = "xen"
|
47
47
|
# Assume guest
|
48
48
|
virtualization[:role] = "guest"
|
49
49
|
virtualization[:systems][:xen] = "guest"
|
50
50
|
|
51
51
|
# This file should exist on most Xen systems, normally empty for guests
|
52
|
-
if File.
|
52
|
+
if File.exist?("/proc/xen/capabilities")
|
53
53
|
if File.read("/proc/xen/capabilities") =~ /control_d/i
|
54
54
|
virtualization[:role] = "host"
|
55
55
|
virtualization[:systems][:xen] = "host"
|
@@ -65,7 +65,7 @@ Ohai.plugin(:Virtualization) do
|
|
65
65
|
# but rather be additive - btm
|
66
66
|
|
67
67
|
# Detect from kernel module
|
68
|
-
if File.
|
68
|
+
if File.exist?("/proc/modules")
|
69
69
|
modules = File.read("/proc/modules")
|
70
70
|
if modules =~ /^kvm/
|
71
71
|
virtualization[:system] = "kvm"
|
@@ -87,7 +87,7 @@ Ohai.plugin(:Virtualization) do
|
|
87
87
|
# 2.6.27-9-server (intrepid) has this / 2.6.18-6-amd64 (etch) does not
|
88
88
|
# It would be great if we could read pv_info in the kernel
|
89
89
|
# Wait for reply to: http://article.gmane.org/gmane.comp.emulators.kvm.devel/27885
|
90
|
-
if File.
|
90
|
+
if File.exist?("/proc/cpuinfo")
|
91
91
|
if File.read("/proc/cpuinfo") =~ /QEMU Virtual CPU|Common KVM processor|Common 32-bit KVM processor/
|
92
92
|
virtualization[:system] = "kvm"
|
93
93
|
virtualization[:role] = "guest"
|
@@ -97,18 +97,18 @@ Ohai.plugin(:Virtualization) do
|
|
97
97
|
|
98
98
|
# Detect OpenVZ / Virtuozzo.
|
99
99
|
# http://wiki.openvz.org/BC_proc_entries
|
100
|
-
if File.
|
100
|
+
if File.exist?("/proc/bc/0")
|
101
101
|
virtualization[:system] = "openvz"
|
102
102
|
virtualization[:role] = "host"
|
103
103
|
virtualization[:systems][:openvz] = "host"
|
104
|
-
elsif File.
|
104
|
+
elsif File.exist?("/proc/vz")
|
105
105
|
virtualization[:system] = "openvz"
|
106
106
|
virtualization[:role] = "guest"
|
107
107
|
virtualization[:systems][:openvz] = "guest"
|
108
108
|
end
|
109
109
|
|
110
110
|
# Detect Parallels virtual machine from pci devices
|
111
|
-
if File.
|
111
|
+
if File.exist?("/proc/bus/pci/devices")
|
112
112
|
if File.read("/proc/bus/pci/devices") =~ /1ab84000/
|
113
113
|
virtualization[:system] = "parallels"
|
114
114
|
virtualization[:role] = "guest"
|
@@ -117,8 +117,8 @@ Ohai.plugin(:Virtualization) do
|
|
117
117
|
end
|
118
118
|
|
119
119
|
# parse dmidecode to discover various virtualization guests
|
120
|
-
if File.
|
121
|
-
guest =
|
120
|
+
if File.exist?("/usr/sbin/dmidecode")
|
121
|
+
guest = guest_from_dmi(shell_out('dmidecode').stdout)
|
122
122
|
if guest
|
123
123
|
virtualization[:system] = guest
|
124
124
|
virtualization[:role] = 'guest'
|
@@ -127,10 +127,10 @@ Ohai.plugin(:Virtualization) do
|
|
127
127
|
end
|
128
128
|
|
129
129
|
# Detect Linux-VServer
|
130
|
-
if File.
|
130
|
+
if File.exist?("/proc/self/status")
|
131
131
|
proc_self_status = File.read("/proc/self/status")
|
132
132
|
vxid = proc_self_status.match(/^(s_context|VxID):\s*(\d+)$/)
|
133
|
-
if vxid
|
133
|
+
if vxid && vxid[2]
|
134
134
|
virtualization[:system] = "linux-vserver"
|
135
135
|
if vxid[2] == "0"
|
136
136
|
virtualization[:role] = "host"
|
@@ -160,7 +160,7 @@ Ohai.plugin(:Virtualization) do
|
|
160
160
|
#
|
161
161
|
# Full notes, https://tickets.opscode.com/browse/OHAI-551
|
162
162
|
# Kernel docs, https://www.kernel.org/doc/Documentation/cgroups
|
163
|
-
if File.
|
163
|
+
if File.exist?("/proc/self/cgroup")
|
164
164
|
cgroup_content = File.read("/proc/self/cgroup")
|
165
165
|
if cgroup_content =~ %r{^\d+:[^:]+:/(lxc|docker)/.+$} ||
|
166
166
|
cgroup_content =~ %r{^\d+:[^:]+:/[^/]+/(lxc|docker)-.+$}
|
@@ -180,10 +180,10 @@ Ohai.plugin(:Virtualization) do
|
|
180
180
|
# If so, we may need to look further for a differentiator (OHAI-573)
|
181
181
|
virtualization[:systems][:lxc] = "host"
|
182
182
|
end
|
183
|
-
elsif File.
|
184
|
-
|
185
|
-
|
186
|
-
|
183
|
+
elsif File.exist?("/.dockerenv") || File.exist?("/.dockerinit")
|
184
|
+
virtualization[:system] = "docker"
|
185
|
+
virtualization[:role] = "guest"
|
186
|
+
virtualization[:systems][:docker] = "guest"
|
187
187
|
end
|
188
188
|
end
|
189
189
|
end
|
@@ -23,58 +23,62 @@ Ohai.plugin(:Packages) do
|
|
23
23
|
depends 'platform_family'
|
24
24
|
|
25
25
|
collect_data(:linux) do
|
26
|
-
|
26
|
+
if configuration(:enabled)
|
27
|
+
packages Mash.new
|
28
|
+
if %w(debian).include? platform_family
|
29
|
+
so = shell_out('dpkg-query -W')
|
30
|
+
pkgs = so.stdout.lines
|
27
31
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
pkgs.each do |pkg|
|
33
|
-
name, version = pkg.split
|
34
|
-
packages[name] = { 'version' => version }
|
35
|
-
end
|
32
|
+
pkgs.each do |pkg|
|
33
|
+
name, version = pkg.split
|
34
|
+
packages[name] = { 'version' => version }
|
35
|
+
end
|
36
36
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
37
|
+
elsif %w(rhel fedora suse).include? platform_family
|
38
|
+
require 'shellwords'
|
39
|
+
format = Shellwords.escape '%{NAME}\t%{VERSION}\t%{RELEASE}\n'
|
40
|
+
so = shell_out("rpm -qa --queryformat #{format}")
|
41
|
+
pkgs = so.stdout.lines
|
42
42
|
|
43
|
-
|
44
|
-
|
45
|
-
|
43
|
+
pkgs.each do |pkg|
|
44
|
+
name, version, release = pkg.split
|
45
|
+
packages[name] = { 'version' => version, 'release' => release }
|
46
|
+
end
|
46
47
|
end
|
47
48
|
end
|
48
49
|
end
|
49
50
|
|
50
51
|
collect_data(:windows) do
|
51
|
-
|
52
|
-
|
53
|
-
|
52
|
+
if configuration(:enabled)
|
53
|
+
packages Mash.new
|
54
|
+
require 'wmi-lite'
|
54
55
|
|
55
|
-
|
56
|
-
|
56
|
+
wmi = WmiLite::Wmi.new
|
57
|
+
w32_product = wmi.instances_of('Win32_Product')
|
57
58
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
59
|
+
w32_product.find_all.each do |product|
|
60
|
+
name = product['name']
|
61
|
+
package = packages[name] = Mash.new
|
62
|
+
%w(version vendor installdate).each do |attr|
|
63
|
+
package[attr] = product[attr]
|
64
|
+
end
|
63
65
|
end
|
64
66
|
end
|
65
67
|
end
|
66
68
|
|
67
69
|
collect_data(:aix) do
|
68
|
-
|
69
|
-
|
70
|
-
|
70
|
+
if configuration(:enabled)
|
71
|
+
packages Mash.new
|
72
|
+
so = shell_out('lslpp -L -q -c')
|
73
|
+
pkgs = so.stdout.lines
|
71
74
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
75
|
+
# Output format is
|
76
|
+
# Package Name:Fileset:Level
|
77
|
+
# On aix, filesets are packages and levels are versions
|
78
|
+
pkgs.each do |pkg|
|
79
|
+
_, name, version = pkg.split(':')
|
80
|
+
packages[name] = { 'version' => version }
|
81
|
+
end
|
78
82
|
end
|
79
83
|
end
|
80
84
|
|
@@ -115,8 +119,10 @@ Ohai.plugin(:Packages) do
|
|
115
119
|
end
|
116
120
|
|
117
121
|
collect_data(:solaris2) do
|
118
|
-
|
119
|
-
|
120
|
-
|
122
|
+
if configuration(:enabled)
|
123
|
+
packages Mash.new
|
124
|
+
collect_ips_packages
|
125
|
+
collect_sysv_packages
|
126
|
+
end
|
121
127
|
end
|
122
128
|
end
|
@@ -20,28 +20,32 @@ Ohai.plugin(:Drivers) do
|
|
20
20
|
depends "kernel"
|
21
21
|
|
22
22
|
collect_data(:windows) do
|
23
|
-
|
23
|
+
if configuration(:enabled)
|
24
24
|
|
25
|
-
|
25
|
+
require 'wmi-lite/wmi'
|
26
26
|
|
27
|
-
|
28
|
-
|
27
|
+
kext = Mash.new
|
28
|
+
pnp_drivers = Mash.new
|
29
29
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
pnp_drivers[driver['deviceid']]
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
30
|
+
wmi = WmiLite::Wmi.new
|
31
|
+
|
32
|
+
drivers = wmi.instances_of('Win32_PnPSignedDriver')
|
33
|
+
drivers.each do |driver|
|
34
|
+
pnp_drivers[driver['deviceid']] = Mash.new
|
35
|
+
driver.wmi_ole_object.properties_.each do |p|
|
36
|
+
pnp_drivers[driver['deviceid']][p.name.wmi_underscore.to_sym] = driver[p.name.downcase]
|
37
|
+
end
|
38
|
+
if driver['devicename']
|
39
|
+
kext[driver['devicename']] = pnp_drivers[driver['deviceid']]
|
40
|
+
kext[driver['devicename']][:version] = pnp_drivers[driver['deviceid']][:driver_version]
|
41
|
+
kext[driver['devicename']][:date] = pnp_drivers[driver['deviceid']][:driver_date] ? pnp_drivers[driver['deviceid']][:driver_date].to_s[0..7] : nil
|
42
|
+
end
|
40
43
|
end
|
41
|
-
end
|
42
44
|
|
43
|
-
|
44
|
-
|
45
|
+
kernel[:pnp_drivers] = pnp_drivers
|
46
|
+
kernel[:modules] = kext
|
45
47
|
|
48
|
+
end
|
46
49
|
end
|
50
|
+
|
47
51
|
end
|
data/lib/ohai/version.rb
CHANGED
@@ -270,6 +270,22 @@ end
|
|
270
270
|
end
|
271
271
|
end
|
272
272
|
|
273
|
+
describe "with ec2 dmi data" do
|
274
|
+
it_should_behave_like "ec2"
|
275
|
+
|
276
|
+
before(:each) do
|
277
|
+
@plugin[:dmi] = { :bios => { :all_records => [ { :Version => "4.2.amazon" } ] } }
|
278
|
+
end
|
279
|
+
end
|
280
|
+
|
281
|
+
describe "without ec2 dmi data" do
|
282
|
+
it_should_behave_like "!ec2"
|
283
|
+
|
284
|
+
before(:each) do
|
285
|
+
@plugin[:dmi] = nil
|
286
|
+
end
|
287
|
+
end
|
288
|
+
|
273
289
|
describe "with ec2 cloud file" do
|
274
290
|
it_should_behave_like "ec2"
|
275
291
|
|
@@ -25,24 +25,24 @@ describe Ohai::System, "Linux virtualization platform" do
|
|
25
25
|
allow(plugin).to receive(:collect_os).and_return(:linux)
|
26
26
|
|
27
27
|
# default to all requested Files not existing
|
28
|
-
allow(File).to receive(:
|
29
|
-
allow(File).to receive(:
|
30
|
-
allow(File).to receive(:
|
31
|
-
allow(File).to receive(:
|
32
|
-
allow(File).to receive(:
|
33
|
-
allow(File).to receive(:
|
34
|
-
allow(File).to receive(:
|
35
|
-
allow(File).to receive(:
|
36
|
-
allow(File).to receive(:
|
37
|
-
allow(File).to receive(:
|
38
|
-
allow(File).to receive(:
|
39
|
-
allow(File).to receive(:
|
28
|
+
allow(File).to receive(:exist?).with("/proc/xen").and_return(false)
|
29
|
+
allow(File).to receive(:exist?).with("/proc/xen/capabilities").and_return(false)
|
30
|
+
allow(File).to receive(:exist?).with("/proc/modules").and_return(false)
|
31
|
+
allow(File).to receive(:exist?).with("/proc/cpuinfo").and_return(false)
|
32
|
+
allow(File).to receive(:exist?).with("/usr/sbin/dmidecode").and_return(false)
|
33
|
+
allow(File).to receive(:exist?).with("/proc/self/status").and_return(false)
|
34
|
+
allow(File).to receive(:exist?).with("/proc/bc/0").and_return(false)
|
35
|
+
allow(File).to receive(:exist?).with("/proc/vz").and_return(false)
|
36
|
+
allow(File).to receive(:exist?).with("/proc/self/cgroup").and_return(false)
|
37
|
+
allow(File).to receive(:exist?).with("/.dockerenv").and_return(false)
|
38
|
+
allow(File).to receive(:exist?).with("/.dockerinit").and_return(false)
|
39
|
+
allow(File).to receive(:exist?).with("/proc/bus/pci/devices").and_return(false)
|
40
40
|
end
|
41
41
|
|
42
42
|
describe "when we are checking for xen" do
|
43
43
|
it "sets xen guest if /proc/xen exists but /proc/xen/capabilities does not" do
|
44
|
-
expect(File).to receive(:
|
45
|
-
expect(File).to receive(:
|
44
|
+
expect(File).to receive(:exist?).with("/proc/xen").and_return(true)
|
45
|
+
expect(File).to receive(:exist?).with("/proc/xen/capabilities").and_return(false)
|
46
46
|
plugin.run
|
47
47
|
expect(plugin[:virtualization][:system]).to eq("xen")
|
48
48
|
expect(plugin[:virtualization][:role]).to eq("guest")
|
@@ -50,8 +50,8 @@ describe Ohai::System, "Linux virtualization platform" do
|
|
50
50
|
end
|
51
51
|
|
52
52
|
it "sets xen host if /proc/xen/capabilities contains control_d " do
|
53
|
-
expect(File).to receive(:
|
54
|
-
expect(File).to receive(:
|
53
|
+
expect(File).to receive(:exist?).with("/proc/xen").and_return(true)
|
54
|
+
expect(File).to receive(:exist?).with("/proc/xen/capabilities").and_return(true)
|
55
55
|
allow(File).to receive(:read).with("/proc/xen/capabilities").and_return("control_d")
|
56
56
|
plugin.run
|
57
57
|
expect(plugin[:virtualization][:system]).to eq("xen")
|
@@ -60,8 +60,8 @@ describe Ohai::System, "Linux virtualization platform" do
|
|
60
60
|
end
|
61
61
|
|
62
62
|
it "sets xen guest if /proc/xen/capabilities exists but is empty" do
|
63
|
-
expect(File).to receive(:
|
64
|
-
expect(File).to receive(:
|
63
|
+
expect(File).to receive(:exist?).with("/proc/xen").and_return(true)
|
64
|
+
expect(File).to receive(:exist?).with("/proc/xen/capabilities").and_return(true)
|
65
65
|
allow(File).to receive(:read).with("/proc/xen/capabilities").and_return("")
|
66
66
|
plugin.run
|
67
67
|
expect(plugin[:virtualization][:system]).to eq("xen")
|
@@ -70,7 +70,7 @@ describe Ohai::System, "Linux virtualization platform" do
|
|
70
70
|
end
|
71
71
|
|
72
72
|
it "does not set virtualization if xen isn't there" do
|
73
|
-
expect(File).to receive(:
|
73
|
+
expect(File).to receive(:exist?).at_least(:once).and_return(false)
|
74
74
|
plugin.run
|
75
75
|
expect(plugin[:virtualization]).to eq({'systems' => {}})
|
76
76
|
end
|
@@ -78,7 +78,7 @@ describe Ohai::System, "Linux virtualization platform" do
|
|
78
78
|
|
79
79
|
describe "when we are checking for kvm" do
|
80
80
|
it "sets kvm host if /proc/modules contains kvm" do
|
81
|
-
expect(File).to receive(:
|
81
|
+
expect(File).to receive(:exist?).with("/proc/modules").and_return(true)
|
82
82
|
allow(File).to receive(:read).with("/proc/modules").and_return("kvm 165872 1 kvm_intel")
|
83
83
|
plugin.run
|
84
84
|
expect(plugin[:virtualization][:system]).to eq("kvm")
|
@@ -87,7 +87,7 @@ describe Ohai::System, "Linux virtualization platform" do
|
|
87
87
|
end
|
88
88
|
|
89
89
|
it "sets kvm guest if /proc/cpuinfo contains QEMU Virtual CPU" do
|
90
|
-
expect(File).to receive(:
|
90
|
+
expect(File).to receive(:exist?).with("/proc/cpuinfo").and_return(true)
|
91
91
|
allow(File).to receive(:read).with("/proc/cpuinfo").and_return("QEMU Virtual CPU")
|
92
92
|
plugin.run
|
93
93
|
expect(plugin[:virtualization][:system]).to eq("kvm")
|
@@ -96,7 +96,7 @@ describe Ohai::System, "Linux virtualization platform" do
|
|
96
96
|
end
|
97
97
|
|
98
98
|
it "sets kvm guest if /proc/cpuinfo contains Common KVM processor" do
|
99
|
-
expect(File).to receive(:
|
99
|
+
expect(File).to receive(:exist?).with("/proc/cpuinfo").and_return(true)
|
100
100
|
allow(File).to receive(:read).with("/proc/cpuinfo").and_return("Common KVM processor")
|
101
101
|
plugin.run
|
102
102
|
expect(plugin[:virtualization][:system]).to eq("kvm")
|
@@ -105,7 +105,7 @@ describe Ohai::System, "Linux virtualization platform" do
|
|
105
105
|
end
|
106
106
|
|
107
107
|
it "sets kvm guest if /proc/cpuinfo contains Common 32-bit KVM processor" do
|
108
|
-
expect(File).to receive(:
|
108
|
+
expect(File).to receive(:exist?).with("/proc/cpuinfo").and_return(true)
|
109
109
|
allow(File).to receive(:read).with("/proc/cpuinfo").and_return("Common 32-bit KVM processor")
|
110
110
|
plugin.run
|
111
111
|
expect(plugin[:virtualization][:system]).to eq("kvm")
|
@@ -114,7 +114,7 @@ describe Ohai::System, "Linux virtualization platform" do
|
|
114
114
|
end
|
115
115
|
|
116
116
|
it "does not set virtualization if kvm isn't there" do
|
117
|
-
expect(File).to receive(:
|
117
|
+
expect(File).to receive(:exist?).at_least(:once).and_return(false)
|
118
118
|
plugin.run
|
119
119
|
expect(plugin[:virtualization]).to eq({'systems' => {}})
|
120
120
|
end
|
@@ -122,7 +122,7 @@ describe Ohai::System, "Linux virtualization platform" do
|
|
122
122
|
|
123
123
|
describe "when we are checking for VirtualBox" do
|
124
124
|
it "sets vbox host if /proc/modules contains vboxdrv" do
|
125
|
-
expect(File).to receive(:
|
125
|
+
expect(File).to receive(:exist?).with("/proc/modules").and_return(true)
|
126
126
|
allow(File).to receive(:read).with("/proc/modules").and_return("vboxdrv 268268 3 vboxnetadp,vboxnetflt")
|
127
127
|
plugin.run
|
128
128
|
expect(plugin[:virtualization][:system]).to eq("vbox")
|
@@ -131,7 +131,7 @@ describe Ohai::System, "Linux virtualization platform" do
|
|
131
131
|
end
|
132
132
|
|
133
133
|
it "sets vbox gues if /proc/modules contains vboxguest" do
|
134
|
-
expect(File).to receive(:
|
134
|
+
expect(File).to receive(:exist?).with("/proc/modules").and_return(true)
|
135
135
|
allow(File).to receive(:read).with("/proc/modules").and_return("vboxguest 214901 2 vboxsf, Live 0xffffffffa00db000 (OF)")
|
136
136
|
plugin.run
|
137
137
|
expect(plugin[:virtualization][:system]).to eq("vbox")
|
@@ -140,7 +140,7 @@ describe Ohai::System, "Linux virtualization platform" do
|
|
140
140
|
end
|
141
141
|
|
142
142
|
it "does not set virtualization if vbox isn't there" do
|
143
|
-
expect(File).to receive(:
|
143
|
+
expect(File).to receive(:exist?).at_least(:once).and_return(false)
|
144
144
|
plugin.run
|
145
145
|
expect(plugin[:virtualization]).to eq({'systems' => {}})
|
146
146
|
end
|
@@ -148,7 +148,7 @@ describe Ohai::System, "Linux virtualization platform" do
|
|
148
148
|
|
149
149
|
describe "when we are parsing dmidecode" do
|
150
150
|
before(:each) do
|
151
|
-
expect(File).to receive(:
|
151
|
+
expect(File).to receive(:exist?).with("/usr/sbin/dmidecode").and_return(true)
|
152
152
|
end
|
153
153
|
|
154
154
|
it "sets virtualpc guest if dmidecode detects Microsoft Virtual Machine" do
|
@@ -308,7 +308,7 @@ RHEV
|
|
308
308
|
|
309
309
|
describe "when we are checking for Linux-VServer" do
|
310
310
|
it "sets Linux-VServer host if /proc/self/status contains s_context: 0" do
|
311
|
-
expect(File).to receive(:
|
311
|
+
expect(File).to receive(:exist?).with("/proc/self/status").and_return(true)
|
312
312
|
allow(File).to receive(:read).with("/proc/self/status").and_return("s_context: 0")
|
313
313
|
plugin.run
|
314
314
|
expect(plugin[:virtualization][:system]).to eq("linux-vserver")
|
@@ -317,7 +317,7 @@ RHEV
|
|
317
317
|
end
|
318
318
|
|
319
319
|
it "sets Linux-VServer host if /proc/self/status contains VxID: 0" do
|
320
|
-
expect(File).to receive(:
|
320
|
+
expect(File).to receive(:exist?).with("/proc/self/status").and_return(true)
|
321
321
|
allow(File).to receive(:read).with("/proc/self/status").and_return("VxID: 0")
|
322
322
|
plugin.run
|
323
323
|
expect(plugin[:virtualization][:system]).to eq("linux-vserver")
|
@@ -326,7 +326,7 @@ RHEV
|
|
326
326
|
end
|
327
327
|
|
328
328
|
it "sets Linux-VServer host if /proc/self/status contains multiple space VxID: 0" do
|
329
|
-
expect(File).to receive(:
|
329
|
+
expect(File).to receive(:exist?).with("/proc/self/status").and_return(true)
|
330
330
|
allow(File).to receive(:read).with("/proc/self/status").and_return("VxID: 0")
|
331
331
|
plugin.run
|
332
332
|
expect(plugin[:virtualization][:system]).to eq("linux-vserver")
|
@@ -335,7 +335,7 @@ RHEV
|
|
335
335
|
end
|
336
336
|
|
337
337
|
it "sets Linux-VServer host if /proc/self/status contains tabbed VxID:\t0" do
|
338
|
-
expect(File).to receive(:
|
338
|
+
expect(File).to receive(:exist?).with("/proc/self/status").and_return(true)
|
339
339
|
allow(File).to receive(:read).with("/proc/self/status").and_return("VxID:\t0")
|
340
340
|
plugin.run
|
341
341
|
expect(plugin[:virtualization][:system]).to eq("linux-vserver")
|
@@ -344,7 +344,7 @@ RHEV
|
|
344
344
|
end
|
345
345
|
|
346
346
|
it "sets Linux-VServer guest if /proc/self/status contains s_context > 0" do
|
347
|
-
expect(File).to receive(:
|
347
|
+
expect(File).to receive(:exist?).with("/proc/self/status").and_return(true)
|
348
348
|
allow(File).to receive(:read).with("/proc/self/status").and_return("s_context: 2")
|
349
349
|
plugin.run
|
350
350
|
expect(plugin[:virtualization][:system]).to eq("linux-vserver")
|
@@ -353,7 +353,7 @@ RHEV
|
|
353
353
|
end
|
354
354
|
|
355
355
|
it "sets Linux-VServer guest if /proc/self/status contains VxID > 0" do
|
356
|
-
expect(File).to receive(:
|
356
|
+
expect(File).to receive(:exist?).with("/proc/self/status").and_return(true)
|
357
357
|
allow(File).to receive(:read).with("/proc/self/status").and_return("VxID: 2")
|
358
358
|
plugin.run
|
359
359
|
expect(plugin[:virtualization][:system]).to eq("linux-vserver")
|
@@ -362,7 +362,7 @@ RHEV
|
|
362
362
|
end
|
363
363
|
|
364
364
|
it "does not set virtualization if Linux-VServer isn't there" do
|
365
|
-
expect(File).to receive(:
|
365
|
+
expect(File).to receive(:exist?).at_least(:once).and_return(false)
|
366
366
|
plugin.run
|
367
367
|
expect(plugin[:virtualization]).to eq({'systems' => {}})
|
368
368
|
end
|
@@ -370,7 +370,7 @@ RHEV
|
|
370
370
|
|
371
371
|
describe "when we are checking for openvz" do
|
372
372
|
it "sets openvz host if /proc/bc/0 exists" do
|
373
|
-
expect(File).to receive(:
|
373
|
+
expect(File).to receive(:exist?).with("/proc/bc/0").and_return(true)
|
374
374
|
plugin.run
|
375
375
|
expect(plugin[:virtualization][:system]).to eq("openvz")
|
376
376
|
expect(plugin[:virtualization][:role]).to eq("host")
|
@@ -378,8 +378,8 @@ RHEV
|
|
378
378
|
end
|
379
379
|
|
380
380
|
it "sets openvz guest if /proc/bc/0 does not exist and /proc/vz exists" do
|
381
|
-
expect(File).to receive(:
|
382
|
-
expect(File).to receive(:
|
381
|
+
expect(File).to receive(:exist?).with("/proc/bc/0").and_return(false)
|
382
|
+
expect(File).to receive(:exist?).with("/proc/vz").and_return(true)
|
383
383
|
plugin.run
|
384
384
|
expect(plugin[:virtualization][:system]).to eq("openvz")
|
385
385
|
expect(plugin[:virtualization][:role]).to eq("guest")
|
@@ -387,8 +387,8 @@ RHEV
|
|
387
387
|
end
|
388
388
|
|
389
389
|
it "does not set virtualization if openvz isn't there" do
|
390
|
-
expect(File).to receive(:
|
391
|
-
expect(File).to receive(:
|
390
|
+
expect(File).to receive(:exist?).with("/proc/bc/0").and_return(false)
|
391
|
+
expect(File).to receive(:exist?).with("/proc/vz").and_return(false)
|
392
392
|
plugin.run
|
393
393
|
expect(plugin[:virtualization]).to eq({'systems' => {}})
|
394
394
|
end
|
@@ -400,7 +400,7 @@ RHEV
|
|
400
400
|
0018 1ab84000 1f 8001 0 0 0 0 0 0 20 0 0 0 0 0 0 prl_tg
|
401
401
|
0028 1af41000 17 8201 ee000000 0 0 0 0 0 40 1000 0 0 0 0 0 virtio-pci
|
402
402
|
DEVICES
|
403
|
-
expect(File).to receive(:
|
403
|
+
expect(File).to receive(:exist?).with("/proc/bus/pci/devices").and_return(true)
|
404
404
|
allow(File).to receive(:read).with("/proc/bus/pci/devices").and_return(devices)
|
405
405
|
plugin.run
|
406
406
|
expect(plugin[:virtualization][:system]).to eq("parallels")
|
@@ -413,7 +413,7 @@ RHEV
|
|
413
413
|
0030 1af41000 a 8401 ee040000 0 0 0 0 0 40 1000 0 0 0 0 0 virtio-pci
|
414
414
|
0050 10110022 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
415
415
|
DEVICES
|
416
|
-
expect(File).to receive(:
|
416
|
+
expect(File).to receive(:exist?).with("/proc/bus/pci/devices").and_return(true)
|
417
417
|
allow(File).to receive(:read).with("/proc/bus/pci/devices").and_return(devices)
|
418
418
|
plugin.run
|
419
419
|
expect(plugin[:virtualization]).to eq({'systems' => {}})
|
@@ -432,7 +432,7 @@ RHEV
|
|
432
432
|
2:cpu:/lxc/baa660ed81bc81d262ac6e19486142aeec5fce2043e2a173eb2505c6fbed89bc
|
433
433
|
1:cpuset:/
|
434
434
|
CGROUP
|
435
|
-
expect(File).to receive(:
|
435
|
+
expect(File).to receive(:exist?).with("/proc/self/cgroup").and_return(true)
|
436
436
|
allow(File).to receive(:read).with("/proc/self/cgroup").and_return(self_cgroup)
|
437
437
|
plugin.run
|
438
438
|
expect(plugin[:virtualization][:system]).to eq("lxc")
|
@@ -451,7 +451,7 @@ CGROUP
|
|
451
451
|
2:cpu:/lxc/vanilla
|
452
452
|
1:cpuset:/lxc/vanilla
|
453
453
|
CGROUP
|
454
|
-
expect(File).to receive(:
|
454
|
+
expect(File).to receive(:exist?).with("/proc/self/cgroup").and_return(true)
|
455
455
|
allow(File).to receive(:read).with("/proc/self/cgroup").and_return(self_cgroup)
|
456
456
|
plugin.run
|
457
457
|
expect(plugin[:virtualization][:system]).to eq("lxc")
|
@@ -470,7 +470,7 @@ CGROUP
|
|
470
470
|
2:cpu:/Charlie
|
471
471
|
1:cpuset:/Charlie
|
472
472
|
CGROUP
|
473
|
-
expect(File).to receive(:
|
473
|
+
expect(File).to receive(:exist?).with("/proc/self/cgroup").and_return(true)
|
474
474
|
allow(File).to receive(:read).with("/proc/self/cgroup").and_return(self_cgroup)
|
475
475
|
plugin.run
|
476
476
|
expect(plugin[:virtualization]).to eq({'systems' => {}})
|
@@ -488,7 +488,7 @@ CGROUP
|
|
488
488
|
2:cpu:/
|
489
489
|
1:cpuset:/
|
490
490
|
CGROUP
|
491
|
-
expect(File).to receive(:
|
491
|
+
expect(File).to receive(:exist?).with("/proc/self/cgroup").and_return(true)
|
492
492
|
allow(File).to receive(:read).with("/proc/self/cgroup").and_return(self_cgroup)
|
493
493
|
end
|
494
494
|
|
@@ -521,7 +521,7 @@ CGROUP
|
|
521
521
|
end
|
522
522
|
|
523
523
|
it "does not set virtualization if /proc/self/cgroup isn't there" do
|
524
|
-
expect(File).to receive(:
|
524
|
+
expect(File).to receive(:exist?).with("/proc/self/cgroup").and_return(false)
|
525
525
|
plugin.run
|
526
526
|
expect(plugin[:virtualization]).to eq({'systems' => {}})
|
527
527
|
end
|
@@ -539,7 +539,7 @@ CGROUP
|
|
539
539
|
2:cpu:/docker/baa660ed81bc81d262ac6e19486142aeec5fce2043e2a173eb2505c6fbed89bc
|
540
540
|
1:cpuset:/
|
541
541
|
CGROUP
|
542
|
-
allow(File).to receive(:
|
542
|
+
allow(File).to receive(:exist?).with("/proc/self/cgroup").and_return(true)
|
543
543
|
allow(File).to receive(:read).with("/proc/self/cgroup").and_return(self_cgroup)
|
544
544
|
plugin.run
|
545
545
|
expect(plugin[:virtualization][:system]).to eq("docker")
|
@@ -558,7 +558,7 @@ CGROUP
|
|
558
558
|
2:cpu:/docker/vanilla
|
559
559
|
1:cpuset:/docker/vanilla
|
560
560
|
CGROUP
|
561
|
-
allow(File).to receive(:
|
561
|
+
allow(File).to receive(:exist?).with("/proc/self/cgroup").and_return(true)
|
562
562
|
allow(File).to receive(:read).with("/proc/self/cgroup").and_return(self_cgroup)
|
563
563
|
plugin.run
|
564
564
|
expect(plugin[:virtualization][:system]).to eq("docker")
|
@@ -579,7 +579,7 @@ CGROUP
|
|
579
579
|
2:cpu,cpuacct:/system.slice/docker-47341c91be8d491cb3b8a475ad5b4aef6e79bf728cbb351c384e4a6c410f172f.scope
|
580
580
|
1:name=systemd:/system.slice/docker-47341c91be8d491cb3b8a475ad5b4aef6e79bf728cbb351c384e4a6c410f172f.scope
|
581
581
|
CGROUP
|
582
|
-
allow(File).to receive(:
|
582
|
+
allow(File).to receive(:exist?).with("/proc/self/cgroup").and_return(true)
|
583
583
|
allow(File).to receive(:read).with("/proc/self/cgroup").and_return(self_cgroup)
|
584
584
|
plugin.run
|
585
585
|
expect(plugin[:virtualization][:system]).to eq("docker")
|
@@ -598,7 +598,7 @@ CGROUP
|
|
598
598
|
2:cpu:/Charlie
|
599
599
|
1:cpuset:/Charlie
|
600
600
|
CGROUP
|
601
|
-
allow(File).to receive(:
|
601
|
+
allow(File).to receive(:exist?).with("/proc/self/cgroup").and_return(true)
|
602
602
|
allow(File).to receive(:read).with("/proc/self/cgroup").and_return(self_cgroup)
|
603
603
|
plugin.run
|
604
604
|
expect(plugin[:virtualization]).to eq({'systems' => {}})
|
@@ -616,7 +616,7 @@ CGROUP
|
|
616
616
|
2:cpu:/
|
617
617
|
1:cpuset:/
|
618
618
|
CGROUP
|
619
|
-
allow(File).to receive(:
|
619
|
+
allow(File).to receive(:exist?).with("/proc/self/cgroup").and_return(true)
|
620
620
|
allow(File).to receive(:read).with("/proc/self/cgroup").and_return(self_cgroup)
|
621
621
|
plugin.run
|
622
622
|
expect(plugin[:virtualization]).to eq({'systems' => {}})
|
@@ -643,13 +643,13 @@ CGROUP
|
|
643
643
|
end
|
644
644
|
|
645
645
|
it "does not set virtualization if /proc/self/cgroup isn't there" do
|
646
|
-
allow(File).to receive(:
|
646
|
+
allow(File).to receive(:exist?).with("/proc/self/cgroup").and_return(false)
|
647
647
|
plugin.run
|
648
648
|
expect(plugin[:virtualization]).to eq({'systems' => {}})
|
649
649
|
end
|
650
650
|
|
651
651
|
it "sets virtualization if /.dockerenv exists" do
|
652
|
-
allow(File).to receive(:
|
652
|
+
allow(File).to receive(:exist?).with("/.dockerenv").and_return(true)
|
653
653
|
plugin.run
|
654
654
|
expect(plugin[:virtualization][:system]).to eq("docker")
|
655
655
|
expect(plugin[:virtualization][:role]).to eq("guest")
|
@@ -657,7 +657,7 @@ CGROUP
|
|
657
657
|
end
|
658
658
|
|
659
659
|
it "sets virtualization if /.dockerinit exists" do
|
660
|
-
allow(File).to receive(:
|
660
|
+
allow(File).to receive(:exist?).with("/.dockerinit").and_return(true)
|
661
661
|
plugin.run
|
662
662
|
expect(plugin[:virtualization][:system]).to eq("docker")
|
663
663
|
expect(plugin[:virtualization][:role]).to eq("guest")
|
@@ -665,8 +665,8 @@ CGROUP
|
|
665
665
|
end
|
666
666
|
|
667
667
|
it "does not set virtualization if /.dockerenv or /.dockerinit does not exists" do
|
668
|
-
allow(File).to receive(:
|
669
|
-
allow(File).to receive(:
|
668
|
+
allow(File).to receive(:exist?).with("/.dockerenv").and_return(false)
|
669
|
+
allow(File).to receive(:exist?).with("/.dockerinit").and_return(false)
|
670
670
|
plugin.run
|
671
671
|
expect(plugin[:virtualization]).to eq({'systems' => {}})
|
672
672
|
end
|
@@ -20,222 +20,252 @@
|
|
20
20
|
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
|
21
21
|
|
22
22
|
describe Ohai::System, 'plugin packages' do
|
23
|
-
context
|
23
|
+
context "when the packages plugin is disabled" do
|
24
|
+
before do
|
25
|
+
Ohai.config[:plugin][:packages][:enabled] = false
|
26
|
+
allow(plugin).to receive(:collect_os).and_return(platform_family.to_s)
|
27
|
+
plugin.run
|
28
|
+
end
|
29
|
+
|
24
30
|
let(:plugin) do
|
25
31
|
get_plugin('packages').tap do |plugin|
|
26
|
-
plugin[:platform_family] =
|
32
|
+
plugin[:platform_family] = platform_family
|
27
33
|
end
|
28
34
|
end
|
29
35
|
|
30
|
-
|
31
|
-
|
32
|
-
|
36
|
+
[:debian, :fedora, :windows, :aix, :solaris2].each do |os|
|
37
|
+
context "on #{os}" do
|
38
|
+
let(:platform_family) { os }
|
33
39
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
.and_return(mock_shell_out(0, stdout, ''))
|
39
|
-
plugin.run
|
40
|
+
it "does not enumerate the packages" do
|
41
|
+
expect(plugin[:packages]).to eq(nil)
|
42
|
+
end
|
43
|
+
end
|
40
44
|
end
|
45
|
+
end
|
41
46
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
.and_return(mock_shell_out(0, stdout, ''))
|
46
|
-
plugin.run
|
47
|
+
context "when the packages plugin is enabled" do
|
48
|
+
before do
|
49
|
+
Ohai.config[:plugin][:packages][:enabled] = true
|
47
50
|
end
|
48
51
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
52
|
+
context 'on debian' do
|
53
|
+
let(:plugin) do
|
54
|
+
get_plugin('packages').tap do |plugin|
|
55
|
+
plugin[:platform_family] = 'debian'
|
56
|
+
end
|
57
|
+
end
|
53
58
|
|
54
|
-
|
55
|
-
|
56
|
-
get_plugin('packages').tap do |plugin|
|
57
|
-
plugin[:platform_family] = 'fedora'
|
59
|
+
let(:stdout) do
|
60
|
+
File.read(File.join(SPEC_PLUGIN_PATH, 'dpkg-query.output'))
|
58
61
|
end
|
59
|
-
end
|
60
62
|
|
61
|
-
|
63
|
+
before(:each) do
|
64
|
+
allow(plugin).to receive(:collect_os).and_return(:linux)
|
65
|
+
allow(plugin).to receive(:shell_out)
|
66
|
+
.with('dpkg-query -W')
|
67
|
+
.and_return(mock_shell_out(0, stdout, ''))
|
68
|
+
plugin.run
|
69
|
+
end
|
62
70
|
|
63
|
-
|
64
|
-
|
65
|
-
|
71
|
+
it 'calls dpkg query' do
|
72
|
+
expect(plugin).to receive(:shell_out)
|
73
|
+
.with('dpkg-query -W')
|
74
|
+
.and_return(mock_shell_out(0, stdout, ''))
|
75
|
+
plugin.run
|
76
|
+
end
|
66
77
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
plugin.run
|
78
|
+
it 'gets packages and versions' do
|
79
|
+
expect(plugin[:packages]['vim-common'][:version]).to eq('2:7.4.052-1ubuntu3')
|
80
|
+
end
|
71
81
|
end
|
72
82
|
|
73
|
-
|
74
|
-
|
75
|
-
.
|
76
|
-
|
77
|
-
|
78
|
-
|
83
|
+
context 'on fedora' do
|
84
|
+
let(:plugin) do
|
85
|
+
get_plugin('packages').tap do |plugin|
|
86
|
+
plugin[:platform_family] = 'fedora'
|
87
|
+
end
|
88
|
+
end
|
79
89
|
|
80
|
-
|
81
|
-
expect(plugin[:packages]['vim-common'][:version]).to eq('7.2.411')
|
82
|
-
expect(plugin[:packages]['vim-common'][:release]).to eq('1.8.el6')
|
83
|
-
end
|
84
|
-
end
|
90
|
+
let(:format) { Shellwords.escape '%{NAME}\t%{VERSION}\t%{RELEASE}\n' }
|
85
91
|
|
86
|
-
|
87
|
-
|
92
|
+
let(:stdout) do
|
93
|
+
File.read(File.join(SPEC_PLUGIN_PATH, 'rpmquery.output'))
|
94
|
+
end
|
88
95
|
|
89
|
-
|
90
|
-
|
91
|
-
plugin
|
96
|
+
before(:each) do
|
97
|
+
allow(plugin).to receive(:collect_os).and_return(:linux)
|
98
|
+
allow(plugin).to receive(:shell_out).with("rpm -qa --queryformat #{format}").and_return(mock_shell_out(0, stdout, ''))
|
99
|
+
plugin.run
|
92
100
|
end
|
93
|
-
end
|
94
101
|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
'identifyingnumber' => '{22FA28AB-3C1B-438B-A8B5-E23892C8B567}',
|
102
|
-
'installdate' => '20150511',
|
103
|
-
'installdate2' => nil,
|
104
|
-
'installlocation' => nil,
|
105
|
-
'installsource' => 'C:\\chef\\cache\\',
|
106
|
-
'installstate' => 5,
|
107
|
-
'language' => '1033',
|
108
|
-
'localpackage' => 'C:\\Windows\\Installer\\30884.msi',
|
109
|
-
'name' => 'NXLOG-CE',
|
110
|
-
'packagecache' => 'C:\\Windows\\Installer\\30884.msi',
|
111
|
-
'packagecode' => '{EC3A13C4-4634-47FC-9662-DC293CB96F9F}',
|
112
|
-
'packagename' => 'nexlog-ce-2.8.1248.msi',
|
113
|
-
'productid' => nil,
|
114
|
-
'regcompany' => nil,
|
115
|
-
'regowner' => nil,
|
116
|
-
'skunumber' => nil,
|
117
|
-
'transforms' => nil,
|
118
|
-
'urlinfoabout' => nil,
|
119
|
-
'urlupdateinfo' => nil,
|
120
|
-
'vendor' => 'nxsec.com',
|
121
|
-
'version' => '2.8.1248',
|
122
|
-
'wordcount' => 2 },
|
123
|
-
{ 'assignmenttype' => 1,
|
124
|
-
'caption' => 'Chef Development Kit v0.7.0',
|
125
|
-
'description' => 'Chef Development Kit v0.7.0',
|
126
|
-
'helplink' => 'http://www.getchef.com/support/',
|
127
|
-
'helptelephone' => nil,
|
128
|
-
'identifyingnumber' => '{90754A33-404C-4172-8F3B-7F04CE98011C}',
|
129
|
-
'installdate' => '20150925', 'installdate2' => nil,
|
130
|
-
'installlocation' => nil,
|
131
|
-
'installsource' => 'C:\\Users\\skhajamohid1\\Downloads\\',
|
132
|
-
'installstate' => 5, 'language' => '1033',
|
133
|
-
'localpackage' => 'C:\\WINDOWS\\Installer\\d9e1ca7.msi',
|
134
|
-
'name' => 'Chef Development Kit v0.7.0',
|
135
|
-
'packagecache' => 'C:\\WINDOWS\\Installer\\d9e1ca7.msi',
|
136
|
-
'packagecode' => '{9B82FB86-40AE-4CDF-9DE8-97574F9395B9}',
|
137
|
-
'packagename' => 'chefdk-0.7.0-1 (2).msi',
|
138
|
-
'productid' => nil,
|
139
|
-
'regcompany' => nil,
|
140
|
-
'regowner' => nil,
|
141
|
-
'skunumber' => nil,
|
142
|
-
'transforms' => nil,
|
143
|
-
'urlinfoabout' => nil,
|
144
|
-
'urlupdateinfo' => nil,
|
145
|
-
'vendor' => "\"Chef Software, Inc. <maintainers@chef.io>\"",
|
146
|
-
'version' => '0.7.0.1',
|
147
|
-
'wordcount' => 2 }]
|
148
|
-
end
|
102
|
+
it 'calls rpm -qa' do
|
103
|
+
expect(plugin).to receive(:shell_out)
|
104
|
+
.with("rpm -qa --queryformat #{format}")
|
105
|
+
.and_return(mock_shell_out(0, stdout, ''))
|
106
|
+
plugin.run
|
107
|
+
end
|
149
108
|
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
109
|
+
it 'gets packages and versions/release' do
|
110
|
+
expect(plugin[:packages]['vim-common'][:version]).to eq('7.2.411')
|
111
|
+
expect(plugin[:packages]['vim-common'][:release]).to eq('1.8.el6')
|
112
|
+
end
|
154
113
|
end
|
155
114
|
|
156
|
-
|
157
|
-
|
158
|
-
expect(plugin[:packages]['Chef Development Kit v0.7.0'][:vendor]).to eq("\"Chef Software, Inc. <maintainers@chef.io>\"")
|
159
|
-
expect(plugin[:packages]['Chef Development Kit v0.7.0'][:installdate]).to eq('20150925')
|
115
|
+
context 'on windows', :windows_only do
|
116
|
+
require 'wmi-lite'
|
160
117
|
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
118
|
+
let(:plugin) do
|
119
|
+
get_plugin('packages').tap do |plugin|
|
120
|
+
plugin[:platform_family] = 'windows'
|
121
|
+
end
|
122
|
+
end
|
166
123
|
|
167
|
-
|
168
|
-
|
124
|
+
let(:win32_product_output) do
|
125
|
+
[{ 'assignmenttype' => 0,
|
126
|
+
'caption' => 'NXLOG-CE',
|
127
|
+
'description' => 'NXLOG-CE',
|
128
|
+
'helplink' => nil,
|
129
|
+
'helptelephone' => nil,
|
130
|
+
'identifyingnumber' => '{22FA28AB-3C1B-438B-A8B5-E23892C8B567}',
|
131
|
+
'installdate' => '20150511',
|
132
|
+
'installdate2' => nil,
|
133
|
+
'installlocation' => nil,
|
134
|
+
'installsource' => 'C:\\chef\\cache\\',
|
135
|
+
'installstate' => 5,
|
136
|
+
'language' => '1033',
|
137
|
+
'localpackage' => 'C:\\Windows\\Installer\\30884.msi',
|
138
|
+
'name' => 'NXLOG-CE',
|
139
|
+
'packagecache' => 'C:\\Windows\\Installer\\30884.msi',
|
140
|
+
'packagecode' => '{EC3A13C4-4634-47FC-9662-DC293CB96F9F}',
|
141
|
+
'packagename' => 'nexlog-ce-2.8.1248.msi',
|
142
|
+
'productid' => nil,
|
143
|
+
'regcompany' => nil,
|
144
|
+
'regowner' => nil,
|
145
|
+
'skunumber' => nil,
|
146
|
+
'transforms' => nil,
|
147
|
+
'urlinfoabout' => nil,
|
148
|
+
'urlupdateinfo' => nil,
|
149
|
+
'vendor' => 'nxsec.com',
|
150
|
+
'version' => '2.8.1248',
|
151
|
+
'wordcount' => 2 },
|
152
|
+
{ 'assignmenttype' => 1,
|
153
|
+
'caption' => 'Chef Development Kit v0.7.0',
|
154
|
+
'description' => 'Chef Development Kit v0.7.0',
|
155
|
+
'helplink' => 'http://www.getchef.com/support/',
|
156
|
+
'helptelephone' => nil,
|
157
|
+
'identifyingnumber' => '{90754A33-404C-4172-8F3B-7F04CE98011C}',
|
158
|
+
'installdate' => '20150925', 'installdate2' => nil,
|
159
|
+
'installlocation' => nil,
|
160
|
+
'installsource' => 'C:\\Users\\skhajamohid1\\Downloads\\',
|
161
|
+
'installstate' => 5, 'language' => '1033',
|
162
|
+
'localpackage' => 'C:\\WINDOWS\\Installer\\d9e1ca7.msi',
|
163
|
+
'name' => 'Chef Development Kit v0.7.0',
|
164
|
+
'packagecache' => 'C:\\WINDOWS\\Installer\\d9e1ca7.msi',
|
165
|
+
'packagecode' => '{9B82FB86-40AE-4CDF-9DE8-97574F9395B9}',
|
166
|
+
'packagename' => 'chefdk-0.7.0-1 (2).msi',
|
167
|
+
'productid' => nil,
|
168
|
+
'regcompany' => nil,
|
169
|
+
'regowner' => nil,
|
170
|
+
'skunumber' => nil,
|
171
|
+
'transforms' => nil,
|
172
|
+
'urlinfoabout' => nil,
|
173
|
+
'urlupdateinfo' => nil,
|
174
|
+
'vendor' => "\"Chef Software, Inc. <maintainers@chef.io>\"",
|
175
|
+
'version' => '0.7.0.1',
|
176
|
+
'wordcount' => 2 }]
|
177
|
+
end
|
169
178
|
|
170
|
-
|
171
|
-
|
172
|
-
|
179
|
+
before(:each) do
|
180
|
+
allow(plugin).to receive(:collect_os).and_return(:windows)
|
181
|
+
expect_any_instance_of(WmiLite::Wmi).to receive(:instances_of).with('Win32_Product').and_return(win32_product_output)
|
182
|
+
plugin.run
|
183
|
+
end
|
173
184
|
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
end
|
185
|
+
it 'gets package info' do
|
186
|
+
expect(plugin[:packages]['Chef Development Kit v0.7.0'][:version]).to eq('0.7.0.1')
|
187
|
+
expect(plugin[:packages]['Chef Development Kit v0.7.0'][:vendor]).to eq("\"Chef Software, Inc. <maintainers@chef.io>\"")
|
188
|
+
expect(plugin[:packages]['Chef Development Kit v0.7.0'][:installdate]).to eq('20150925')
|
179
189
|
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
plugin.run
|
190
|
+
expect(plugin[:packages]['NXLOG-CE'][:version]).to eq('2.8.1248')
|
191
|
+
expect(plugin[:packages]['NXLOG-CE'][:vendor]).to eq('nxsec.com')
|
192
|
+
expect(plugin[:packages]['NXLOG-CE'][:installdate]).to eq('20150511')
|
193
|
+
end
|
185
194
|
end
|
186
195
|
|
187
|
-
|
188
|
-
|
189
|
-
end
|
190
|
-
end
|
196
|
+
context 'on aix' do
|
197
|
+
let(:plugin) { get_plugin('packages') }
|
191
198
|
|
192
|
-
|
193
|
-
|
199
|
+
let(:stdout) do
|
200
|
+
File.read(File.join(SPEC_PLUGIN_PATH, 'lslpp.output'))
|
201
|
+
end
|
194
202
|
|
195
|
-
|
196
|
-
|
197
|
-
|
203
|
+
before(:each) do
|
204
|
+
allow(plugin).to receive(:collect_os).and_return(:aix)
|
205
|
+
allow(plugin).to receive(:shell_out).with('lslpp -L -q -c').and_return(mock_shell_out(0, stdout, ''))
|
206
|
+
plugin.run
|
207
|
+
end
|
198
208
|
|
199
|
-
|
200
|
-
|
201
|
-
|
209
|
+
it 'calls lslpp -L -q -c' do
|
210
|
+
expect(plugin).to receive(:shell_out)
|
211
|
+
.with('lslpp -L -q -c')
|
212
|
+
.and_return(mock_shell_out(0, stdout, ''))
|
213
|
+
plugin.run
|
214
|
+
end
|
202
215
|
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
allow(plugin).to receive(:shell_out).with('pkginfo -l').and_return(mock_shell_out(0, pkginfo_output, ''))
|
207
|
-
plugin.run
|
216
|
+
it 'gets packages with version' do
|
217
|
+
expect(plugin[:packages]['chef'][:version]).to eq('12.5.1.1')
|
218
|
+
end
|
208
219
|
end
|
209
220
|
|
210
|
-
|
211
|
-
|
212
|
-
.with('pkg list -H')
|
213
|
-
.and_return(mock_shell_out(0, pkglist_output, ''))
|
214
|
-
plugin.run
|
215
|
-
end
|
221
|
+
context 'on solaris2' do
|
222
|
+
let(:plugin) { get_plugin('packages') }
|
216
223
|
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
.and_return(mock_shell_out(0, pkginfo_output, ''))
|
221
|
-
plugin.run
|
222
|
-
end
|
224
|
+
let(:pkglist_output) do
|
225
|
+
File.read(File.join(SPEC_PLUGIN_PATH, 'pkglist.output'))
|
226
|
+
end
|
223
227
|
|
224
|
-
|
225
|
-
|
226
|
-
|
228
|
+
let(:pkginfo_output) do
|
229
|
+
File.read(File.join(SPEC_PLUGIN_PATH, 'pkginfo.output'))
|
230
|
+
end
|
227
231
|
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
+
before(:each) do
|
233
|
+
allow(plugin).to receive(:collect_os).and_return(:solaris2)
|
234
|
+
allow(plugin).to receive(:shell_out).with('pkg list -H').and_return(mock_shell_out(0, pkglist_output, ''))
|
235
|
+
allow(plugin).to receive(:shell_out).with('pkginfo -l').and_return(mock_shell_out(0, pkginfo_output, ''))
|
236
|
+
plugin.run
|
237
|
+
end
|
232
238
|
|
233
|
-
|
234
|
-
|
235
|
-
|
239
|
+
it 'calls pkg list -H' do
|
240
|
+
expect(plugin).to receive(:shell_out)
|
241
|
+
.with('pkg list -H')
|
242
|
+
.and_return(mock_shell_out(0, pkglist_output, ''))
|
243
|
+
plugin.run
|
244
|
+
end
|
236
245
|
|
237
|
-
|
238
|
-
|
246
|
+
it 'calls pkginfo -l' do
|
247
|
+
expect(plugin).to receive(:shell_out)
|
248
|
+
.with('pkginfo -l')
|
249
|
+
.and_return(mock_shell_out(0, pkginfo_output, ''))
|
250
|
+
plugin.run
|
251
|
+
end
|
252
|
+
|
253
|
+
it 'gets ips packages with version' do
|
254
|
+
expect(plugin[:packages]['chef'][:version]).to eq('12.5.1')
|
255
|
+
end
|
256
|
+
|
257
|
+
it 'gets ips packages with version and publisher' do
|
258
|
+
expect(plugin[:packages]['system/EMCpower'][:version]).to eq('6.0.0.1.0-3')
|
259
|
+
expect(plugin[:packages]['system/EMCpower'][:publisher]).to eq('emc.com')
|
260
|
+
end
|
261
|
+
|
262
|
+
it 'gets sysv packages with version' do
|
263
|
+
expect(plugin[:packages]['chef'][:version]).to eq('12.5.1')
|
264
|
+
end
|
265
|
+
|
266
|
+
it 'gets sysv packages with version' do
|
267
|
+
expect(plugin[:packages]['mqm'][:version]).to eq('7.0.1.4')
|
268
|
+
end
|
239
269
|
end
|
240
270
|
end
|
241
271
|
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.
|
4
|
+
version: 8.10.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: 2016-
|
11
|
+
date: 2016-02-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: systemu
|
@@ -582,7 +582,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
582
582
|
version: '0'
|
583
583
|
requirements: []
|
584
584
|
rubyforge_project:
|
585
|
-
rubygems_version: 2.4.
|
585
|
+
rubygems_version: 2.4.5
|
586
586
|
signing_key:
|
587
587
|
specification_version: 4
|
588
588
|
summary: Ohai profiles your system and emits JSON
|