ohai 17.7.12 → 17.9.0
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/plugins/chef.rb +1 -1
- data/lib/ohai/plugins/rpm.rb +12 -2
- data/lib/ohai/plugins/vmware.rb +22 -2
- data/lib/ohai/runner.rb +1 -1
- data/lib/ohai/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4d6aab3006a40779de433a6634b5be22fcb2ed1950c4b67d22eaa1fc18cc8993
|
4
|
+
data.tar.gz: ae3152a23474650f3d5c497ff8e966273a14656dc6d8f454ce4ac769a6259f1a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d7331b209e4d513403cd87949ab0eb4f65a00597da848e22042c2658734cd999c9419ea2fa135e8fcb253eb69c97881324ccbb519198726ba445aec71cb8732
|
7
|
+
data.tar.gz: 6673a8e0fcdaa7cc26fddf35ef54fc88169bcccbecb9f00d85cfa3584661c0c4803869c86b71615f9f69a65dd45aefdd0e22bd6a3a426a34ab8180370312f49e
|
data/lib/ohai/plugins/chef.rb
CHANGED
@@ -33,7 +33,7 @@ Ohai.plugin(:Chef) do
|
|
33
33
|
begin
|
34
34
|
require "chef/version"
|
35
35
|
require "chef-config/config" unless defined?(ChefConfig::Config)
|
36
|
-
rescue
|
36
|
+
rescue LoadError
|
37
37
|
logger.trace("Plugin Chef: Unable to load the chef gem to determine the version")
|
38
38
|
# this catches when you've done a major version bump of ohai, but
|
39
39
|
# your chef gem is incompatible, so we can't load it in the same VM
|
data/lib/ohai/plugins/rpm.rb
CHANGED
@@ -91,17 +91,27 @@ Ohai.plugin(:Rpm) do
|
|
91
91
|
value = ""
|
92
92
|
lines[macros_start_idx + 1..macros_end_idx - 1].each do |line|
|
93
93
|
if line.start_with?("-")
|
94
|
+
# new macros are always prefixed by a dash
|
94
95
|
if name
|
96
|
+
# if we had parsed a macro before, store it
|
95
97
|
rpm[:macros][name] = value
|
96
98
|
name = nil
|
97
99
|
value = ""
|
98
|
-
else
|
99
|
-
_prefix, name, value = line.split(" ", 3)
|
100
100
|
end
|
101
|
+
|
102
|
+
# parse the new macro definition
|
103
|
+
_prefix, name, value = line.split(" ", 3)
|
101
104
|
else
|
105
|
+
# continuations have no prefix and just append to the previous one
|
102
106
|
value += "\n#{line}"
|
103
107
|
end
|
104
108
|
end
|
109
|
+
|
110
|
+
# Once we're done parsing all lines, we might have a parsed definition
|
111
|
+
# we haven't stored - if so, store it.
|
112
|
+
if name
|
113
|
+
rpm[:macros][name] = value
|
114
|
+
end
|
105
115
|
else
|
106
116
|
logger.trace("Plugin RPM: Could not find rpm. Skipping plugin.")
|
107
117
|
end
|
data/lib/ohai/plugins/vmware.rb
CHANGED
@@ -45,12 +45,14 @@ Ohai.plugin(:VMware) do
|
|
45
45
|
logger.trace("Plugin VMware: #{vmtools_path} not found")
|
46
46
|
else
|
47
47
|
vmware Mash.new
|
48
|
+
vmware[:host] = Mash.new
|
49
|
+
vmware[:guest] = Mash.new
|
48
50
|
begin
|
49
51
|
# vmware-toolbox-cmd stat <param> commands
|
50
52
|
# Iterate through each parameter supported by the "vwware-toolbox-cmd stat" command, assign value
|
51
53
|
# to attribute "vmware[:<parameter>]"
|
52
54
|
%w{hosttime speed sessionid balloon swap memlimit memres cpures cpulimit}.each do |param|
|
53
|
-
vmware[param] = from_cmd(
|
55
|
+
vmware[param] = from_cmd([vmtools_path, "stat", param])
|
54
56
|
if /UpdateInfo failed/.match?(vmware[param])
|
55
57
|
vmware[param] = nil
|
56
58
|
end
|
@@ -59,8 +61,23 @@ Ohai.plugin(:VMware) do
|
|
59
61
|
# Iterate through each parameter supported by the "vmware-toolbox-cmd status" command, assign value
|
60
62
|
# to attribute "vmware[:<parameter>]"
|
61
63
|
%w{upgrade timesync}.each do |param|
|
62
|
-
vmware[param] = from_cmd(
|
64
|
+
vmware[param] = from_cmd([vmtools_path, param, "status"])
|
63
65
|
end
|
66
|
+
# Distinguish hypervisors by presence of raw session data (vSphere only)
|
67
|
+
raw_session = from_cmd([vmtools_path, "stat", "raw", "json", "session"])
|
68
|
+
if raw_session.empty?
|
69
|
+
vmware[:host] = {
|
70
|
+
type: "vmware_desktop",
|
71
|
+
}
|
72
|
+
else
|
73
|
+
require "json" unless defined?(JSON)
|
74
|
+
session = JSON.parse(raw_session)
|
75
|
+
vmware[:host] = {
|
76
|
+
type: "vmware_vsphere",
|
77
|
+
version: session["version"],
|
78
|
+
}
|
79
|
+
end
|
80
|
+
vmware[:guest][:vmware_tools_version] = from_cmd([vmtools_path, "-v"]).split(" ").first
|
64
81
|
rescue
|
65
82
|
logger.trace("Plugin VMware: Error while collecting VMware guest attributes")
|
66
83
|
end
|
@@ -71,4 +88,7 @@ Ohai.plugin(:VMware) do
|
|
71
88
|
get_vm_attributes("/usr/bin/vmware-toolbox-cmd") if virtualization[:systems][:vmware]
|
72
89
|
end
|
73
90
|
|
91
|
+
collect_data(:windows) do
|
92
|
+
get_vm_attributes("C:/Program Files/VMWare/VMware Tools/VMwareToolboxCmd.exe") if virtualization[:systems][:vmware]
|
93
|
+
end
|
74
94
|
end
|
data/lib/ohai/runner.rb
CHANGED
@@ -61,7 +61,7 @@ module Ohai
|
|
61
61
|
rescue Ohai::Exceptions::Error, SystemExit # SystemExit: abort or exit from plug-in should exit Ohai with failure code
|
62
62
|
raise
|
63
63
|
rescue Exception => e
|
64
|
-
logger.
|
64
|
+
logger.warn("Plugin #{plugin.name} threw exception #{e.inspect} #{e.backtrace.join("\n")}")
|
65
65
|
end
|
66
66
|
end
|
67
67
|
logger.trace("Plugin #{plugin.name} took #{"%f" % elapsed.truncate(6)} seconds to run.")
|
data/lib/ohai/version.rb
CHANGED
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: 17.
|
4
|
+
version: 17.9.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: 2021-
|
11
|
+
date: 2021-12-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chef-config
|