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.
- checksums.yaml +4 -4
- data/README.md +93 -0
- data/bin/ohai +0 -9
- data/lib/ohai/mixin/ec2_metadata.rb +3 -2
- data/lib/ohai/plugins/freebsd/cpu.rb +9 -6
- data/lib/ohai/plugins/freebsd/virtualization.rb +2 -2
- data/lib/ohai/plugins/hostname.rb +6 -4
- data/lib/ohai/plugins/kernel.rb +19 -15
- data/lib/ohai/plugins/linux/mdadm.rb +75 -0
- data/lib/ohai/plugins/linux/network.rb +1 -1
- data/lib/ohai/plugins/linux/platform.rb +6 -0
- data/lib/ohai/plugins/linux/virtualization.rb +38 -4
- data/lib/ohai/plugins/passwd.rb +2 -1
- data/lib/ohai/plugins/solaris2/platform.rb +1 -1
- data/lib/ohai/plugins/uptime.rb +3 -3
- data/lib/ohai/plugins/windows/cpu.rb +14 -11
- data/lib/ohai/plugins/windows/filesystem.rb +9 -5
- data/lib/ohai/plugins/windows/network.rb +16 -9
- data/lib/ohai/util/file_helper.rb +35 -0
- data/lib/ohai/version.rb +1 -1
- data/spec/unit/plugins/freebsd/cpu_spec.rb +68 -0
- data/spec/unit/plugins/freebsd/virtualization_spec.rb +9 -13
- data/spec/unit/plugins/kernel_spec.rb +26 -15
- data/spec/unit/plugins/linux/mdadm_spec.rb +104 -0
- data/spec/unit/plugins/linux/platform_spec.rb +14 -0
- data/spec/unit/plugins/linux/virtualization_spec.rb +63 -16
- data/spec/unit/plugins/passwd_spec.rb +7 -0
- data/spec/unit/plugins/solaris2/platform_spec.rb +40 -0
- data/spec/unit/util/file_helper_spec.rb +45 -0
- metadata +24 -5
- data/README.rdoc +0 -98
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 81416c96c35d5769f24aae74567e9937a5e1798a
|
4
|
+
data.tar.gz: 44012ca9a21be521454fe2123e73391c31f9177d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d77a851d7feb9394295e5c5165b1a5ea2e97c1e4364e945e931fb177dcbd052c4aa3cf9600f64bcd07468780b6a468d1db070126e61e88d526a3fd65353eaca
|
7
|
+
data.tar.gz: 9e8fca70a6e332456131d6e770a538253a29f739639776f1276d6f3dc849cee3487b6410592fb0404a1e943eca06794d44260696f69e16815b0c231a57744beb
|
data/README.md
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
# ohai
|
2
|
+
|
3
|
+
# DESCRIPTION:
|
4
|
+
|
5
|
+
Ohai detects data about your operating system. It can be used
|
6
|
+
standalone, but it's primary purpose is to provide node data to Chef.
|
7
|
+
|
8
|
+
Ohai will print out a JSON data blob for all the known data about your
|
9
|
+
system. When used with Chef, that data is reported back via node
|
10
|
+
attributes.
|
11
|
+
|
12
|
+
Chef distributes ohai as a RubyGem. This README is for developers who
|
13
|
+
want to modify the Ohai source code. For users who want to write plugins
|
14
|
+
for Ohai, see the docs:
|
15
|
+
|
16
|
+
* General documentation: http://docs.opscode.com/ohai.html
|
17
|
+
* Custom plugin documentation: http://docs.opscode.com/ohai_custom.html
|
18
|
+
|
19
|
+
# DEVELOPMENT:
|
20
|
+
|
21
|
+
Before working on the code, if you plan to contribute your changes, you
|
22
|
+
should read the contributing guidelines:
|
23
|
+
|
24
|
+
* https://github.com/opscode/ohai/blob/master/CONTRIBUTING.md
|
25
|
+
|
26
|
+
The basic process for contributing is:
|
27
|
+
|
28
|
+
1. Fork this repo on GitHub.
|
29
|
+
2. Create a feature branch for your work.
|
30
|
+
3. Make your change, including tests.
|
31
|
+
4. Submit a pull request.
|
32
|
+
|
33
|
+
# ENVIRONMENT:
|
34
|
+
|
35
|
+
Ohai's development dependencies should be installed with bundler. Just
|
36
|
+
run `bundle install` in the root of the repo.
|
37
|
+
|
38
|
+
## Spec Testing:
|
39
|
+
|
40
|
+
We use RSpec for unit/spec tests. To run the full suite, run:
|
41
|
+
|
42
|
+
bundle exec rake spec
|
43
|
+
|
44
|
+
You can run individual test files by running the rspec executable:
|
45
|
+
|
46
|
+
bundle exec rspec spec/unit/FILE.rb
|
47
|
+
|
48
|
+
## Rake Tasks
|
49
|
+
|
50
|
+
Ohai has some Rake tasks for doing various things.
|
51
|
+
|
52
|
+
rake -T
|
53
|
+
rake clobber_package # Remove package products
|
54
|
+
rake gem # Build the gem file ohai-$VERSION.gem
|
55
|
+
rake install # install the gem locally
|
56
|
+
rake make_spec # create a gemspec file
|
57
|
+
rake package # Build all the packages
|
58
|
+
rake repackage # Force a rebuild of the package files
|
59
|
+
rake spec # Run specs
|
60
|
+
|
61
|
+
($VERSION is the current version, from the GemSpec in Rakefile)
|
62
|
+
|
63
|
+
# LINKS:
|
64
|
+
|
65
|
+
Source:
|
66
|
+
|
67
|
+
* http://github.com/opscode/ohai/tree/master
|
68
|
+
|
69
|
+
Tickets/Issues:
|
70
|
+
|
71
|
+
* http://tickets.opscode.com/
|
72
|
+
|
73
|
+
(Use the OHAI project)
|
74
|
+
|
75
|
+
# LICENSE:
|
76
|
+
|
77
|
+
Ohai - system information application
|
78
|
+
|
79
|
+
Author:: Adam Jacob (<adam@getchef.com>)
|
80
|
+
Copyright:: Copyright (c) 2008-2014 Chef Software, Inc.
|
81
|
+
License:: Apache License, Version 2.0
|
82
|
+
|
83
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
84
|
+
you may not use this file except in compliance with the License.
|
85
|
+
You may obtain a copy of the License at
|
86
|
+
|
87
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
88
|
+
|
89
|
+
Unless required by applicable law or agreed to in writing, software
|
90
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
91
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
92
|
+
See the License for the specific language governing permissions and
|
93
|
+
limitations under the License.
|
data/bin/ohai
CHANGED
@@ -99,9 +99,10 @@ module Ohai
|
|
99
99
|
end
|
100
100
|
|
101
101
|
def metadata_get(id, api_version)
|
102
|
-
|
102
|
+
path = "/#{api_version}/meta-data/#{id}"
|
103
|
+
response = http_client.get(path)
|
103
104
|
unless response.code == '200'
|
104
|
-
raise "Encountered error retrieving EC2 metadata (returned #{response.code} response)"
|
105
|
+
raise "Encountered error retrieving EC2 metadata (#{path} returned #{response.code} response)"
|
105
106
|
end
|
106
107
|
response
|
107
108
|
end
|
@@ -24,12 +24,15 @@ Ohai.plugin(:CPU) do
|
|
24
24
|
# identical processors is probably a hardware requirement so we'll duplicate data for each cpu
|
25
25
|
# old examples: http://www.bnv-bamberg.de/home/ba3294/smp/rbuild/index.htm
|
26
26
|
cpuinfo = Mash.new
|
27
|
+
cpuinfo["flags"] = []
|
27
28
|
|
28
29
|
# /var/run/dmesg.boot
|
29
|
-
#CPU:
|
30
|
-
#
|
31
|
-
#
|
32
|
-
#
|
30
|
+
# CPU: Intel(R) Core(TM) i7-3615QM CPU @ 2.30GHz (3516.61-MHz K8-class CPU)
|
31
|
+
# Origin = "GenuineIntel" Id = 0x306a9 Family = 6 Model = 3a Stepping = 9
|
32
|
+
# Features=0x783fbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,MMX,FXSR,SSE,SSE2>
|
33
|
+
# Features2=0x209<SSE3,MON,SSSE3>
|
34
|
+
# AMD Features=0x28100800<SYSCALL,NX,RDTSCP,LM>
|
35
|
+
# AMD Features2=0x1<LAHF>
|
33
36
|
|
34
37
|
File.open("/var/run/dmesg.boot").each do |line|
|
35
38
|
case line
|
@@ -39,9 +42,9 @@ Ohai.plugin(:CPU) do
|
|
39
42
|
when /Origin = "(.+)"\s+Id = (.+)\s+Stepping = (.+)/
|
40
43
|
cpuinfo["vendor_id"] = $1
|
41
44
|
cpuinfo["stepping"] = $3
|
42
|
-
# These _should_ match /AMD Features2?/ lines as well
|
45
|
+
# These _should_ match /AMD Features2?/ lines as well
|
43
46
|
when /Features=.+<(.+)>/
|
44
|
-
cpuinfo["flags"]
|
47
|
+
cpuinfo["flags"].concat($1.downcase.split(','))
|
45
48
|
# Features2=0x80000001<SSE3,<b31>>
|
46
49
|
when /Features2=[a-f\dx]+<(.+)>/
|
47
50
|
cpuinfo["flags"].concat($1.downcase.split(','))
|
@@ -54,7 +54,7 @@ Ohai.plugin(:Virtualization) do
|
|
54
54
|
# Detect KVM/QEMU from cpu, report as KVM
|
55
55
|
# hw.model: QEMU Virtual CPU version 0.9.1
|
56
56
|
so = shell_out("sysctl -n hw.model")
|
57
|
-
if so.stdout.split($/)[0] =~ /QEMU Virtual CPU/
|
57
|
+
if so.stdout.split($/)[0] =~ /QEMU Virtual CPU|Common KVM processor|Common 32-bit KVM processor/
|
58
58
|
virtualization[:system] = "kvm"
|
59
59
|
virtualization[:role] = "guest"
|
60
60
|
end
|
@@ -83,7 +83,7 @@ Ohai.plugin(:Virtualization) do
|
|
83
83
|
when /Manufacturer: VMware/
|
84
84
|
found_virt_manufacturer = "vmware"
|
85
85
|
when /Product Name: VMware Virtual Platform/
|
86
|
-
if found_virt_manufacturer == "vmware"
|
86
|
+
if found_virt_manufacturer == "vmware"
|
87
87
|
virtualization[:system] = "vmware"
|
88
88
|
virtualization[:role] = "guest"
|
89
89
|
end
|
@@ -145,12 +145,14 @@ Ohai.plugin(:Hostname) do
|
|
145
145
|
end
|
146
146
|
|
147
147
|
collect_data(:windows) do
|
148
|
-
require '
|
148
|
+
require 'wmi-lite/wmi'
|
149
149
|
require 'socket'
|
150
150
|
|
151
|
-
|
152
|
-
|
153
|
-
|
151
|
+
wmi = WmiLite::Wmi.new
|
152
|
+
host = wmi.first_of('Win32_ComputerSystem')
|
153
|
+
|
154
|
+
hostname "#{host['name']}"
|
155
|
+
machinename "#{host['name']}"
|
154
156
|
|
155
157
|
info = Socket.gethostbyname(Socket.gethostname)
|
156
158
|
if info.first =~ /.+?\.(.*)/
|
data/lib/ohai/plugins/kernel.rb
CHANGED
@@ -155,15 +155,19 @@ Ohai.plugin(:Kernel) do
|
|
155
155
|
end
|
156
156
|
|
157
157
|
collect_data(:windows) do
|
158
|
-
require '
|
158
|
+
require 'win32ole'
|
159
|
+
require 'wmi-lite/wmi'
|
160
|
+
|
159
161
|
WIN32OLE.codepage = WIN32OLE::CP_UTF8
|
160
162
|
|
163
|
+
wmi = WmiLite::Wmi.new
|
164
|
+
|
161
165
|
kernel Mash.new
|
162
166
|
|
163
|
-
host =
|
167
|
+
host = wmi.first_of('Win32_OperatingSystem')
|
164
168
|
kernel[:os_info] = Mash.new
|
165
|
-
host.properties_.each do |p|
|
166
|
-
kernel[:os_info][p.name.wmi_underscore.to_sym] = host
|
169
|
+
host.wmi_ole_object.properties_.each do |p|
|
170
|
+
kernel[:os_info][p.name.wmi_underscore.to_sym] = host[p.name.downcase]
|
167
171
|
end
|
168
172
|
|
169
173
|
kernel[:name] = "#{kernel[:os_info][:caption]}"
|
@@ -171,10 +175,10 @@ Ohai.plugin(:Kernel) do
|
|
171
175
|
kernel[:version] = "#{kernel[:os_info][:version]} #{kernel[:os_info][:csd_version]} Build #{kernel[:os_info][:build_number]}"
|
172
176
|
kernel[:os] = os_lookup(kernel[:os_info][:os_type]) || languages[:ruby][:host_os]
|
173
177
|
|
174
|
-
host =
|
178
|
+
host = wmi.first_of('Win32_ComputerSystem')
|
175
179
|
kernel[:cs_info] = Mash.new
|
176
|
-
host.properties_.each do |p|
|
177
|
-
kernel[:cs_info][p.name.wmi_underscore.to_sym] = host
|
180
|
+
host.wmi_ole_object.properties_.each do |p|
|
181
|
+
kernel[:cs_info][p.name.wmi_underscore.to_sym] = host[p.name.downcase]
|
178
182
|
end
|
179
183
|
|
180
184
|
kernel[:machine] = machine_lookup("#{kernel[:cs_info][:system_type]}")
|
@@ -182,16 +186,16 @@ Ohai.plugin(:Kernel) do
|
|
182
186
|
kext = Mash.new
|
183
187
|
pnp_drivers = Mash.new
|
184
188
|
|
185
|
-
drivers =
|
189
|
+
drivers = wmi.instances_of('Win32_PnPSignedDriver')
|
186
190
|
drivers.each do |driver|
|
187
|
-
pnp_drivers[driver
|
188
|
-
driver.properties_.each do |p|
|
189
|
-
pnp_drivers[driver
|
191
|
+
pnp_drivers[driver['deviceid']] = Mash.new
|
192
|
+
driver.wmi_ole_object.properties_.each do |p|
|
193
|
+
pnp_drivers[driver['deviceid']][p.name.wmi_underscore.to_sym] = driver[p.name.downcase]
|
190
194
|
end
|
191
|
-
if driver
|
192
|
-
kext[driver
|
193
|
-
kext[driver
|
194
|
-
kext[driver
|
195
|
+
if driver['devicename']
|
196
|
+
kext[driver['devicename']] = pnp_drivers[driver['deviceid']]
|
197
|
+
kext[driver['devicename']][:version] = pnp_drivers[driver['deviceid']][:driver_version]
|
198
|
+
kext[driver['devicename']][:date] = pnp_drivers[driver['deviceid']][:driver_date] ? pnp_drivers[driver['deviceid']][:driver_date].to_s[0..7] : nil
|
195
199
|
end
|
196
200
|
end
|
197
201
|
|
@@ -0,0 +1,75 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Tim Smith <tsmith@limelight.com>
|
3
|
+
# Copyright:: Copyright (c) 2013-2014, Limelight Networks, Inc.
|
4
|
+
# Plugin:: mdadm
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
Ohai.plugin(:Mdadm) do
|
20
|
+
provides 'mdadm'
|
21
|
+
|
22
|
+
def create_raid_device_mash(stdout)
|
23
|
+
device_mash = Mash.new
|
24
|
+
device_mash[:device_counts] = Mash.new
|
25
|
+
stdout.lines.each do |line|
|
26
|
+
case line
|
27
|
+
when /Version\s+: ([0-9.]+)/
|
28
|
+
device_mash[:version] = Regexp.last_match[1].to_f
|
29
|
+
when /Raid Level\s+: raid([0-9]+)/
|
30
|
+
device_mash[:level] = Regexp.last_match[1].to_i
|
31
|
+
when /Array Size.*\(([0-9.]+)/
|
32
|
+
device_mash[:size] = Regexp.last_match[1].to_f
|
33
|
+
when /State\s+: ([a-z]+)/
|
34
|
+
device_mash[:state] = Regexp.last_match[1]
|
35
|
+
when /Total Devices\s+: ([0-9]+)/
|
36
|
+
device_mash[:device_counts][:total] = Regexp.last_match[1].to_i
|
37
|
+
when /Raid Devices\s+: ([0-9]+)/
|
38
|
+
device_mash[:device_counts][:raid] = Regexp.last_match[1].to_i
|
39
|
+
when /Working Devices\s+: ([0-9]+)/
|
40
|
+
device_mash[:device_counts][:working] = Regexp.last_match[1].to_i
|
41
|
+
when /Failed Devices\s+: ([0-9]+)/
|
42
|
+
device_mash[:device_counts][:failed] = Regexp.last_match[1].to_i
|
43
|
+
when /Active Devices\s+: ([0-9]+)/
|
44
|
+
device_mash[:device_counts][:active] = Regexp.last_match[1].to_i
|
45
|
+
when /Spare Devices\s+: ([0-9]+)/
|
46
|
+
device_mash[:device_counts][:spare] = Regexp.last_match[1].to_i
|
47
|
+
end
|
48
|
+
end
|
49
|
+
device_mash
|
50
|
+
end
|
51
|
+
|
52
|
+
collect_data(:linux) do
|
53
|
+
# gather a list of all raid arrays
|
54
|
+
if File.exist?('/proc/mdstat')
|
55
|
+
devices = []
|
56
|
+
File.open('/proc/mdstat').each do |line|
|
57
|
+
devices << Regexp.last_match[1] if line =~ /(md[0-9]+)/
|
58
|
+
end
|
59
|
+
|
60
|
+
# create the mdadm mash and gather individual information if devices are present
|
61
|
+
unless devices.empty?
|
62
|
+
mdadm Mash.new
|
63
|
+
devices.sort.each do |device|
|
64
|
+
mdadm[device] = Mash.new
|
65
|
+
|
66
|
+
# gather detailed information on the array
|
67
|
+
so = shell_out("mdadm --detail /dev/#{device}")
|
68
|
+
|
69
|
+
# if the mdadm command was sucessful pass so.stdout to create_raid_device_mash to grab the tidbits we want
|
70
|
+
mdadm[device] = create_raid_device_mash(so.stdout) if so.stdout
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -46,7 +46,7 @@ Ohai.plugin(:Network) do
|
|
46
46
|
# Match the lead line for an interface from iproute2
|
47
47
|
# 3: eth0.11@eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP
|
48
48
|
# The '@eth0:' portion doesn't exist on primary interfaces and thus is optional in the regex
|
49
|
-
IPROUTE_INT_REGEX = /^(\d+): ([0-9a-zA-Z@:\.\-_]*?)(@[0-9a-zA-Z]+|):\s/
|
49
|
+
IPROUTE_INT_REGEX = /^(\d+): ([0-9a-zA-Z@:\.\-_]*?)(@[0-9a-zA-Z]+|):\s/ unless defined? IPROUTE_INT_REGEX
|
50
50
|
|
51
51
|
if File.exist?("/sbin/ip")
|
52
52
|
|
@@ -83,6 +83,10 @@ Ohai.plugin(:Platform) do
|
|
83
83
|
platform "arch"
|
84
84
|
# no way to determine platform_version in a rolling release distribution
|
85
85
|
# kernel release will be used - ex. 2.6.32-ARCH
|
86
|
+
elsif File.exists?('/etc/exherbo-release')
|
87
|
+
platform "exherbo"
|
88
|
+
# no way to determine platform_version in a rolling release distribution
|
89
|
+
# kernel release will be used - ex. 3.13
|
86
90
|
elsif lsb[:id] =~ /RedHat/i
|
87
91
|
platform "redhat"
|
88
92
|
platform_version lsb[:release]
|
@@ -115,6 +119,8 @@ Ohai.plugin(:Platform) do
|
|
115
119
|
platform_family "slackware"
|
116
120
|
when /arch/
|
117
121
|
platform_family "arch"
|
122
|
+
when /exherbo/
|
123
|
+
platform_family "exherbo"
|
118
124
|
end
|
119
125
|
end
|
120
126
|
end
|
@@ -16,11 +16,20 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
|
19
|
+
require 'ohai/util/file_helper'
|
20
|
+
|
21
|
+
include Ohai::Util::FileHelper
|
22
|
+
|
19
23
|
Ohai.plugin(:Virtualization) do
|
20
24
|
provides "virtualization"
|
21
25
|
|
26
|
+
def lxc_version_exists?
|
27
|
+
which('lxc-version')
|
28
|
+
end
|
29
|
+
|
22
30
|
collect_data(:linux) do
|
23
|
-
virtualization Mash.new
|
31
|
+
virtualization Mash.new unless virtualization
|
32
|
+
virtualization[:systems] = Mash.new unless virtualization[:systems]
|
24
33
|
|
25
34
|
# if it is possible to detect paravirt vs hardware virt, it should be put in
|
26
35
|
# virtualization[:mechanism]
|
@@ -31,11 +40,13 @@ Ohai.plugin(:Virtualization) do
|
|
31
40
|
virtualization[:system] = "xen"
|
32
41
|
# Assume guest
|
33
42
|
virtualization[:role] = "guest"
|
43
|
+
virtualization[:systems][:xen] = "guest"
|
34
44
|
|
35
45
|
# This file should exist on most Xen systems, normally empty for guests
|
36
46
|
if File.exists?("/proc/xen/capabilities")
|
37
47
|
if File.read("/proc/xen/capabilities") =~ /control_d/i
|
38
48
|
virtualization[:role] = "host"
|
49
|
+
virtualization[:systems][:xen] = "host"
|
39
50
|
end
|
40
51
|
end
|
41
52
|
end
|
@@ -53,12 +64,15 @@ Ohai.plugin(:Virtualization) do
|
|
53
64
|
if modules =~ /^kvm/
|
54
65
|
virtualization[:system] = "kvm"
|
55
66
|
virtualization[:role] = "host"
|
67
|
+
virtualization[:systems][:kvm] = "host"
|
56
68
|
elsif modules =~ /^vboxdrv/
|
57
69
|
virtualization[:system] = "vbox"
|
58
70
|
virtualization[:role] = "host"
|
71
|
+
virtualization[:systems][:vbox] = "host"
|
59
72
|
elsif modules =~ /^vboxguest/
|
60
73
|
virtualization[:system] = "vbox"
|
61
74
|
virtualization[:role] = "guest"
|
75
|
+
virtualization[:systems][:vbox] = "guest"
|
62
76
|
end
|
63
77
|
end
|
64
78
|
|
@@ -71,6 +85,7 @@ Ohai.plugin(:Virtualization) do
|
|
71
85
|
if File.read("/proc/cpuinfo") =~ /QEMU Virtual CPU|Common KVM processor|Common 32-bit KVM processor/
|
72
86
|
virtualization[:system] = "kvm"
|
73
87
|
virtualization[:role] = "guest"
|
88
|
+
virtualization[:systems][:kvm] = "guest"
|
74
89
|
end
|
75
90
|
end
|
76
91
|
|
@@ -79,9 +94,11 @@ Ohai.plugin(:Virtualization) do
|
|
79
94
|
if File.exists?("/proc/bc/0")
|
80
95
|
virtualization[:system] = "openvz"
|
81
96
|
virtualization[:role] = "host"
|
97
|
+
virtualization[:systems][:openvz] = "host"
|
82
98
|
elsif File.exists?("/proc/vz")
|
83
99
|
virtualization[:system] = "openvz"
|
84
100
|
virtualization[:role] = "guest"
|
101
|
+
virtualization[:systems][:openvz] = "guest"
|
85
102
|
end
|
86
103
|
|
87
104
|
# http://www.dmo.ca/blog/detecting-virtualization-on-linux
|
@@ -92,21 +109,25 @@ Ohai.plugin(:Virtualization) do
|
|
92
109
|
if so.stdout =~ /Product Name: Virtual Machine/
|
93
110
|
virtualization[:system] = "virtualpc"
|
94
111
|
virtualization[:role] = "guest"
|
112
|
+
virtualization[:systems][:virtualpc] = "guest"
|
95
113
|
end
|
96
114
|
when /Manufacturer: VMware/
|
97
115
|
if so.stdout =~ /Product Name: VMware Virtual Platform/
|
98
116
|
virtualization[:system] = "vmware"
|
99
117
|
virtualization[:role] = "guest"
|
118
|
+
virtualization[:systems][:vmware] = "guest"
|
100
119
|
end
|
101
120
|
when /Manufacturer: Xen/
|
102
121
|
if so.stdout =~ /Product Name: HVM domU/
|
103
122
|
virtualization[:system] = "xen"
|
104
123
|
virtualization[:role] = "guest"
|
124
|
+
virtualization[:systems][:xen] = "guest"
|
105
125
|
end
|
106
126
|
when /Manufacturer: Oracle Corporation/
|
107
127
|
if so.stdout =~ /Product Name: VirtualBox/
|
108
128
|
virtualization[:system] = "vbox"
|
109
129
|
virtualization[:role] = "guest"
|
130
|
+
virtualization[:systems][:vbox] = "guest"
|
110
131
|
end
|
111
132
|
else
|
112
133
|
nil
|
@@ -121,8 +142,10 @@ Ohai.plugin(:Virtualization) do
|
|
121
142
|
virtualization[:system] = "linux-vserver"
|
122
143
|
if vxid[2] == "0"
|
123
144
|
virtualization[:role] = "host"
|
145
|
+
virtualization[:systems]["linux-vserver"] = "host"
|
124
146
|
else
|
125
147
|
virtualization[:role] = "guest"
|
148
|
+
virtualization[:systems]["linux-vserver"] = "guest"
|
126
149
|
end
|
127
150
|
end
|
128
151
|
end
|
@@ -149,9 +172,20 @@ Ohai.plugin(:Virtualization) do
|
|
149
172
|
if File.read("/proc/self/cgroup") =~ %r{^\d+:[^:]+:/(lxc|docker)/.+$}
|
150
173
|
virtualization[:system] = "lxc"
|
151
174
|
virtualization[:role] = "guest"
|
152
|
-
|
153
|
-
|
154
|
-
|
175
|
+
virtualization[:systems][:lxc] = "guest"
|
176
|
+
elsif lxc_version_exists? && File.read("/proc/self/cgroup") =~ %r{\d:[^:]+:/$}
|
177
|
+
# lxc-version shouldn't be installed by default
|
178
|
+
# Even so, it is likely we are on an LXC capable host that is not being used as such
|
179
|
+
# So we're cautious here to not overwrite other existing values (OHAI-573)
|
180
|
+
unless virtualization[:system] && virtualization[:role]
|
181
|
+
virtualization[:system] = "lxc"
|
182
|
+
virtualization[:role] = "host"
|
183
|
+
end
|
184
|
+
|
185
|
+
# In general, the 'systems' framework from OHAI-182 is less susceptible to conflicts
|
186
|
+
# But, this could overwrite virtualization[:systems][:lxc] = "guest"
|
187
|
+
# If so, we may need to look further for a differentiator (OHAI-573)
|
188
|
+
virtualization[:systems][:lxc] = "host"
|
155
189
|
end
|
156
190
|
end
|
157
191
|
end
|