ohai 14.6.2 → 14.8.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/ohai/mixin/gce_metadata.rb +5 -1
- data/lib/ohai/plugins/bsd/virtualization.rb +20 -22
- data/lib/ohai/plugins/linux/platform.rb +19 -8
- data/lib/ohai/plugins/linux/virtualization.rb +14 -0
- data/lib/ohai/version.rb +1 -1
- data/ohai.gemspec +2 -2
- data/spec/unit/plugins/bsd/virtualization_spec.rb +60 -65
- data/spec/unit/plugins/linux/platform_spec.rb +36 -4
- data/spec/unit/plugins/linux/virtualization_spec.rb +13 -0
- metadata +3 -23
- data/README.md +0 -88
- data/spec/data/plugins/___lib64___libc.so.6.output +0 -135
- data/spec/data/plugins/___lib___libc.so.6.output +0 -135
- data/spec/data/plugins/cc.output +0 -135
- data/spec/data/plugins/cl.output +0 -135
- data/spec/data/plugins/devenv.com.output +0 -135
- data/spec/data/plugins/env.output +0 -71
- data/spec/data/plugins/erl.output +0 -144
- data/spec/data/plugins/gcc.output +0 -135
- data/spec/data/plugins/groovy.output +0 -159
- data/spec/data/plugins/java.output +0 -143
- data/spec/data/plugins/lua.output +0 -143
- data/spec/data/plugins/node.output +0 -143
- data/spec/data/plugins/perl.output +0 -143
- data/spec/data/plugins/php.output +0 -159
- data/spec/data/plugins/python.output +0 -143
- data/spec/data/plugins/uname.output +0 -71
- data/spec/data/plugins/v7message.rb +0 -7
- data/spec/data/plugins/what.output +0 -135
- data/spec/data/plugins/xlc.output +0 -135
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 524e88334ac80fdc8ae183847f9eab6ef4cab298f39e15bc1e9eeb256a268794
|
4
|
+
data.tar.gz: dbdcd571211fed208f544f2a68b4499d9f0a7d45f8712ef8d7a9987a43abfeb4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0dc03263ccbc0fec35bde6fe7d60d184850a81832c35141232d5169dcf6fad84ade7f4d81b504923057526d403440da3cb91732e93447896c10f960981d22c32
|
7
|
+
data.tar.gz: 66c6a59004a0ab93466b8b66d09086801220ad28fce64dd3f549ac9865595c15b24c0a2bd70ddc0fda39a7e171bf022c377cbdee3565a3ba962c23a853b1b042
|
@@ -28,7 +28,11 @@ module Ohai
|
|
28
28
|
def http_get(uri)
|
29
29
|
conn = Net::HTTP.start(GCE_METADATA_ADDR)
|
30
30
|
conn.read_timeout = 6
|
31
|
-
conn.get(uri, {
|
31
|
+
conn.get(uri, {
|
32
|
+
"Metadata-Flavor" => "Google",
|
33
|
+
"User-Agent" => "chef-ohai/#{Ohai::VERSION}",
|
34
|
+
}
|
35
|
+
)
|
32
36
|
end
|
33
37
|
|
34
38
|
def fetch_metadata(id = "")
|
@@ -1,7 +1,7 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Bryan McLellan (btm@loftninjas.org)
|
3
3
|
# Copyright:: Copyright (c) 2009 Bryan McLellan
|
4
|
-
# Copyright:: Copyright (c) 2015-
|
4
|
+
# Copyright:: Copyright (c) 2015-2018 Chef Software, Inc.
|
5
5
|
# License:: Apache License, Version 2.0
|
6
6
|
#
|
7
7
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -76,7 +76,7 @@ Ohai.plugin(:Virtualization) do
|
|
76
76
|
# Detect KVM/QEMU paravirt guests from cpu, report as KVM
|
77
77
|
# hw.model: QEMU Virtual CPU version 0.9.1
|
78
78
|
so = shell_out("sysctl -n hw.model")
|
79
|
-
if so.stdout
|
79
|
+
if so.stdout =~ /QEMU Virtual CPU|KVM processor/
|
80
80
|
virtualization[:system] = "kvm"
|
81
81
|
virtualization[:role] = "guest"
|
82
82
|
virtualization[:systems][:kvm] = "guest"
|
@@ -87,27 +87,25 @@ Ohai.plugin(:Virtualization) do
|
|
87
87
|
# there are a limited number of hypervisors detected here, BUT it doesn't
|
88
88
|
# require dmidecode to be installed and dmidecode isn't in freebsd out of the box
|
89
89
|
so = shell_out("sysctl -n kern.vm_guest")
|
90
|
-
case so.stdout
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
when /bhyve/
|
107
|
-
virtualization[:system] = "bhyve"
|
90
|
+
hypervisor = case so.stdout
|
91
|
+
when /vmware/
|
92
|
+
"vmware"
|
93
|
+
when /hv/
|
94
|
+
"hyperv"
|
95
|
+
when /xen/
|
96
|
+
"xen"
|
97
|
+
when /kvm/
|
98
|
+
so = shell_out("sysctl -n kern.hostuuid")
|
99
|
+
so.stdout =~ /^ec2/ ? "amazonec2" : "kvm"
|
100
|
+
when /bhyve/
|
101
|
+
"bhyve"
|
102
|
+
end
|
103
|
+
|
104
|
+
if hypervisor
|
105
|
+
virtualization[:system] = hypervisor
|
108
106
|
virtualization[:role] = "guest"
|
109
|
-
virtualization[:systems][
|
110
|
-
logger.trace("Plugin Virtualization: Guest running on
|
107
|
+
virtualization[:systems][hypervisor.to_sym] = "guest"
|
108
|
+
logger.trace("Plugin Virtualization: Guest running on #{hypervisor} detected")
|
111
109
|
end
|
112
110
|
|
113
111
|
# parse dmidecode to discover various virtualization guests
|
@@ -127,7 +127,7 @@ Ohai.plugin(:Platform) do
|
|
127
127
|
when /debian/, /ubuntu/, /linuxmint/, /raspbian/, /cumulus/
|
128
128
|
# apt-get+dpkg almost certainly goes here
|
129
129
|
"debian"
|
130
|
-
when /oracle/, /centos/, /redhat/, /scientific/, /enterpriseenterprise/, /xenserver/, /cloudlinux/, /ibm_powerkvm/, /parallels/, /nexus_centos/, /clearos/, /bigip/ # Note that 'enterpriseenterprise' is oracle's LSB "distributor ID"
|
130
|
+
when /oracle/, /centos/, /redhat/, /scientific/, /enterpriseenterprise/, /xcp/, /xenserver/, /cloudlinux/, /ibm_powerkvm/, /parallels/, /nexus_centos/, /clearos/, /bigip/ # Note that 'enterpriseenterprise' is oracle's LSB "distributor ID"
|
131
131
|
# NOTE: "rhel" should be reserved exclusively for recompiled rhel versions that are nearly perfectly compatible down to the platform_version.
|
132
132
|
# The operating systems that are "rhel" should all be as compatible as rhel7 = centos7 = oracle7 = scientific7 (98%-ish core RPM version compatibility
|
133
133
|
# and the version numbers MUST track the upstream). The appropriate EPEL version repo should work nearly perfectly. Some variation like the
|
@@ -137,7 +137,7 @@ Ohai.plugin(:Platform) do
|
|
137
137
|
"rhel"
|
138
138
|
when /amazon/
|
139
139
|
"amazon"
|
140
|
-
when /suse/, /sles/, /opensuse/
|
140
|
+
when /suse/, /sles/, /opensuse/, /opensuseleap/, /sled/
|
141
141
|
"suse"
|
142
142
|
when /fedora/, /pidora/, /arista_eos/
|
143
143
|
# In the broadest sense: RPM-based, fedora-derived distributions which are not strictly re-compiled RHEL (if it uses RPMs, and smells more like redhat and less like
|
@@ -149,7 +149,7 @@ Ohai.plugin(:Platform) do
|
|
149
149
|
"gentoo"
|
150
150
|
when /slackware/
|
151
151
|
"slackware"
|
152
|
-
when /arch/
|
152
|
+
when /arch/, /manjaro/, /antergos/
|
153
153
|
"arch"
|
154
154
|
when /exherbo/
|
155
155
|
"exherbo"
|
@@ -157,6 +157,8 @@ Ohai.plugin(:Platform) do
|
|
157
157
|
"alpine"
|
158
158
|
when /clearlinux/
|
159
159
|
"clearlinux"
|
160
|
+
when /mangeia/
|
161
|
+
"mandriva"
|
160
162
|
end
|
161
163
|
end
|
162
164
|
|
@@ -196,6 +198,9 @@ Ohai.plugin(:Platform) do
|
|
196
198
|
contents = File.read("/etc/parallels-release").chomp
|
197
199
|
platform get_redhatish_platform(contents)
|
198
200
|
platform_version contents.match(/(\d\.\d\.\d)/)[0]
|
201
|
+
elsif File.exist?("/etc/Eos-release")
|
202
|
+
platform "arista_eos"
|
203
|
+
platform_version File.read("/etc/Eos-release").strip.split[-1]
|
199
204
|
elsif File.exist?("/etc/redhat-release")
|
200
205
|
if os_release_file_is_cisco? # Cisco guestshell
|
201
206
|
platform "nexus_centos"
|
@@ -224,10 +229,6 @@ Ohai.plugin(:Platform) do
|
|
224
229
|
else
|
225
230
|
platform "suse"
|
226
231
|
end
|
227
|
-
elsif File.exist?("/etc/Eos-release")
|
228
|
-
platform "arista_eos"
|
229
|
-
platform_version File.read("/etc/Eos-release").strip.split[-1]
|
230
|
-
platform_family "fedora"
|
231
232
|
elsif os_release_file_is_cisco?
|
232
233
|
raise "unknown Cisco /etc/os-release or /etc/cisco-release ID_LIKE field" if
|
233
234
|
os_release_info["ID_LIKE"].nil? || ! os_release_info["ID_LIKE"].include?("wrlinux")
|
@@ -283,6 +284,9 @@ Ohai.plugin(:Platform) do
|
|
283
284
|
elsif lsb[:id] =~ /XenServer/i
|
284
285
|
platform "xenserver"
|
285
286
|
platform_version lsb[:release]
|
287
|
+
elsif lsb[:id] =~ /XCP/i
|
288
|
+
platform "xcp"
|
289
|
+
platform_version lsb[:release]
|
286
290
|
elsif lsb[:id] # LSB can provide odd data that changes between releases, so we currently fall back on it rather than dealing with its subtleties
|
287
291
|
platform lsb[:id].downcase
|
288
292
|
platform_version lsb[:release]
|
@@ -291,7 +295,14 @@ Ohai.plugin(:Platform) do
|
|
291
295
|
# We have to do this for compatibility reasons, or older OS releases might get different
|
292
296
|
# "platform" or "platform_version" attributes (e.g. SLES12, RHEL7).
|
293
297
|
elsif File.exist?("/etc/os-release")
|
294
|
-
|
298
|
+
case os_release_info["ID"]
|
299
|
+
when "sles"
|
300
|
+
platform "suse" # SLES is wrong. We call it SUSE
|
301
|
+
when "opensuse-leap"
|
302
|
+
platform "opensuseleap"
|
303
|
+
else
|
304
|
+
platform os_release_info["ID"]
|
305
|
+
end
|
295
306
|
platform_version os_release_info["VERSION_ID"]
|
296
307
|
# platform_family also does not need to be hardcoded anymore.
|
297
308
|
# This would be the correct way, but we stick with "determine_platform_family" for compatibility reasons.
|
@@ -150,6 +150,17 @@ Ohai.plugin(:Virtualization) do
|
|
150
150
|
end
|
151
151
|
end
|
152
152
|
|
153
|
+
# Detect Hyper-V guest and the hostname of the host
|
154
|
+
if File.exist?("/var/lib/hyperv/.kvp_pool_3")
|
155
|
+
logger.trace("Plugin Virtualization: /var/lib/hyperv/.kvp_pool_3 contains string indicating Hyper-V guest")
|
156
|
+
data = File.read("/var/lib/hyperv/.kvp_pool_3")
|
157
|
+
hyperv_host = data[/\HostName(.*?)HostingSystemEditionId/, 1].scan(/[[:print:]]/).join.downcase
|
158
|
+
virtualization[:system] = "hyperv"
|
159
|
+
virtualization[:role] = "guest"
|
160
|
+
virtualization[:systems][:hyperv] = "guest"
|
161
|
+
virtualization[:hypervisor_host] = hyperv_host
|
162
|
+
end
|
163
|
+
|
153
164
|
# Detect Linux-VServer
|
154
165
|
if File.exist?("/proc/self/status")
|
155
166
|
proc_self_status = File.read("/proc/self/status")
|
@@ -212,6 +223,7 @@ Ohai.plugin(:Virtualization) do
|
|
212
223
|
logger.trace("Plugin Virtualization: /proc/self/cgroup and lxc-version command exist. Detecting as lxc host")
|
213
224
|
virtualization[:system] = "lxc"
|
214
225
|
virtualization[:role] = "host"
|
226
|
+
virtualization[:systems][:lxc] = "host"
|
215
227
|
end
|
216
228
|
# In general, the 'systems' framework from OHAI-182 is less susceptible to conflicts
|
217
229
|
# But, this could overwrite virtualization[:systems][:lxc] = "guest"
|
@@ -231,6 +243,7 @@ Ohai.plugin(:Virtualization) do
|
|
231
243
|
logger.trace("Plugin Virtualization: /dev/lxd/sock exists. Detecting as lxd guest")
|
232
244
|
virtualization[:system] = "lxd"
|
233
245
|
virtualization[:role] = "guest"
|
246
|
+
virtualization[:systems][:lxd] = "guest"
|
234
247
|
else
|
235
248
|
# 'How' LXD is installed dictates the runtime data location
|
236
249
|
#
|
@@ -245,6 +258,7 @@ Ohai.plugin(:Virtualization) do
|
|
245
258
|
logger.trace("Plugin Virtualization: #{devlxd} exists. Detecting as lxd host")
|
246
259
|
virtualization[:system] = "lxd"
|
247
260
|
virtualization[:role] = "host"
|
261
|
+
virtualization[:systems][:lxd] = "host"
|
248
262
|
break
|
249
263
|
end
|
250
264
|
end
|
data/lib/ohai/version.rb
CHANGED
data/ohai.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
|
|
10
10
|
s.license = "Apache-2.0"
|
11
11
|
s.author = "Adam Jacob"
|
12
12
|
s.email = "adam@chef.io"
|
13
|
-
s.homepage = "https://
|
13
|
+
s.homepage = "https://github.com/chef/ohai/"
|
14
14
|
|
15
15
|
s.required_ruby_version = ">= 2.4"
|
16
16
|
|
@@ -34,5 +34,5 @@ Gem::Specification.new do |s|
|
|
34
34
|
s.executables = %w{ohai}
|
35
35
|
|
36
36
|
s.require_path = "lib"
|
37
|
-
s.files = %w{LICENSE
|
37
|
+
s.files = %w{LICENSE Gemfile Rakefile} + Dir.glob("*.gemspec") + Dir.glob("{docs,lib,spec}/**/*")
|
38
38
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Bryan McLellan <btm@chef.io>
|
3
|
-
# Copyright:: Copyright (c) 2012-
|
3
|
+
# Copyright:: Copyright (c) 2012-2018 Chef Software, Inc.
|
4
4
|
# License:: Apache License, Version 2.0
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -19,54 +19,56 @@
|
|
19
19
|
require_relative "../../../spec_helper.rb"
|
20
20
|
|
21
21
|
describe Ohai::System, "BSD virtualization plugin" do
|
22
|
+
let(:plugin) { get_plugin("bsd/virtualization") }
|
23
|
+
|
22
24
|
before(:each) do
|
23
|
-
|
24
|
-
allow(
|
25
|
-
allow(
|
26
|
-
allow(
|
27
|
-
allow(
|
28
|
-
allow(
|
29
|
-
allow(
|
25
|
+
allow(plugin).to receive(:collect_os).and_return(:freebsd)
|
26
|
+
allow(plugin).to receive(:shell_out).with("sysctl -n security.jail.jailed").and_return(mock_shell_out(0, "0", ""))
|
27
|
+
allow(plugin).to receive(:shell_out).with((Ohai.abs_path( "/sbin/kldstat" )).to_s).and_return(mock_shell_out(0, "", ""))
|
28
|
+
allow(plugin).to receive(:shell_out).with("jls -nd").and_return(mock_shell_out(0, "", ""))
|
29
|
+
allow(plugin).to receive(:shell_out).with("sysctl -n hw.model").and_return(mock_shell_out(0, "", ""))
|
30
|
+
allow(plugin).to receive(:shell_out).with("sysctl -n kern.vm_guest").and_return(mock_shell_out(0, "", ""))
|
31
|
+
allow(plugin).to receive(:shell_out).with("sysctl -n kern.hostuuid").and_return(mock_shell_out(0, "", ""))
|
30
32
|
allow(File).to receive(:exist?).and_return false
|
31
33
|
end
|
32
34
|
|
33
35
|
context "when on a bhyve host" do
|
34
36
|
it "detects we are a host" do
|
35
37
|
allow(File).to receive(:exist?).with("/dev/vmm").and_return true
|
36
|
-
|
37
|
-
expect(
|
38
|
-
expect(
|
39
|
-
expect(
|
38
|
+
plugin.run
|
39
|
+
expect(plugin[:virtualization][:system]).to eq("bhyve")
|
40
|
+
expect(plugin[:virtualization][:role]).to eq("host")
|
41
|
+
expect(plugin[:virtualization][:systems][:bhyve]).to eq("host")
|
40
42
|
end
|
41
43
|
end
|
42
44
|
|
43
45
|
context "when on a bhyve guest" do
|
44
46
|
it "detects we are a guest" do
|
45
|
-
allow(
|
46
|
-
|
47
|
-
expect(
|
48
|
-
expect(
|
49
|
-
expect(
|
47
|
+
allow(plugin).to receive(:shell_out).with("sysctl -n kern.vm_guest").and_return(mock_shell_out(0, "bhyve", ""))
|
48
|
+
plugin.run
|
49
|
+
expect(plugin[:virtualization][:system]).to eq("bhyve")
|
50
|
+
expect(plugin[:virtualization][:role]).to eq("guest")
|
51
|
+
expect(plugin[:virtualization][:systems][:bhyve]).to eq("guest")
|
50
52
|
end
|
51
53
|
end
|
52
54
|
|
53
55
|
context "jails" do
|
54
56
|
it "detects we are in a jail" do
|
55
|
-
allow(
|
56
|
-
|
57
|
-
expect(
|
58
|
-
expect(
|
59
|
-
expect(
|
57
|
+
allow(plugin).to receive(:shell_out).with("sysctl -n security.jail.jailed").and_return(mock_shell_out(0, "1", ""))
|
58
|
+
plugin.run
|
59
|
+
expect(plugin[:virtualization][:system]).to eq("jail")
|
60
|
+
expect(plugin[:virtualization][:role]).to eq("guest")
|
61
|
+
expect(plugin[:virtualization][:systems][:jail]).to eq("guest")
|
60
62
|
end
|
61
63
|
|
62
64
|
it "detects we are hosting jails" do
|
63
65
|
# from http://www.freebsd.org/doc/handbook/jails-application.html
|
64
66
|
@jails = "JID IP Address Hostname Path\n 3 192.168.3.17 ns.example.org /home/j/ns\n 2 192.168.3.18 mail.example.org /home/j/mail\n 1 62.123.43.14 www.example.org /home/j/www"
|
65
|
-
allow(
|
66
|
-
|
67
|
-
expect(
|
68
|
-
expect(
|
69
|
-
expect(
|
67
|
+
allow(plugin).to receive(:shell_out).with("jls -nd").and_return(mock_shell_out(0, @jails, ""))
|
68
|
+
plugin.run
|
69
|
+
expect(plugin[:virtualization][:system]).to eq("jail")
|
70
|
+
expect(plugin[:virtualization][:role]).to eq("host")
|
71
|
+
expect(plugin[:virtualization][:systems][:jail]).to eq("host")
|
70
72
|
end
|
71
73
|
end
|
72
74
|
|
@@ -77,14 +79,14 @@ describe Ohai::System, "BSD virtualization plugin" do
|
|
77
79
|
1 40 0xffffffff80100000 d20428 kernel
|
78
80
|
7 3 0xffffffff81055000 41e88 vboxguest.ko
|
79
81
|
OUT
|
80
|
-
allow(
|
82
|
+
allow(plugin).to receive(:shell_out).with((Ohai.abs_path("/sbin/kldstat")).to_s).and_return(mock_shell_out(0, @vbox_guest, ""))
|
81
83
|
end
|
82
84
|
|
83
85
|
it "detects we are a guest" do
|
84
|
-
|
85
|
-
expect(
|
86
|
-
expect(
|
87
|
-
expect(
|
86
|
+
plugin.run
|
87
|
+
expect(plugin[:virtualization][:system]).to eq("vbox")
|
88
|
+
expect(plugin[:virtualization][:role]).to eq("guest")
|
89
|
+
expect(plugin[:virtualization][:systems][:vbox]).to eq("guest")
|
88
90
|
end
|
89
91
|
end
|
90
92
|
|
@@ -95,56 +97,49 @@ OUT
|
|
95
97
|
1 40 0xffffffff80100000 d20428 kernel
|
96
98
|
7 3 0xffffffff81055000 41e88 vboxdrv.ko
|
97
99
|
OUT
|
98
|
-
allow(
|
100
|
+
allow(plugin).to receive(:shell_out).with("/sbin/kldstat").and_return(mock_shell_out(0, @stdout, ""))
|
99
101
|
end
|
100
102
|
|
101
103
|
it "detects we are a host" do
|
102
|
-
|
103
|
-
expect(
|
104
|
-
expect(
|
105
|
-
expect(
|
104
|
+
plugin.run
|
105
|
+
expect(plugin[:virtualization][:system]).to eq("vbox")
|
106
|
+
expect(plugin[:virtualization][:role]).to eq("host")
|
107
|
+
expect(plugin[:virtualization][:systems][:vbox]).to eq("host")
|
106
108
|
end
|
107
109
|
end
|
108
110
|
|
109
111
|
context "when on a QEMU guest" do
|
110
112
|
it "detects we are a guest" do
|
111
113
|
[ "Common KVM processor", 'QEMU Virtual CPU version (cpu64-rhel6) ("GenuineIntel" 686-class)', "Common 32-bit KVM processor"].each do |kvm_string|
|
112
|
-
allow(
|
113
|
-
|
114
|
-
expect(
|
115
|
-
expect(
|
116
|
-
expect(
|
114
|
+
allow(plugin).to receive(:shell_out).with("sysctl -n hw.model").and_return(mock_shell_out(0, kvm_string, ""))
|
115
|
+
plugin.run
|
116
|
+
expect(plugin[:virtualization][:system]).to eq("kvm")
|
117
|
+
expect(plugin[:virtualization][:role]).to eq("guest")
|
118
|
+
expect(plugin[:virtualization][:systems][:kvm]).to eq("guest")
|
117
119
|
end
|
118
120
|
end
|
119
121
|
end
|
120
122
|
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
context "when on a vmware guest" do
|
132
|
-
it "detects we are a guest" do
|
133
|
-
allow(@plugin).to receive(:shell_out).with("sysctl -n kern.vm_guest").and_return(mock_shell_out(0, "vmware", ""))
|
134
|
-
@plugin.run
|
135
|
-
expect(@plugin[:virtualization][:system]).to eq("vmware")
|
136
|
-
expect(@plugin[:virtualization][:role]).to eq("guest")
|
137
|
-
expect(@plugin[:virtualization][:systems][:vmware]).to eq("guest")
|
123
|
+
{ xen: "xen", vmware: "vmware", hyperv: "hv", kvm: "kvm", bhyve: "bhyve" }.each_pair do |hypervisor, val|
|
124
|
+
context "when on a #{hypervisor} guest" do
|
125
|
+
it "detects we are a guest" do
|
126
|
+
allow(plugin).to receive(:shell_out).with("sysctl -n kern.vm_guest").and_return(mock_shell_out(0, val, ""))
|
127
|
+
plugin.run
|
128
|
+
expect(plugin[:virtualization][:system]).to eq(hypervisor.to_s)
|
129
|
+
expect(plugin[:virtualization][:role]).to eq("guest")
|
130
|
+
expect(plugin[:virtualization][:systems][hypervisor]).to eq("guest")
|
131
|
+
end
|
138
132
|
end
|
139
133
|
end
|
140
134
|
|
141
|
-
context "when on
|
135
|
+
context "when on an amazonec2 guest" do
|
142
136
|
it "detects we are a guest" do
|
143
|
-
allow(
|
144
|
-
|
145
|
-
|
146
|
-
expect(
|
147
|
-
expect(
|
137
|
+
allow(plugin).to receive(:shell_out).with("sysctl -n kern.vm_guest").and_return(mock_shell_out(0, "kvm", ""))
|
138
|
+
allow(plugin).to receive(:shell_out).with("sysctl -n kern.hostuuid").and_return(mock_shell_out(0, "ec2fb75c-7a36-7938-4efa-8e40b4ac634b", ""))
|
139
|
+
plugin.run
|
140
|
+
expect(plugin[:virtualization][:system]).to eq("amazonec2")
|
141
|
+
expect(plugin[:virtualization][:role]).to eq("guest")
|
142
|
+
expect(plugin[:virtualization][:systems][:amazonec2]).to eq("guest")
|
148
143
|
end
|
149
144
|
end
|
150
145
|
end
|
@@ -296,6 +296,8 @@ OS_RELEASE
|
|
296
296
|
|
297
297
|
describe "on arista eos" do
|
298
298
|
|
299
|
+
let(:have_system_release) { true }
|
300
|
+
let(:have_redhat_release) { true }
|
299
301
|
let(:have_eos_release) { true }
|
300
302
|
|
301
303
|
before(:each) do
|
@@ -303,11 +305,11 @@ OS_RELEASE
|
|
303
305
|
end
|
304
306
|
|
305
307
|
it "should set platform to arista_eos" do
|
306
|
-
expect(File).to receive(:read).with("/etc/Eos-release").and_return("Arista Networks EOS 4.
|
308
|
+
expect(File).to receive(:read).with("/etc/Eos-release").and_return("Arista Networks EOS 4.21.1.1F")
|
307
309
|
@plugin.run
|
308
310
|
expect(@plugin[:platform]).to eq("arista_eos")
|
309
311
|
expect(@plugin[:platform_family]).to eq("fedora")
|
310
|
-
expect(@plugin[:platform_version]).to eq("4.
|
312
|
+
expect(@plugin[:platform_version]).to eq("4.21.1.1F")
|
311
313
|
end
|
312
314
|
end
|
313
315
|
|
@@ -701,8 +703,39 @@ CISCO_RELEASE
|
|
701
703
|
end
|
702
704
|
|
703
705
|
describe "on suse" do
|
706
|
+
context "on openSUSE 15+" do
|
707
|
+
|
708
|
+
let(:have_suse_release) { false }
|
709
|
+
let(:have_os_release) { true }
|
710
|
+
|
711
|
+
let(:os_release_content) do
|
712
|
+
<<~OS_RELEASE
|
713
|
+
NAME="openSUSE Leap"
|
714
|
+
VERSION="15.0"
|
715
|
+
ID="opensuse-leap"
|
716
|
+
ID_LIKE="suse opensuse"
|
717
|
+
VERSION_ID="15.0"
|
718
|
+
PRETTY_NAME="openSUSE Leap 15.0"
|
719
|
+
ANSI_COLOR="0;32"
|
720
|
+
CPE_NAME="cpe:/o:opensuse:leap:15.0"
|
721
|
+
OS_RELEASE
|
722
|
+
end
|
723
|
+
|
724
|
+
before do
|
725
|
+
expect(File).to_not receive(:read).with("/etc/SuSE-release")
|
726
|
+
expect(File).to receive(:read).with("/etc/os-release").and_return(os_release_content)
|
727
|
+
end
|
704
728
|
|
705
|
-
|
729
|
+
it "correctly detects opensuseleap 15" do
|
730
|
+
@plugin.run
|
731
|
+
expect(@plugin[:platform]).to eq("opensuseleap")
|
732
|
+
expect(@plugin[:platform_version]).to eq("15.0")
|
733
|
+
expect(@plugin[:platform_family]).to eq("suse")
|
734
|
+
end
|
735
|
+
|
736
|
+
end
|
737
|
+
|
738
|
+
context "on SLES 15+" do
|
706
739
|
|
707
740
|
let(:have_suse_release) { false }
|
708
741
|
let(:have_os_release) { true }
|
@@ -732,7 +765,6 @@ OS_RELEASE
|
|
732
765
|
expect(@plugin[:platform_version]).to eq("15")
|
733
766
|
expect(@plugin[:platform_family]).to eq("suse")
|
734
767
|
end
|
735
|
-
|
736
768
|
end
|
737
769
|
|
738
770
|
context "on versions that have both /etc/os-release and /etc/SuSE-release (e.g. SLES12)" do
|