ohai 8.13.0 → 8.14.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/Gemfile +1 -1
- data/lib/ohai/common/dmi.rb +1 -1
- data/lib/ohai/config.rb +2 -2
- data/lib/ohai/dsl/plugin.rb +1 -1
- data/lib/ohai/loader.rb +1 -1
- data/lib/ohai/mixin/command.rb +18 -5
- data/lib/ohai/mixin/ec2_metadata.rb +1 -1
- data/lib/ohai/plugins/aix/os.rb +1 -1
- data/lib/ohai/plugins/c.rb +49 -67
- data/lib/ohai/plugins/darwin/memory.rb +1 -1
- data/lib/ohai/plugins/darwin/network.rb +3 -3
- data/lib/ohai/plugins/darwin/platform.rb +1 -1
- data/lib/ohai/plugins/darwin/system_profiler.rb +1 -1
- data/lib/ohai/plugins/digital_ocean.rb +1 -1
- data/lib/ohai/plugins/ec2.rb +42 -41
- data/lib/ohai/plugins/erlang.rb +1 -1
- data/lib/ohai/plugins/ip_scopes.rb +1 -1
- data/lib/ohai/plugins/kernel.rb +1 -1
- data/lib/ohai/plugins/linux/network.rb +2 -2
- data/lib/ohai/plugins/linux/platform.rb +6 -1
- data/lib/ohai/plugins/mono.rb +1 -1
- data/lib/ohai/plugins/network.rb +2 -2
- data/lib/ohai/plugins/packages.rb +59 -46
- data/lib/ohai/plugins/python.rb +2 -2
- data/lib/ohai/plugins/rackspace.rb +4 -4
- data/lib/ohai/plugins/sigar/network.rb +1 -1
- data/lib/ohai/plugins/sigar/network_route.rb +1 -1
- data/lib/ohai/plugins/solaris2/dmi.rb +1 -1
- data/lib/ohai/plugins/solaris2/network.rb +25 -8
- data/lib/ohai/plugins/ssh_host_key.rb +1 -1
- data/lib/ohai/plugins/windows/network.rb +5 -5
- data/lib/ohai/provides_map.rb +2 -2
- data/lib/ohai/system.rb +1 -1
- data/lib/ohai/version.rb +1 -1
- data/spec/functional/loader_spec.rb +1 -1
- data/spec/unit/mixin/command_spec.rb +118 -0
- data/spec/unit/plugins/aix/os_spec.rb +6 -5
- data/spec/unit/plugins/c_spec.rb +169 -118
- data/spec/unit/plugins/digital_ocean_spec.rb +7 -7
- data/spec/unit/plugins/dmi_spec.rb +4 -4
- data/spec/unit/plugins/ec2_spec.rb +64 -69
- data/spec/unit/plugins/linode_spec.rb +6 -6
- data/spec/unit/plugins/linux/platform_spec.rb +7 -0
- data/spec/unit/plugins/linux/sessions_spec.rb +2 -2
- data/spec/unit/plugins/network_spec.rb +16 -16
- data/spec/unit/plugins/openstack_spec.rb +1 -1
- data/spec/unit/plugins/packages_spec.rb +165 -191
- data/spec/unit/plugins/rackspace_spec.rb +203 -130
- data/spec/unit/plugins/solaris2/filesystem.rb +2 -2
- data/spec/unit/plugins/solaris2/network_spec.rb +36 -5
- metadata +3 -3
data/lib/ohai/plugins/erlang.rb
CHANGED
@@ -34,7 +34,7 @@ Ohai.plugin(:Erlang) do
|
|
34
34
|
erlang[:version] = output[5]
|
35
35
|
erlang[:options] = options.split(",")
|
36
36
|
erlang[:emulator] = output[2].gsub!(/(\(|\))/, "")
|
37
|
-
if erlang[:version]
|
37
|
+
if erlang[:version] && erlang[:options] && erlang[:emulator]
|
38
38
|
languages[:erlang] = erlang
|
39
39
|
end
|
40
40
|
end
|
@@ -30,7 +30,7 @@ Ohai.plugin(:IpScopes) do
|
|
30
30
|
interface = network["interfaces"][ifName]
|
31
31
|
interface["addresses"].each do |address, attrs|
|
32
32
|
begin
|
33
|
-
attrs
|
33
|
+
attrs["ip_scope"] = address.to_ip.scope
|
34
34
|
|
35
35
|
if private_addr?(address) && !tunnel_iface?(interface)
|
36
36
|
privateaddress(address)
|
data/lib/ohai/plugins/kernel.rb
CHANGED
@@ -191,7 +191,7 @@ Ohai.plugin(:Kernel) do
|
|
191
191
|
host = wmi.first_of("Win32_ComputerSystem")
|
192
192
|
kernel[:cs_info] = Mash.new
|
193
193
|
cs_info_blacklist = [
|
194
|
-
"oem_logo_bitmap"
|
194
|
+
"oem_logo_bitmap",
|
195
195
|
]
|
196
196
|
host.wmi_ole_object.properties_.each do |p|
|
197
197
|
if !cs_info_blacklist.include?(p.name.wmi_underscore)
|
@@ -205,7 +205,7 @@ Ohai.plugin(:Network) do
|
|
205
205
|
net_counters[tmp_int][:tx][:queuelen] = $1
|
206
206
|
end
|
207
207
|
|
208
|
-
if line =~ /vlan id (\d+)/
|
208
|
+
if line =~ /vlan id (\d+)/ || line =~ /vlan protocol ([\w\.]+) id (\d+)/
|
209
209
|
if $2
|
210
210
|
tmp_prot = $1
|
211
211
|
tmp_id = $2
|
@@ -463,7 +463,7 @@ Ohai.plugin(:Network) do
|
|
463
463
|
|
464
464
|
default_route = choose_default_route(routes)
|
465
465
|
|
466
|
-
if default_route.nil?
|
466
|
+
if default_route.nil? || default_route.empty?
|
467
467
|
attribute_name = if family[:name] == "inet"
|
468
468
|
"default_interface"
|
469
469
|
else
|
@@ -125,7 +125,12 @@ Ohai.plugin(:Platform) do
|
|
125
125
|
suse_version = suse_release[/VERSION = ([\d\.]{2,})/, 1] if suse_version == ""
|
126
126
|
platform_version suse_version
|
127
127
|
if suse_release =~ /^openSUSE/
|
128
|
-
|
128
|
+
# opensuse releases >= 42 are openSUSE Leap
|
129
|
+
if platform_version.to_i < 42
|
130
|
+
platform "opensuse"
|
131
|
+
else
|
132
|
+
platform "opensuseleap"
|
133
|
+
end
|
129
134
|
else
|
130
135
|
platform "suse"
|
131
136
|
end
|
data/lib/ohai/plugins/mono.rb
CHANGED
@@ -33,7 +33,7 @@ Ohai.plugin(:Mono) do
|
|
33
33
|
mono[:version] = output[4]
|
34
34
|
end
|
35
35
|
if output.length >= 11
|
36
|
-
mono[:builddate] = "%s %s %s %s" % [output[6], output[7], output[8], output[11].
|
36
|
+
mono[:builddate] = "%s %s %s %s" % [output[6], output[7], output[8], output[11].delete!(")")]
|
37
37
|
end
|
38
38
|
languages[:mono] = mono if mono[:version]
|
39
39
|
end
|
data/lib/ohai/plugins/network.rb
CHANGED
@@ -39,7 +39,7 @@ Ohai.plugin(:NetworkAddresses) do
|
|
39
39
|
Mash[network["interfaces"]].each do |iface, iface_v|
|
40
40
|
next if iface_v.nil? || !iface_v.has_key?("addresses")
|
41
41
|
iface_v["addresses"].each do |addr, addr_v|
|
42
|
-
next if addr_v.nil?
|
42
|
+
next if addr_v.nil? || (not addr_v.has_key? "family") || addr_v["family"] != family
|
43
43
|
ipaddresses << {
|
44
44
|
:ipaddress => addr_v["prefixlen"] ? IPAddress("#{addr}/#{addr_v["prefixlen"]}") : IPAddress("#{addr}/#{addr_v["netmask"]}"),
|
45
45
|
:scope => addr_v["scope"].nil? ? nil : addr_v["scope"].downcase,
|
@@ -106,7 +106,7 @@ Ohai.plugin(:NetworkAddresses) do
|
|
106
106
|
Ohai::Log.debug("[#{family}] no default interface, picking the first ipaddress")
|
107
107
|
end
|
108
108
|
|
109
|
-
return [ nil, nil ] if r.nil?
|
109
|
+
return [ nil, nil ] if r.nil? || r.empty?
|
110
110
|
|
111
111
|
[ r[:ipaddress].to_s, r[:iface] ]
|
112
112
|
end
|
@@ -22,63 +22,78 @@ Ohai.plugin(:Packages) do
|
|
22
22
|
provides "packages"
|
23
23
|
depends "platform_family"
|
24
24
|
|
25
|
+
WINDOWS_ATTRIBUTE_ALIASES = {
|
26
|
+
"DisplayVersion" => "version",
|
27
|
+
"Publisher" => "publisher",
|
28
|
+
"InstallDate" => "installdate",
|
29
|
+
}
|
30
|
+
|
25
31
|
collect_data(:linux) do
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
pkgs = so.stdout.lines
|
32
|
+
packages Mash.new
|
33
|
+
if %w{debian}.include? platform_family
|
34
|
+
so = shell_out("dpkg-query -W")
|
35
|
+
pkgs = so.stdout.lines
|
31
36
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
37
|
+
pkgs.each do |pkg|
|
38
|
+
name, version = pkg.split
|
39
|
+
packages[name] = { "version" => version }
|
40
|
+
end
|
36
41
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
+
elsif %w{rhel fedora suse}.include? platform_family
|
43
|
+
require "shellwords"
|
44
|
+
format = Shellwords.escape '%{NAME}\t%{VERSION}\t%{RELEASE}\n'
|
45
|
+
so = shell_out("rpm -qa --queryformat #{format}")
|
46
|
+
pkgs = so.stdout.lines
|
42
47
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
end
|
48
|
+
pkgs.each do |pkg|
|
49
|
+
name, version, release = pkg.split
|
50
|
+
packages[name] = { "version" => version, "release" => release }
|
47
51
|
end
|
48
52
|
end
|
49
53
|
end
|
50
54
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
55
|
+
def collect_programs_from_registry_key(key_path)
|
56
|
+
# from http://msdn.microsoft.com/en-us/library/windows/desktop/aa384129(v=vs.85).aspx
|
57
|
+
if ::RbConfig::CONFIG["target_cpu"] == "i386"
|
58
|
+
reg_type = Win32::Registry::KEY_READ | 0x100
|
59
|
+
elsif ::RbConfig::CONFIG["target_cpu"] == "x86_64"
|
60
|
+
reg_type = Win32::Registry::KEY_READ | 0x200
|
61
|
+
else
|
62
|
+
reg_type = Win32::Registry::KEY_READ
|
63
|
+
end
|
64
|
+
Win32::Registry::HKEY_LOCAL_MACHINE.open(key_path, reg_type) do |reg|
|
65
|
+
reg.each_key do |key, _wtime|
|
66
|
+
pkg = reg.open(key)
|
67
|
+
name = pkg["DisplayName"] rescue nil
|
68
|
+
next if name.nil?
|
61
69
|
package = packages[name] = Mash.new
|
62
|
-
|
63
|
-
|
70
|
+
WINDOWS_ATTRIBUTE_ALIASES.each do |registry_attr, package_attr|
|
71
|
+
value = pkg[registry_attr] rescue nil
|
72
|
+
package[package_attr] = value unless value.nil?
|
64
73
|
end
|
65
74
|
end
|
66
75
|
end
|
67
76
|
end
|
68
77
|
|
78
|
+
collect_data(:windows) do
|
79
|
+
require "win32/registry"
|
80
|
+
packages Mash.new
|
81
|
+
collect_programs_from_registry_key('Software\Microsoft\Windows\CurrentVersion\Uninstall')
|
82
|
+
# on 64 bit systems, 32 bit programs are stored here
|
83
|
+
collect_programs_from_registry_key('Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall')
|
84
|
+
end
|
85
|
+
|
69
86
|
collect_data(:aix) do
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
pkgs = so.stdout.lines
|
87
|
+
packages Mash.new
|
88
|
+
so = shell_out("lslpp -L -q -c")
|
89
|
+
pkgs = so.stdout.lines
|
74
90
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
end
|
91
|
+
# Output format is
|
92
|
+
# Package Name:Fileset:Level
|
93
|
+
# On aix, filesets are packages and levels are versions
|
94
|
+
pkgs.each do |pkg|
|
95
|
+
_, name, version = pkg.split(":")
|
96
|
+
packages[name] = { "version" => version }
|
82
97
|
end
|
83
98
|
end
|
84
99
|
|
@@ -119,10 +134,8 @@ Ohai.plugin(:Packages) do
|
|
119
134
|
end
|
120
135
|
|
121
136
|
collect_data(:solaris2) do
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
collect_sysv_packages
|
126
|
-
end
|
137
|
+
packages Mash.new
|
138
|
+
collect_ips_packages
|
139
|
+
collect_sysv_packages
|
127
140
|
end
|
128
141
|
end
|
data/lib/ohai/plugins/python.rb
CHANGED
@@ -32,10 +32,10 @@ Ohai.plugin(:Python) do
|
|
32
32
|
output = so.stdout.split
|
33
33
|
python[:version] = output[0]
|
34
34
|
if output.length >= 6
|
35
|
-
python[:builddate] = "%s %s %s %s" % [output[2], output[3], output[4], output[5].
|
35
|
+
python[:builddate] = "%s %s %s %s" % [output[2], output[3], output[4], output[5].delete!(")")]
|
36
36
|
end
|
37
37
|
|
38
|
-
languages[:python] = python if python[:version]
|
38
|
+
languages[:python] = python if python[:version] && python[:builddate]
|
39
39
|
end
|
40
40
|
end
|
41
41
|
end
|
@@ -40,7 +40,7 @@ Ohai.plugin(:Rackspace) do
|
|
40
40
|
if so.exitstatus == 0
|
41
41
|
so.stdout.strip.downcase == "rackspace"
|
42
42
|
end
|
43
|
-
rescue
|
43
|
+
rescue Ohai::Exceptions::Exec
|
44
44
|
false
|
45
45
|
end
|
46
46
|
|
@@ -91,7 +91,7 @@ Ohai.plugin(:Rackspace) do
|
|
91
91
|
rackspace[:region] = line.split[2].delete('\"') if line =~ /^region/
|
92
92
|
end
|
93
93
|
end
|
94
|
-
rescue
|
94
|
+
rescue Ohai::Exceptions::Exec
|
95
95
|
Ohai::Log.debug("rackspace plugin: Unable to find xenstore-ls, cannot capture region information for Rackspace cloud")
|
96
96
|
nil
|
97
97
|
end
|
@@ -103,7 +103,7 @@ Ohai.plugin(:Rackspace) do
|
|
103
103
|
if so.exitstatus == 0
|
104
104
|
rackspace[:instance_id] = so.stdout.gsub(/instance-/, "")
|
105
105
|
end
|
106
|
-
rescue
|
106
|
+
rescue Ohai::Exceptions::Exec
|
107
107
|
Ohai::Log.debug("rackspace plugin: Unable to find xenstore-read, cannot capture instance ID information for Rackspace cloud")
|
108
108
|
nil
|
109
109
|
end
|
@@ -127,7 +127,7 @@ Ohai.plugin(:Rackspace) do
|
|
127
127
|
networks.delete_if { |hash| hash["label"] == "private" }
|
128
128
|
networks.delete_if { |hash| hash["label"] == "public" }
|
129
129
|
end
|
130
|
-
rescue
|
130
|
+
rescue Ohai::Exceptions::Exec
|
131
131
|
Ohai::Log.debug("rackspace plugin: Unable to capture custom private networking information for Rackspace cloud")
|
132
132
|
nil
|
133
133
|
end
|
@@ -156,7 +156,7 @@ Ohai.plugin(:Network) do
|
|
156
156
|
network[:interfaces][route.ifname][:route] = Mash.new unless network[:interfaces][route.ifname][:route]
|
157
157
|
route_data = {}
|
158
158
|
Ohai::Mixin::NetworkConstants::SIGAR_ROUTE_METHODS.each do |m|
|
159
|
-
if
|
159
|
+
if m == :flags
|
160
160
|
route_data[m] = flags(route.send(m))
|
161
161
|
else
|
162
162
|
route_data[m] = route.send(m)
|
@@ -49,7 +49,7 @@ Ohai.plugin(:NetworkRoutes) do
|
|
49
49
|
network[:interfaces][route.ifname][:route] = Mash.new unless network[:interfaces][route.ifname][:route]
|
50
50
|
route_data = {}
|
51
51
|
Ohai::Mixin::NetworkConstants::SIGAR_ROUTE_METHODS.each do |m|
|
52
|
-
if
|
52
|
+
if m == :flags
|
53
53
|
route_data[m] = flags(route.send(m))
|
54
54
|
else
|
55
55
|
route_data[m] = route.send(m)
|
@@ -24,7 +24,7 @@ Ohai.plugin(:DMI) do
|
|
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
|
27
|
-
if (dmi.class.to_s == "Mash")
|
27
|
+
if (dmi.class.to_s == "Mash") && (dmi.keys.length > 1)
|
28
28
|
Ohai::Log.debug("skipping smbios output, since DMI information has already been provided")
|
29
29
|
return
|
30
30
|
end
|
@@ -58,7 +58,7 @@ ETHERNET_ENCAPS = %w{ afe amd8111s arn atge ath bfe bge bnx bnxe ce cxgbe
|
|
58
58
|
dmfe e1000g efe elxl emlxs eri hermon hme hxge igb
|
59
59
|
iprb ipw iwh iwi iwk iwp ixgb ixgbe mwl mxfe myri10ge
|
60
60
|
nge ntxn nxge pcn platform qfe qlc ral rge rtls rtw rwd
|
61
|
-
rwn sfe tavor vr wpi xge yge} unless defined?(ETHERNET_ENCAPS)
|
61
|
+
rwn sfe tavor vr wpi xge yge } unless defined?(ETHERNET_ENCAPS)
|
62
62
|
|
63
63
|
Ohai.plugin(:Network) do
|
64
64
|
provides "network", "network/interfaces"
|
@@ -79,6 +79,15 @@ Ohai.plugin(:Network) do
|
|
79
79
|
nil
|
80
80
|
end
|
81
81
|
|
82
|
+
def full_interface_name(iface, part_name, index)
|
83
|
+
iface.each do |name, attrs|
|
84
|
+
next unless attrs && attrs.respond_to?(:[])
|
85
|
+
return name if /^#{part_name}($|:)/.match(name) && attrs[:index] == index
|
86
|
+
end
|
87
|
+
|
88
|
+
nil
|
89
|
+
end
|
90
|
+
|
82
91
|
collect_data(:solaris2) do
|
83
92
|
require "scanf"
|
84
93
|
|
@@ -97,10 +106,10 @@ Ohai.plugin(:Network) do
|
|
97
106
|
iface[cint] = Mash.new unless iface[cint]
|
98
107
|
iface[cint][:mtu] = $2
|
99
108
|
iface[cint][:index] = $3
|
100
|
-
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|POINTOPOINT|PREFERRED|PRIVATE|ROUTER|RUNNING|STANDBY|TEMPORARY|UNNUMBERED|UP|VIRTUAL|XRESOLV|IPv4|IPv6|,)+)\>\s/
|
109
|
+
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/
|
101
110
|
flags = $1.split(",")
|
102
111
|
else
|
103
|
-
flags =
|
112
|
+
flags = []
|
104
113
|
end
|
105
114
|
iface[cint][:flags] = flags.flatten
|
106
115
|
if cint =~ /^(\w+)(\d+.*)/
|
@@ -156,16 +165,24 @@ Ohai.plugin(:Network) do
|
|
156
165
|
|
157
166
|
network[:interfaces] = iface
|
158
167
|
|
159
|
-
so = shell_out("route -n get default")
|
168
|
+
so = shell_out("route -v -n get default")
|
160
169
|
so.stdout.lines do |line|
|
161
|
-
matches = /interface: (
|
170
|
+
matches = /interface: (?<name>\S+)\s+index\s+(?<index>\d+)/.match(line)
|
162
171
|
if matches
|
163
|
-
|
164
|
-
|
172
|
+
network[:default_interface] =
|
173
|
+
case
|
174
|
+
when iface[matches[:name]]
|
175
|
+
matches[:name]
|
176
|
+
when int_name = full_interface_name(iface, matches[:name], matches[:index])
|
177
|
+
int_name
|
178
|
+
else
|
179
|
+
matches[:name]
|
180
|
+
end
|
181
|
+
Ohai::Log.debug("found interface device: #{network[:default_interface]} #{matches[:name]}")
|
165
182
|
end
|
166
183
|
matches = /gateway: (\S+)/.match(line)
|
167
184
|
if matches
|
168
|
-
Ohai::Log.debug("found gateway: #{
|
185
|
+
Ohai::Log.debug("found gateway: #{matches[1]}")
|
169
186
|
network[:default_gateway] = matches[1]
|
170
187
|
end
|
171
188
|
end
|
@@ -51,7 +51,7 @@ Ohai.plugin(:SSHHostKey) do
|
|
51
51
|
if sshd_config
|
52
52
|
File.open(sshd_config) do |conf|
|
53
53
|
conf.each_line do |line|
|
54
|
-
if line
|
54
|
+
if line =~ /^hostkey\s/i
|
55
55
|
pub_file = "#{line.split[1]}.pub"
|
56
56
|
content = IO.read(pub_file).split
|
57
57
|
key_type, key_subtype = extract_keytype?(content)
|
@@ -64,7 +64,7 @@ Ohai.plugin(:Network) do
|
|
64
64
|
end
|
65
65
|
|
66
66
|
iface_instance.keys.each do |i|
|
67
|
-
if iface_config[i][:ip_enabled]
|
67
|
+
if iface_config[i][:ip_enabled] && iface_instance[i][:net_connection_id]
|
68
68
|
cint = sprintf("0x%x", iface_instance[i][:interface_index] ? iface_instance[i][:interface_index] : iface_instance[i][:index] ).downcase
|
69
69
|
iface[cint] = Mash.new
|
70
70
|
iface[cint][:configuration] = iface_config[i]
|
@@ -76,7 +76,7 @@ Ohai.plugin(:Network) do
|
|
76
76
|
ip = iface[cint][:configuration][:ip_address][i]
|
77
77
|
_ip = IPAddress("#{ip}/#{iface[cint][:configuration][:ip_subnet][i]}")
|
78
78
|
iface[cint][:addresses][ip] = Mash.new(
|
79
|
-
:prefixlen => _ip.prefix
|
79
|
+
:prefixlen => _ip.prefix
|
80
80
|
)
|
81
81
|
if _ip.ipv6?
|
82
82
|
# inet6 address
|
@@ -96,14 +96,14 @@ Ohai.plugin(:Network) do
|
|
96
96
|
# Apparently you can have more than one mac_address? Odd.
|
97
97
|
[iface[cint][:configuration][:mac_address]].flatten.each do |mac_addr|
|
98
98
|
iface[cint][:addresses][mac_addr] = {
|
99
|
-
"family" => "lladdr"
|
99
|
+
"family" => "lladdr",
|
100
100
|
}
|
101
101
|
end
|
102
102
|
iface[cint][:mtu] = iface[cint][:configuration][:mtu]
|
103
103
|
iface[cint][:type] = iface[cint][:instance][:adapter_type]
|
104
104
|
iface[cint][:arp] = {}
|
105
105
|
iface[cint][:encapsulation] = windows_encaps_lookup(iface[cint][:instance][:adapter_type])
|
106
|
-
if iface[cint][:configuration][:default_ip_gateway] != nil
|
106
|
+
if iface[cint][:configuration][:default_ip_gateway] != nil && iface[cint][:configuration][:default_ip_gateway].size > 0
|
107
107
|
network[:default_gateway] = iface[cint][:configuration][:default_ip_gateway].first
|
108
108
|
network[:default_interface] = cint
|
109
109
|
end
|
@@ -119,7 +119,7 @@ Ohai.plugin(:Network) do
|
|
119
119
|
end
|
120
120
|
next unless iface[cint]
|
121
121
|
if line =~ /^\s+(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\s+([a-fA-F0-9\:-]+)/
|
122
|
-
iface[cint][:arp][$1] = $2.
|
122
|
+
iface[cint][:arp][$1] = $2.tr("-", ":").downcase
|
123
123
|
end
|
124
124
|
end
|
125
125
|
end
|
data/lib/ohai/provides_map.rb
CHANGED
@@ -114,8 +114,8 @@ module Ohai
|
|
114
114
|
private
|
115
115
|
|
116
116
|
def normalize_and_validate(attribute)
|
117
|
-
raise Ohai::Exceptions::AttributeSyntaxError, "Attribute contains duplicate '/' characters: #{attribute}" if attribute
|
118
|
-
raise Ohai::Exceptions::AttributeSyntaxError, "Attribute contains a trailing '/': #{attribute}" if attribute
|
117
|
+
raise Ohai::Exceptions::AttributeSyntaxError, "Attribute contains duplicate '/' characters: #{attribute}" if attribute =~ /\/\/+/
|
118
|
+
raise Ohai::Exceptions::AttributeSyntaxError, "Attribute contains a trailing '/': #{attribute}" if attribute =~ /\/$/
|
119
119
|
|
120
120
|
parts = attribute.split("/")
|
121
121
|
parts.shift if parts.length != 0 && parts[0].length == 0 # attribute begins with a '/'
|
data/lib/ohai/system.rb
CHANGED
@@ -88,7 +88,7 @@ module Ohai
|
|
88
88
|
# Users who are migrating from ohai 6 may give one or more Ohai 6 plugin
|
89
89
|
# names as the +attribute_filter+. In this case we return early because
|
90
90
|
# the v7 plugin provides map will not have an entry for this plugin.
|
91
|
-
if attribute_filter
|
91
|
+
if attribute_filter && Array(attribute_filter).all? { |filter_item| have_v6_plugin?(filter_item) }
|
92
92
|
return true
|
93
93
|
end
|
94
94
|
|