ohai 8.13.0 → 8.14.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -1
  3. data/lib/ohai/common/dmi.rb +1 -1
  4. data/lib/ohai/config.rb +2 -2
  5. data/lib/ohai/dsl/plugin.rb +1 -1
  6. data/lib/ohai/loader.rb +1 -1
  7. data/lib/ohai/mixin/command.rb +18 -5
  8. data/lib/ohai/mixin/ec2_metadata.rb +1 -1
  9. data/lib/ohai/plugins/aix/os.rb +1 -1
  10. data/lib/ohai/plugins/c.rb +49 -67
  11. data/lib/ohai/plugins/darwin/memory.rb +1 -1
  12. data/lib/ohai/plugins/darwin/network.rb +3 -3
  13. data/lib/ohai/plugins/darwin/platform.rb +1 -1
  14. data/lib/ohai/plugins/darwin/system_profiler.rb +1 -1
  15. data/lib/ohai/plugins/digital_ocean.rb +1 -1
  16. data/lib/ohai/plugins/ec2.rb +42 -41
  17. data/lib/ohai/plugins/erlang.rb +1 -1
  18. data/lib/ohai/plugins/ip_scopes.rb +1 -1
  19. data/lib/ohai/plugins/kernel.rb +1 -1
  20. data/lib/ohai/plugins/linux/network.rb +2 -2
  21. data/lib/ohai/plugins/linux/platform.rb +6 -1
  22. data/lib/ohai/plugins/mono.rb +1 -1
  23. data/lib/ohai/plugins/network.rb +2 -2
  24. data/lib/ohai/plugins/packages.rb +59 -46
  25. data/lib/ohai/plugins/python.rb +2 -2
  26. data/lib/ohai/plugins/rackspace.rb +4 -4
  27. data/lib/ohai/plugins/sigar/network.rb +1 -1
  28. data/lib/ohai/plugins/sigar/network_route.rb +1 -1
  29. data/lib/ohai/plugins/solaris2/dmi.rb +1 -1
  30. data/lib/ohai/plugins/solaris2/network.rb +25 -8
  31. data/lib/ohai/plugins/ssh_host_key.rb +1 -1
  32. data/lib/ohai/plugins/windows/network.rb +5 -5
  33. data/lib/ohai/provides_map.rb +2 -2
  34. data/lib/ohai/system.rb +1 -1
  35. data/lib/ohai/version.rb +1 -1
  36. data/spec/functional/loader_spec.rb +1 -1
  37. data/spec/unit/mixin/command_spec.rb +118 -0
  38. data/spec/unit/plugins/aix/os_spec.rb +6 -5
  39. data/spec/unit/plugins/c_spec.rb +169 -118
  40. data/spec/unit/plugins/digital_ocean_spec.rb +7 -7
  41. data/spec/unit/plugins/dmi_spec.rb +4 -4
  42. data/spec/unit/plugins/ec2_spec.rb +64 -69
  43. data/spec/unit/plugins/linode_spec.rb +6 -6
  44. data/spec/unit/plugins/linux/platform_spec.rb +7 -0
  45. data/spec/unit/plugins/linux/sessions_spec.rb +2 -2
  46. data/spec/unit/plugins/network_spec.rb +16 -16
  47. data/spec/unit/plugins/openstack_spec.rb +1 -1
  48. data/spec/unit/plugins/packages_spec.rb +165 -191
  49. data/spec/unit/plugins/rackspace_spec.rb +203 -130
  50. data/spec/unit/plugins/solaris2/filesystem.rb +2 -2
  51. data/spec/unit/plugins/solaris2/network_spec.rb +36 -5
  52. metadata +3 -3
@@ -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] and erlang[:options] and erlang[:emulator]
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.merge! "ip_scope" => address.to_ip.scope
33
+ attrs["ip_scope"] = address.to_ip.scope
34
34
 
35
35
  if private_addr?(address) && !tunnel_iface?(interface)
36
36
  privateaddress(address)
@@ -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+)/ or line =~ /vlan protocol ([\w\.]+) 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? or default_route.empty?
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
- platform "opensuse"
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
@@ -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].gsub!(/\)/, "")]
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
@@ -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? or not addr_v.has_key? "family" or addr_v["family"] != family
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? or r.empty?
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
- if configuration(:enabled)
27
- packages Mash.new
28
- if %w{debian}.include? platform_family
29
- so = shell_out("dpkg-query -W")
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
- pkgs.each do |pkg|
33
- name, version = pkg.split
34
- packages[name] = { "version" => version }
35
- end
37
+ pkgs.each do |pkg|
38
+ name, version = pkg.split
39
+ packages[name] = { "version" => version }
40
+ end
36
41
 
37
- elsif %w{rhel fedora suse}.include? platform_family
38
- require "shellwords"
39
- format = Shellwords.escape '%{NAME}\t%{VERSION}\t%{RELEASE}\n'
40
- so = shell_out("rpm -qa --queryformat #{format}")
41
- pkgs = so.stdout.lines
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
- pkgs.each do |pkg|
44
- name, version, release = pkg.split
45
- packages[name] = { "version" => version, "release" => release }
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
- collect_data(:windows) do
52
- if configuration(:enabled)
53
- packages Mash.new
54
- require "wmi-lite"
55
-
56
- wmi = WmiLite::Wmi.new
57
- w32_product = wmi.instances_of("Win32_Product")
58
-
59
- w32_product.find_all.each do |product|
60
- name = product["name"]
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
- %w{version vendor installdate}.each do |attr|
63
- package[attr] = product[attr]
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
- if configuration(:enabled)
71
- packages Mash.new
72
- so = shell_out("lslpp -L -q -c")
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
- # Output format is
76
- # Package Name:Fileset:Level
77
- # On aix, filesets are packages and levels are versions
78
- pkgs.each do |pkg|
79
- _, name, version = pkg.split(":")
80
- packages[name] = { "version" => version }
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
- if configuration(:enabled)
123
- packages Mash.new
124
- collect_ips_packages
125
- collect_sysv_packages
126
- end
137
+ packages Mash.new
138
+ collect_ips_packages
139
+ collect_sysv_packages
127
140
  end
128
141
  end
@@ -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].gsub!(/\)/, "")]
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] and python[:builddate]
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 Errno::ENOENT
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 Errno::ENOENT
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 Errno::ENOENT
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 Errno::ENOENT
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(m == :flags)
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(m == :flags)
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") and (dmi.keys.length > 1)
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 = Array.new
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: (\S+)/.match(line)
170
+ matches = /interface: (?<name>\S+)\s+index\s+(?<index>\d+)/.match(line)
162
171
  if matches
163
- Ohai::Log.debug("found gateway device: #{$1}")
164
- network[:default_interface] = matches[1]
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: #{$1}")
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.match(/^hostkey\s/i)
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] and iface_instance[i][:net_connection_id]
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 and iface[cint][:configuration][:default_ip_gateway].size > 0
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.gsub("-", ":").downcase
122
+ iface[cint][:arp][$1] = $2.tr("-", ":").downcase
123
123
  end
124
124
  end
125
125
  end
@@ -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.match(/\/\/+/)
118
- raise Ohai::Exceptions::AttributeSyntaxError, "Attribute contains a trailing '/': #{attribute}" if attribute.match(/\/$/)
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 and Array(attribute_filter).all? { |filter_item| have_v6_plugin?(filter_item) }
91
+ if attribute_filter && Array(attribute_filter).all? { |filter_item| have_v6_plugin?(filter_item) }
92
92
  return true
93
93
  end
94
94