ohai 15.0.35 → 15.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ohai.rb +4 -4
- data/lib/ohai/application.rb +3 -3
- data/lib/ohai/config.rb +2 -2
- data/lib/ohai/dsl.rb +2 -2
- data/lib/ohai/dsl/plugin.rb +5 -5
- data/lib/ohai/hints.rb +1 -1
- data/lib/ohai/loader.rb +4 -4
- data/lib/ohai/mixin/azure_metadata.rb +3 -3
- data/lib/ohai/mixin/command.rb +3 -3
- data/lib/ohai/mixin/do_metadata.rb +3 -3
- data/lib/ohai/mixin/ec2_metadata.rb +6 -6
- data/lib/ohai/mixin/gce_metadata.rb +3 -3
- data/lib/ohai/mixin/http_helper.rb +1 -1
- data/lib/ohai/mixin/scaleway_metadata.rb +3 -3
- data/lib/ohai/mixin/softlayer_metadata.rb +2 -2
- data/lib/ohai/plugin_config.rb +1 -1
- data/lib/ohai/plugins/aix/network.rb +6 -6
- data/lib/ohai/plugins/azure.rb +2 -2
- data/lib/ohai/plugins/bsd/virtualization.rb +2 -2
- data/lib/ohai/plugins/darwin/network.rb +14 -13
- data/lib/ohai/plugins/darwin/virtualization.rb +1 -1
- data/lib/ohai/plugins/digital_ocean.rb +2 -2
- data/lib/ohai/plugins/dmi.rb +3 -3
- data/lib/ohai/plugins/dragonflybsd/network.rb +9 -9
- data/lib/ohai/plugins/ec2.rb +2 -2
- data/lib/ohai/plugins/eucalyptus.rb +2 -2
- data/lib/ohai/plugins/filesystem.rb +5 -5
- data/lib/ohai/plugins/freebsd/network.rb +9 -9
- data/lib/ohai/plugins/gce.rb +2 -2
- data/lib/ohai/plugins/hostname.rb +2 -2
- data/lib/ohai/plugins/kernel.rb +1 -1
- data/lib/ohai/plugins/linux/fips.rb +1 -1
- data/lib/ohai/plugins/linux/network.rb +18 -18
- data/lib/ohai/plugins/linux/platform.rb +1 -3
- data/lib/ohai/plugins/linux/sessions.rb +2 -2
- data/lib/ohai/plugins/linux/virtualization.rb +2 -2
- data/lib/ohai/plugins/netbsd/network.rb +9 -9
- data/lib/ohai/plugins/network.rb +3 -3
- data/lib/ohai/plugins/openbsd/network.rb +9 -9
- data/lib/ohai/plugins/openstack.rb +2 -2
- data/lib/ohai/plugins/os.rb +1 -1
- data/lib/ohai/plugins/packages.rb +6 -8
- data/lib/ohai/plugins/passwd.rb +1 -1
- data/lib/ohai/plugins/scaleway.rb +2 -2
- data/lib/ohai/plugins/scsi.rb +1 -1
- data/lib/ohai/plugins/softlayer.rb +1 -1
- data/lib/ohai/plugins/solaris2/dmi.rb +2 -2
- data/lib/ohai/plugins/solaris2/network.rb +9 -9
- data/lib/ohai/plugins/solaris2/virtualization.rb +1 -1
- data/lib/ohai/plugins/uptime.rb +1 -1
- data/lib/ohai/plugins/virtualbox.rb +164 -19
- data/lib/ohai/plugins/windows/filesystem.rb +1 -1
- data/lib/ohai/plugins/windows/fips.rb +1 -1
- data/lib/ohai/plugins/windows/network.rb +3 -3
- data/lib/ohai/plugins/windows/virtualization.rb +2 -2
- data/lib/ohai/provides_map.rb +4 -4
- data/lib/ohai/runner.rb +1 -1
- data/lib/ohai/system.rb +15 -15
- data/lib/ohai/util/win32.rb +1 -1
- data/lib/ohai/version.rb +1 -1
- data/spec/unit/plugins/solaris2/network_spec.rb +10 -1
- data/spec/unit/plugins/vbox_host_spec.rb +14 -0
- data/spec/unit/plugins/virtualbox_spec.rb +310 -23
- metadata +3 -2
data/lib/ohai/plugins/network.rb
CHANGED
@@ -18,7 +18,7 @@
|
|
18
18
|
|
19
19
|
Ohai.plugin(:NetworkAddresses) do
|
20
20
|
require "ipaddress"
|
21
|
-
|
21
|
+
require_relative "../mixin/network_constants"
|
22
22
|
include Ohai::Mixin::NetworkConstants
|
23
23
|
|
24
24
|
provides "ipaddress", "ip6address", "macaddress"
|
@@ -135,9 +135,9 @@ Ohai.plugin(:NetworkAddresses) do
|
|
135
135
|
results = {}
|
136
136
|
|
137
137
|
network Mash.new unless network
|
138
|
-
network[:interfaces]
|
138
|
+
network[:interfaces] ||= Mash.new
|
139
139
|
counters Mash.new unless counters
|
140
|
-
counters[:network]
|
140
|
+
counters[:network] ||= Mash.new
|
141
141
|
|
142
142
|
# inet family is processed before inet6 to give ipv4 precedence
|
143
143
|
Ohai::Mixin::NetworkConstants::FAMILIES.keys.sort.each do |family|
|
@@ -22,9 +22,9 @@ Ohai.plugin(:Network) do
|
|
22
22
|
|
23
23
|
collect_data(:openbsd) do
|
24
24
|
network Mash.new unless network
|
25
|
-
network[:interfaces]
|
25
|
+
network[:interfaces] ||= Mash.new
|
26
26
|
counters Mash.new unless counters
|
27
|
-
counters[:network]
|
27
|
+
counters[:network] ||= Mash.new
|
28
28
|
|
29
29
|
so = shell_out("route -n get default")
|
30
30
|
so.stdout.lines do |line|
|
@@ -52,11 +52,11 @@ Ohai.plugin(:Network) do
|
|
52
52
|
end
|
53
53
|
# call the family lladdr to match linux for consistency
|
54
54
|
if line =~ /\s+lladdr (.+?)\s/
|
55
|
-
iface[cint][:addresses]
|
55
|
+
iface[cint][:addresses] ||= Mash.new
|
56
56
|
iface[cint][:addresses][$1] = { "family" => "lladdr" }
|
57
57
|
end
|
58
58
|
if line =~ /\s+inet ([\d.]+) netmask ([\da-fx]+)\s*\w*\s*([\d.]*)/
|
59
|
-
iface[cint][:addresses]
|
59
|
+
iface[cint][:addresses] ||= Mash.new
|
60
60
|
# convert the netmask to decimal for consistency
|
61
61
|
netmask = "#{$2[2, 2].hex}.#{$2[4, 2].hex}.#{$2[6, 2].hex}.#{$2[8, 2].hex}"
|
62
62
|
if $3.empty?
|
@@ -67,7 +67,7 @@ Ohai.plugin(:Network) do
|
|
67
67
|
end
|
68
68
|
end
|
69
69
|
if line =~ /\s+inet6 ([a-f0-9\:]+)%?(\w*)\s+prefixlen\s+(\d+)\s*\w*\s*([\da-fx]*)/
|
70
|
-
iface[cint][:addresses]
|
70
|
+
iface[cint][:addresses] ||= Mash.new
|
71
71
|
if $4.empty?
|
72
72
|
iface[cint][:addresses][$1] = { "family" => "inet6", "prefixlen" => $3 }
|
73
73
|
else
|
@@ -89,7 +89,7 @@ Ohai.plugin(:Network) do
|
|
89
89
|
so.stdout.lines do |line|
|
90
90
|
if line =~ /\((\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\) at ([a-fA-F0-9\:]+) on ([0-9a-zA-Z\.\:\-]+)/
|
91
91
|
next unless iface[$3] # this should never happen
|
92
|
-
iface[$3][:arp]
|
92
|
+
iface[$3][:arp] ||= Mash.new
|
93
93
|
iface[$3][:arp][$1] = $2.downcase
|
94
94
|
end
|
95
95
|
end
|
@@ -107,9 +107,9 @@ Ohai.plugin(:Network) do
|
|
107
107
|
# em0 1500 <Link> 00:11:25:2d:90:be 3719557 0 3369969 0 0 0
|
108
108
|
# $1 $2 $3 $4 $5 $6 $7 $8
|
109
109
|
if line =~ /^([\w\.\*]+)\s+\d+\s+<Link>\s+([\w:]*)\s*(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/
|
110
|
-
net_counters[$1]
|
111
|
-
net_counters[$1]["rx"]
|
112
|
-
net_counters[$1]["tx"]
|
110
|
+
net_counters[$1] ||= Mash.new
|
111
|
+
net_counters[$1]["rx"] ||= Mash.new
|
112
|
+
net_counters[$1]["tx"] ||= Mash.new
|
113
113
|
net_counters[$1]["rx"]["packets"] = $3
|
114
114
|
net_counters[$1]["rx"]["errors"] = $4
|
115
115
|
net_counters[$1]["tx"]["packets"] = $5
|
@@ -17,8 +17,8 @@
|
|
17
17
|
# limitations under the License.
|
18
18
|
|
19
19
|
Ohai.plugin(:Openstack) do
|
20
|
-
|
21
|
-
|
20
|
+
require_relative "../mixin/ec2_metadata"
|
21
|
+
require_relative "../mixin/http_helper"
|
22
22
|
include Ohai::Mixin::Ec2Metadata
|
23
23
|
include Ohai::Mixin::HttpHelper
|
24
24
|
|
data/lib/ohai/plugins/os.rb
CHANGED
@@ -22,13 +22,11 @@ Ohai.plugin(:Packages) do
|
|
22
22
|
provides "packages"
|
23
23
|
depends "platform_family"
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
}.freeze
|
31
|
-
end
|
25
|
+
WINDOWS_ATTRIBUTE_ALIASES ||= {
|
26
|
+
"DisplayVersion" => "version",
|
27
|
+
"Publisher" => "publisher",
|
28
|
+
"InstallDate" => "installdate",
|
29
|
+
}.freeze
|
32
30
|
|
33
31
|
collect_data(:linux) do
|
34
32
|
packages Mash.new
|
@@ -104,7 +102,7 @@ Ohai.plugin(:Packages) do
|
|
104
102
|
end
|
105
103
|
|
106
104
|
collect_data(:windows) do
|
107
|
-
require "win32/registry"
|
105
|
+
require "win32/registry" unless defined?(Win32::Registry)
|
108
106
|
packages Mash.new
|
109
107
|
collect_programs_from_registry_key('Software\Microsoft\Windows\CurrentVersion\Uninstall')
|
110
108
|
# on 64 bit systems, 32 bit programs are stored here
|
data/lib/ohai/plugins/passwd.rb
CHANGED
@@ -15,8 +15,8 @@
|
|
15
15
|
# limitations under the License.
|
16
16
|
|
17
17
|
Ohai.plugin(:Scaleway) do
|
18
|
-
|
19
|
-
|
18
|
+
require_relative "../mixin/scaleway_metadata"
|
19
|
+
require_relative "../mixin/http_helper"
|
20
20
|
|
21
21
|
include Ohai::Mixin::ScalewayMetadata
|
22
22
|
include Ohai::Mixin::HttpHelper
|
data/lib/ohai/plugins/scsi.rb
CHANGED
@@ -20,7 +20,7 @@ Ohai.plugin(:DMI) do
|
|
20
20
|
provides "dmi"
|
21
21
|
|
22
22
|
collect_data(:solaris2) do
|
23
|
-
|
23
|
+
require_relative "../../common/dmi"
|
24
24
|
|
25
25
|
# if we already have a "dmi" with keys (presumably from dmidecode), don't try smbios
|
26
26
|
# note that a single key just means dmidecode exited with its version
|
@@ -142,7 +142,7 @@ Ohai.plugin(:DMI) do
|
|
142
142
|
next
|
143
143
|
end
|
144
144
|
|
145
|
-
dmi[dmi_record[:type]]
|
145
|
+
dmi[dmi_record[:type]] ||= Mash.new
|
146
146
|
dmi[dmi_record[:type]][:all_records] = [] unless dmi[dmi_record[:type]].key?(:all_records)
|
147
147
|
dmi_record[:position] = dmi[dmi_record[:type]][:all_records].length
|
148
148
|
dmi[dmi_record[:type]][:all_records].push(Mash.new)
|
@@ -95,18 +95,18 @@ Ohai.plugin(:Network) do
|
|
95
95
|
|
96
96
|
iface = Mash.new
|
97
97
|
network Mash.new unless network
|
98
|
-
network[:interfaces]
|
98
|
+
network[:interfaces] ||= Mash.new
|
99
99
|
counters Mash.new unless counters
|
100
|
-
counters[:network]
|
100
|
+
counters[:network] ||= Mash.new
|
101
101
|
|
102
102
|
so = shell_out("ifconfig -a")
|
103
103
|
cint = nil
|
104
104
|
|
105
105
|
so.stdout.lines do |line|
|
106
|
-
# regex:
|
107
|
-
if line =~ /^([0-9a-zA-Z\.\:\-]+): \S+ mtu (\d+) index (\d+)
|
106
|
+
# regex: https://rubular.com/r/ZiIHbsnfiWPW1p
|
107
|
+
if line =~ /^([0-9a-zA-Z\.\:\-]+): \S+ mtu (\d+)(?: index (\d+))?/
|
108
108
|
cint = $1
|
109
|
-
iface[cint]
|
109
|
+
iface[cint] ||= Mash.new
|
110
110
|
iface[cint][:mtu] = $2
|
111
111
|
iface[cint][:index] = $3
|
112
112
|
if line =~ / flags\=\d+\<((ADDRCONF|ANYCAST|BROADCAST|CoS|DEPRECATED|DHCP|DUPLICATE|FAILED|FIXEDMTU|INACTIVE|L3PROTECT|LOOPBACK|MIP|MULTI_BCAST|MULTICAST|NOARP|NOFAILOVER|NOLOCAL|NONUD|NORTEXCH|NOXMIT|OFFLINE|PHYSRUNNING|POINTOPOINT|PREFERRED|PRIVATE|ROUTER|RUNNING|STANDBY|TEMPORARY|UNNUMBERED|UP|VIRTUAL|XRESOLV|IPv4|IPv6|,)+)\>\s/
|
@@ -122,15 +122,15 @@ Ohai.plugin(:Network) do
|
|
122
122
|
end
|
123
123
|
end
|
124
124
|
if line =~ /\s+inet (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) netmask (([0-9a-f]){1,8})\s*$/
|
125
|
-
iface[cint][:addresses]
|
125
|
+
iface[cint][:addresses] ||= Mash.new
|
126
126
|
iface[cint][:addresses][$1] = { "family" => "inet", "netmask" => $2.scanf("%2x" * 4) * "." }
|
127
127
|
end
|
128
128
|
if line =~ /\s+inet (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) netmask (([0-9a-f]){1,8}) broadcast (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/
|
129
|
-
iface[cint][:addresses]
|
129
|
+
iface[cint][:addresses] ||= Mash.new
|
130
130
|
iface[cint][:addresses][$1] = { "family" => "inet", "netmask" => $2.scanf("%2x" * 4) * ".", "broadcast" => $4 }
|
131
131
|
end
|
132
132
|
if line =~ /\s+inet6 ([a-f0-9\:]+)(\s*|(\%[a-z0-9]+)\s*)\/(\d+)\s*$/
|
133
|
-
iface[cint][:addresses]
|
133
|
+
iface[cint][:addresses] ||= Mash.new
|
134
134
|
iface[cint][:addresses][$1] = { "family" => "inet6", "prefixlen" => $4 }
|
135
135
|
end
|
136
136
|
end
|
@@ -141,7 +141,7 @@ Ohai.plugin(:Network) do
|
|
141
141
|
so.stdout.lines do |line|
|
142
142
|
if line =~ /([0-9a-zA-Z]+)\s+(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\s+(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\s+(\w+)?\s+([a-zA-Z0-9\.\:\-]+)/
|
143
143
|
next unless iface[arpname_to_ifname(iface, $1)] # this should never happen, except on solaris because sun hates you.
|
144
|
-
iface[arpname_to_ifname(iface, $1)][:arp]
|
144
|
+
iface[arpname_to_ifname(iface, $1)][:arp] ||= Mash.new
|
145
145
|
iface[arpname_to_ifname(iface, $1)][:arp][$2] = $5
|
146
146
|
end
|
147
147
|
end
|
data/lib/ohai/plugins/uptime.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
#
|
2
|
-
# Author::
|
3
|
-
#
|
2
|
+
# Author:: Tim Smith <tsmith@chef.io>
|
3
|
+
# Author:: Joshua Colson <joshua.colson@gmail.com>
|
4
|
+
# Copyright:: 2015-2019 Chef Software, Inc.
|
5
|
+
# Copyright:: 2019 Joshua Colson
|
4
6
|
# License:: Apache License, Version 2.0
|
5
7
|
#
|
6
8
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -17,33 +19,176 @@
|
|
17
19
|
#
|
18
20
|
|
19
21
|
Ohai.plugin(:Virtualbox) do
|
22
|
+
depends "virtualization"
|
20
23
|
provides "virtualbox"
|
21
24
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
+
# query virtualbox for each configured vm, as well as
|
26
|
+
# each guest's individual configuration settings
|
27
|
+
def vboxmanage_list_vms
|
28
|
+
vms = Mash.new
|
29
|
+
so_cmd = "VBoxManage list --sorted vms"
|
30
|
+
logger.trace(so_cmd)
|
31
|
+
so = shell_out(so_cmd)
|
25
32
|
|
26
33
|
if so.exitstatus == 0
|
27
|
-
|
28
|
-
virtualbox[:host] = Mash.new
|
29
|
-
virtualbox[:guest] = Mash.new
|
34
|
+
# parse the output
|
30
35
|
so.stdout.lines.each do |line|
|
31
36
|
case line
|
32
|
-
when
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
when /VBoxRev, value: (\S*),/
|
37
|
-
virtualbox[:host][:revision] = Regexp.last_match(1)
|
38
|
-
when /GuestAdd\/VersionExt, value: (\S*),/
|
39
|
-
virtualbox[:guest][:guest_additions_version] = Regexp.last_match(1)
|
40
|
-
when /GuestAdd\/Revision, value: (\S*),/
|
41
|
-
virtualbox[:guest][:guest_additions_revision] = Regexp.last_match(1)
|
37
|
+
when /^"(\S*)" \{(\S*)\}$/
|
38
|
+
name = Regexp.last_match(1)
|
39
|
+
uuid = Regexp.last_match(2)
|
40
|
+
vms[name] = vboxmanage_vminfo(uuid)
|
42
41
|
end
|
43
42
|
end
|
44
43
|
end
|
44
|
+
vms
|
45
45
|
rescue Ohai::Exceptions::Exec
|
46
|
-
logger.trace(
|
46
|
+
logger.trace("Plugin VboxHost: Could not run 'VBoxManage list --sorted vms'. Skipping data")
|
47
|
+
end
|
48
|
+
|
49
|
+
# query the vminfo for particular guest instance, normalizing
|
50
|
+
# the fields so that they're not enclosed in double-quotes (")
|
51
|
+
def vboxmanage_vminfo(machine_id)
|
52
|
+
vm = Mash.new
|
53
|
+
|
54
|
+
so_cmd = "VBoxManage showvminfo #{machine_id} --machinereadable"
|
55
|
+
logger.trace(so_cmd)
|
56
|
+
so = shell_out(so_cmd)
|
57
|
+
|
58
|
+
if so.exitstatus == 0
|
59
|
+
so.stdout.lines.each do |line|
|
60
|
+
line.chomp!
|
61
|
+
left, right = line.split("=")
|
62
|
+
|
63
|
+
# remove enclosing quotes, if needed
|
64
|
+
key = left.delete_prefix('"').delete_suffix('"')
|
65
|
+
|
66
|
+
# skip the name attribute since that is the parent key
|
67
|
+
next if key == "name"
|
68
|
+
|
69
|
+
vm[key.downcase] = right.delete_prefix('"').delete_suffix('"')
|
70
|
+
end
|
71
|
+
end
|
72
|
+
vm
|
73
|
+
rescue Ohai::Exceptions::Exec
|
74
|
+
logger.trace("Plugin VboxHost: Could not run '#{so_cmd}'. Skipping data")
|
75
|
+
end
|
76
|
+
|
77
|
+
# query virtualbox for a list of #{query_type} items
|
78
|
+
# these queries return a result set that is delimited by
|
79
|
+
# multiple successive newlines, with each block containing
|
80
|
+
# key/value pairs delimited by a colon (:) and column aligned
|
81
|
+
#
|
82
|
+
# the keys of each k/v pair are normalized to lowercase
|
83
|
+
def vboxmanage_list_blocks(query_type, name_key)
|
84
|
+
# ignore unrecognized query type
|
85
|
+
supported_queries = %w{
|
86
|
+
bridgedifs dhcpservers dvds hdds hostdvds
|
87
|
+
hostfloppies hostonlyifs natnets
|
88
|
+
}
|
89
|
+
return nil unless supported_queries.include? query_type
|
90
|
+
results = Mash.new
|
91
|
+
|
92
|
+
so_cmd = "VBoxManage list --sorted #{query_type}"
|
93
|
+
logger.trace(so_cmd)
|
94
|
+
so = shell_out(so_cmd)
|
95
|
+
# raise an exception if the command fails
|
96
|
+
# so.error!
|
97
|
+
|
98
|
+
if so.exitstatus == 0
|
99
|
+
# break the result into paragraph blocks, on successive newlines
|
100
|
+
so.stdout.each_line("") do |blk|
|
101
|
+
# remove the multiple newlines of each record
|
102
|
+
blk.chomp!.chomp!
|
103
|
+
# initialize a blank record hash
|
104
|
+
record = Mash.new
|
105
|
+
# parse the record block into key/value pairs
|
106
|
+
blk.each_line() do |line|
|
107
|
+
next unless line.include? ":"
|
108
|
+
# split the line into key/value pair
|
109
|
+
key, right = line.split(":", 2)
|
110
|
+
|
111
|
+
# strip the leading/trailing whitespace if the value is not nil
|
112
|
+
value = right.nil? ? "" : right.strip
|
113
|
+
record[key.downcase] = value
|
114
|
+
end
|
47
115
|
|
116
|
+
# insert the record into the list of results
|
117
|
+
if record.key? name_key.downcase
|
118
|
+
name = record.delete(name_key.downcase)
|
119
|
+
results[name] = record
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
results
|
124
|
+
rescue Ohai::Exceptions::Exec
|
125
|
+
logger.trace("Plugin VboxHost: Could not run '#{so_cmd}'. Skipping data")
|
126
|
+
end
|
127
|
+
|
128
|
+
collect_data(:default) do
|
129
|
+
case virtualization.dig("systems", "vbox")
|
130
|
+
when "guest"
|
131
|
+
logger.trace("Plugin Virtualbox: Node detected as vbox guest. Collecting guest data.")
|
132
|
+
begin
|
133
|
+
so = shell_out("VBoxControl guestproperty enumerate")
|
134
|
+
|
135
|
+
if so.exitstatus == 0
|
136
|
+
virtualbox Mash.new
|
137
|
+
virtualbox[:host] = Mash.new
|
138
|
+
virtualbox[:guest] = Mash.new
|
139
|
+
so.stdout.lines.each do |line|
|
140
|
+
case line
|
141
|
+
when /LanguageID, value: (\S*),/
|
142
|
+
virtualbox[:host][:language] = Regexp.last_match(1)
|
143
|
+
when /VBoxVer, value: (\S*),/
|
144
|
+
virtualbox[:host][:version] = Regexp.last_match(1)
|
145
|
+
when /VBoxRev, value: (\S*),/
|
146
|
+
virtualbox[:host][:revision] = Regexp.last_match(1)
|
147
|
+
when /GuestAdd\/VersionExt, value: (\S*),/
|
148
|
+
virtualbox[:guest][:guest_additions_version] = Regexp.last_match(1)
|
149
|
+
when /GuestAdd\/Revision, value: (\S*),/
|
150
|
+
virtualbox[:guest][:guest_additions_revision] = Regexp.last_match(1)
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
rescue Ohai::Exceptions::Exec
|
155
|
+
logger.trace('Plugin Virtualbox: Could not execute "VBoxControl guestproperty enumerate". Skipping data collection.')
|
156
|
+
end
|
157
|
+
when "host"
|
158
|
+
logger.trace("Plugin Virtualbox: Node detected as vbox host. Collecting host data.")
|
159
|
+
virtualbox Mash.new
|
160
|
+
begin
|
161
|
+
# get a list of virtualbox guest vms
|
162
|
+
virtualbox["guests"] = vboxmanage_list_vms
|
163
|
+
|
164
|
+
# get a list of virtualbox virtual hard disk drives
|
165
|
+
virtualbox["hdds"] = vboxmanage_list_blocks("hdds", "Location")
|
166
|
+
|
167
|
+
# get a list of virtualbox virtual dvd drives
|
168
|
+
virtualbox["dvds"] = vboxmanage_list_blocks("dvds", "Location")
|
169
|
+
|
170
|
+
# get a list of virtualbox host dvd drives
|
171
|
+
virtualbox["hostdvds"] = vboxmanage_list_blocks("hostdvds", "Name")
|
172
|
+
|
173
|
+
# get a list of virtualbox host floppy drives
|
174
|
+
virtualbox["hostfloppies"] = vboxmanage_list_blocks("hostfloppies", "Name")
|
175
|
+
|
176
|
+
# get a list of virtualbox hostonly network interfaces
|
177
|
+
virtualbox["hostonlyifs"] = vboxmanage_list_blocks("hostonlyifs", "Name")
|
178
|
+
|
179
|
+
# get a list of virtualbox bridged network interfaces
|
180
|
+
virtualbox["bridgedifs"] = vboxmanage_list_blocks("bridgedifs", "Name")
|
181
|
+
|
182
|
+
# get a list of virtualbox dhcp servers
|
183
|
+
virtualbox["dhcpservers"] = vboxmanage_list_blocks("dhcpservers", "NetworkName")
|
184
|
+
|
185
|
+
# get a list of virtualbox nat networks
|
186
|
+
virtualbox["natnets"] = vboxmanage_list_blocks("natnets", "NetworkName")
|
187
|
+
rescue Ohai::Exceptions::Exec
|
188
|
+
logger.trace("Plugin VboxHost: Could not collect data for VirtualBox host. Skipping data")
|
189
|
+
end
|
190
|
+
else
|
191
|
+
logger.trace("Plugin Virtualbox: Not on a Virtualbox host or guest. Skipping plugin.")
|
192
|
+
end
|
48
193
|
end
|
49
194
|
end
|