ohai 15.1.5 → 15.2.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +1 -1
  3. data/lib/ohai/common/dmi.rb +3 -0
  4. data/lib/ohai/dsl/plugin.rb +3 -0
  5. data/lib/ohai/dsl/plugin/versionvii.rb +4 -2
  6. data/lib/ohai/hints.rb +3 -1
  7. data/lib/ohai/loader.rb +7 -4
  8. data/lib/ohai/mash.rb +1 -1
  9. data/lib/ohai/mixin/constant_helper.rb +1 -0
  10. data/lib/ohai/mixin/ec2_metadata.rb +4 -3
  11. data/lib/ohai/mixin/gce_metadata.rb +2 -3
  12. data/lib/ohai/plugins/aix/kernel.rb +1 -1
  13. data/lib/ohai/plugins/aix/network.rb +3 -3
  14. data/lib/ohai/plugins/aix/virtualization.rb +4 -0
  15. data/lib/ohai/plugins/azure.rb +1 -0
  16. data/lib/ohai/plugins/cloud.rb +7 -4
  17. data/lib/ohai/plugins/cpu.rb +6 -6
  18. data/lib/ohai/plugins/darwin/network.rb +9 -4
  19. data/lib/ohai/plugins/digital_ocean.rb +2 -0
  20. data/lib/ohai/plugins/dmi.rb +1 -0
  21. data/lib/ohai/plugins/dragonflybsd/memory.rb +1 -1
  22. data/lib/ohai/plugins/dragonflybsd/network.rb +1 -0
  23. data/lib/ohai/plugins/ec2.rb +1 -0
  24. data/lib/ohai/plugins/eucalyptus.rb +1 -0
  25. data/lib/ohai/plugins/filesystem.rb +12 -2
  26. data/lib/ohai/plugins/freebsd/memory.rb +1 -1
  27. data/lib/ohai/plugins/freebsd/network.rb +1 -0
  28. data/lib/ohai/plugins/haskell.rb +4 -4
  29. data/lib/ohai/plugins/hostname.rb +2 -1
  30. data/lib/ohai/plugins/java.rb +1 -0
  31. data/lib/ohai/plugins/kernel.rb +10 -5
  32. data/lib/ohai/plugins/linode.rb +1 -1
  33. data/lib/ohai/plugins/linux/lspci.rb +3 -2
  34. data/lib/ohai/plugins/linux/network.rb +18 -7
  35. data/lib/ohai/plugins/linux/platform.rb +4 -8
  36. data/lib/ohai/plugins/netbsd/memory.rb +1 -1
  37. data/lib/ohai/plugins/netbsd/network.rb +1 -0
  38. data/lib/ohai/plugins/network.rb +2 -0
  39. data/lib/ohai/plugins/openbsd/memory.rb +1 -1
  40. data/lib/ohai/plugins/openbsd/network.rb +1 -0
  41. data/lib/ohai/plugins/openstack.rb +8 -14
  42. data/lib/ohai/plugins/packages.rb +29 -1
  43. data/lib/ohai/plugins/rackspace.rb +1 -0
  44. data/lib/ohai/plugins/scaleway.rb +1 -0
  45. data/lib/ohai/plugins/shard.rb +1 -1
  46. data/lib/ohai/plugins/solaris2/network.rb +3 -1
  47. data/lib/ohai/plugins/virtualbox.rb +5 -3
  48. data/lib/ohai/plugins/windows/network.rb +6 -0
  49. data/lib/ohai/provides_map.rb +26 -3
  50. data/lib/ohai/runner.rb +18 -5
  51. data/lib/ohai/system.rb +8 -0
  52. data/lib/ohai/util/win32.rb +4 -4
  53. data/lib/ohai/version.rb +1 -1
  54. data/spec/data/plugins/rpmquery.output +2 -0
  55. data/spec/functional/application_spec.rb +1 -1
  56. data/spec/functional/loader_spec.rb +1 -1
  57. data/spec/unit/dsl/plugin_spec.rb +15 -15
  58. data/spec/unit/plugin_config_spec.rb +3 -3
  59. data/spec/unit/plugins/docker_spec.rb +11 -11
  60. data/spec/unit/plugins/ec2_spec.rb +4 -2
  61. data/spec/unit/plugins/erlang_spec.rb +2 -2
  62. data/spec/unit/plugins/hostname_spec.rb +14 -10
  63. data/spec/unit/plugins/linux/filesystem_spec.rb +1 -0
  64. data/spec/unit/plugins/linux/lspci_spec.rb +2 -1
  65. data/spec/unit/plugins/linux/platform_spec.rb +5 -0
  66. data/spec/unit/plugins/network_spec.rb +3 -2
  67. data/spec/unit/plugins/openstack_spec.rb +31 -30
  68. data/spec/unit/plugins/packages_spec.rb +20 -0
  69. data/spec/unit/plugins/ruby_spec.rb +1 -1
  70. data/spec/unit/plugins/scsi_spec.rb +2 -1
  71. data/spec/unit/plugins/shard_spec.rb +1 -1
  72. data/spec/unit/plugins/windows/filesystem_spec.rb +2 -2
  73. data/spec/unit/plugins/windows/kernel_spec.rb +2 -2
  74. data/spec/unit/runner_spec.rb +2 -2
  75. data/spec/unit/system_spec.rb +3 -3
  76. metadata +2 -2
@@ -44,6 +44,7 @@ Ohai.plugin(:DigitalOcean) do
44
44
  def looks_like_digital_ocean?
45
45
  return true if hint?("digital_ocean")
46
46
  return true if has_do_dmi? && can_socket_connect?(Ohai::Mixin::DOMetadata::DO_METADATA_ADDR, 80)
47
+
47
48
  false
48
49
  end
49
50
 
@@ -53,6 +54,7 @@ Ohai.plugin(:DigitalOcean) do
53
54
  digital_ocean Mash.new
54
55
  fetch_metadata.each do |k, v|
55
56
  next if k == "vendor_data" # this may have sensitive data we shouldn't store
57
+
56
58
  digital_ocean[k] = v
57
59
  end
58
60
  else
@@ -58,6 +58,7 @@ Ohai.plugin(:DMI) do
58
58
  # ... similar lines trimmed
59
59
  so.stdout.lines do |line|
60
60
  next if blank_line.match(line)
61
+
61
62
  line = line.encode(line.encoding, universal_newline: true)
62
63
 
63
64
  if ( dmidecode_version = dmidecode_version_line.match(line) )
@@ -46,7 +46,7 @@ Ohai.plugin(:Memory) do
46
46
  so.stdout.lines do |line|
47
47
  # Device 1K-blocks Used Avail Capacity
48
48
  # /dev/ad0s1b 253648 0 253648 0%
49
- if line =~ /^([\d\w\/]+)\s+(\d+)\s+(\d+)\s+(\d+)\s+([\d\%]+)/
49
+ if line =~ %r{^([\d\w/]+)\s+(\d+)\s+(\d+)\s+(\d+)\s+([\d\%]+)}
50
50
  mdev = $1
51
51
  memory[:swap][mdev] = Mash.new
52
52
  memory[:swap][mdev][:total] = $2
@@ -89,6 +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
+
92
93
  iface[$3][:arp] ||= Mash.new
93
94
  iface[$3][:arp][$1] = $2.downcase
94
95
  end
@@ -124,6 +124,7 @@ Ohai.plugin(:EC2) do
124
124
  # to the server.
125
125
  # http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AESDG-chapter-instancedata.html#instancedata-data-categories
126
126
  next if k == "iam" && !hint?("iam")
127
+
127
128
  ec2[k] = v
128
129
  end
129
130
  ec2[:userdata] = fetch_userdata
@@ -71,6 +71,7 @@ Ohai.plugin(:Eucalyptus) do
71
71
  # to the server.
72
72
  # http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AESDG-chapter-instancedata.html#instancedata-data-categories
73
73
  next if k == "iam" && !hint?("iam")
74
+
74
75
  eucalyptus[k] = v
75
76
  end
76
77
  eucalyptus[:userdata] = fetch_userdata
@@ -68,6 +68,7 @@ Ohai.plugin(:Filesystem) do
68
68
  view[entry[:device]] ||= Mash.new
69
69
  entry.each do |key, val|
70
70
  next if %w{device mount}.include?(key)
71
+
71
72
  view[entry[:device]][key] = val
72
73
  end
73
74
  view[entry[:device]][:mounts] ||= []
@@ -82,9 +83,11 @@ Ohai.plugin(:Filesystem) do
82
83
  view = {}
83
84
  fs.each_value do |entry|
84
85
  next unless entry[:mount]
86
+
85
87
  view[entry[:mount]] ||= Mash.new
86
88
  entry.each do |key, val|
87
89
  next if %w{mount device}.include?(key)
90
+
88
91
  view[entry[:mount]][key] = val
89
92
  end
90
93
  view[entry[:mount]][:devices] ||= []
@@ -146,6 +149,7 @@ Ohai.plugin(:Filesystem) do
146
149
  unless Ohai.config[:plugin][:filesystem][:allow_partial_data]
147
150
  raise e
148
151
  end
152
+
149
153
  logger.warn("Plugin Filesystem: #{bin} binary is not available. Some data will not be available.")
150
154
  end
151
155
 
@@ -218,6 +222,7 @@ Ohai.plugin(:Filesystem) do
218
222
  so.stdout.each_line do |line|
219
223
  parsed = parse_line(line, cmdtype)
220
224
  next if parsed.nil?
225
+
221
226
  # lsblk lists each device once, so we need to update all entries
222
227
  # in the hash that are related to this device
223
228
  keys_to_update = []
@@ -233,7 +238,7 @@ Ohai.plugin(:Filesystem) do
233
238
  end
234
239
 
235
240
  keys_to_update.each do |k|
236
- [:fs_type, :uuid, :label].each do |subkey|
241
+ %i{fs_type uuid label}.each do |subkey|
237
242
  if parsed[subkey] && !parsed[subkey].empty?
238
243
  fs[k][subkey] = parsed[subkey]
239
244
  end
@@ -266,6 +271,7 @@ Ohai.plugin(:Filesystem) do
266
271
  if line =~ /^(\S+) (\S+) (\S+) (\S+) \S+ \S+$/
267
272
  key = "#{$1},#{$2}"
268
273
  next if fs.key?(key)
274
+
269
275
  fs[key] = Mash.new
270
276
  fs[key][:device] = $1
271
277
  fs[key][:mount] = $2
@@ -412,9 +418,11 @@ Ohai.plugin(:Filesystem) do
412
418
  so = shell_out("df -na")
413
419
  so.stdout.lines do |line|
414
420
  next unless line =~ /^(.+?)\s*: (\S+)\s*$/
421
+
415
422
  mount = $1
416
423
  fs.each do |key, fs_attributes|
417
424
  next unless fs_attributes[:mount] == mount
425
+
418
426
  fs[key][:fs_type] = $2
419
427
  end
420
428
  end
@@ -425,6 +433,7 @@ Ohai.plugin(:Filesystem) do
425
433
  so = shell_out("mount")
426
434
  so.stdout.lines do |line|
427
435
  next unless line =~ /^(.+?) on (.+?) (.+?) on (.+?)$/
436
+
428
437
  key = "#{$2},#{$1}"
429
438
  fs[key] ||= Mash.new
430
439
  fs[key][:mount] = $1
@@ -441,6 +450,7 @@ Ohai.plugin(:Filesystem) do
441
450
  so = shell_out(zfs_get)
442
451
  so.stdout.lines do |line|
443
452
  next unless line =~ /^([^\s]+)\s+([^\s]+)\s+([^\s]+)\s+([^\s]+)$/
453
+
444
454
  filesystem = $1
445
455
  property = $2
446
456
  value = $3
@@ -524,7 +534,7 @@ Ohai.plugin(:Filesystem) do
524
534
  oldie[key][:mount] = mountpoint
525
535
  oldie[key][:device] = dev
526
536
  # an entry starting with 'G' or / (E.G. /tmp or /var)
527
- when /^\s*(G.*?|\/\w)/
537
+ when %r{^\s*(G.*?|/\w)}
528
538
  if fields[0] == "Global"
529
539
  dev = fields[0] + ":" + fields[1]
530
540
  else
@@ -46,7 +46,7 @@ Ohai.plugin(:Memory) do
46
46
  so.stdout.lines do |line|
47
47
  # Device 1K-blocks Used Avail Capacity
48
48
  # /dev/ad0s1b 253648 0 253648 0%
49
- if line =~ /^([\d\w\/]+)\s+(\d+)\s+(\d+)\s+(\d+)\s+([\d\%]+)/
49
+ if line =~ %r{^([\d\w/]+)\s+(\d+)\s+(\d+)\s+(\d+)\s+([\d\%]+)}
50
50
  mdev = $1
51
51
  memory[:swap][mdev] = Mash.new
52
52
  memory[:swap][mdev][:total] = $2
@@ -89,6 +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
+
92
93
  iface[$3][:arp] ||= Mash.new
93
94
  iface[$3][:arp][$1] = $2.downcase
94
95
  end
@@ -17,10 +17,10 @@
17
17
  Ohai.plugin(:Haskell) do
18
18
 
19
19
  provides "languages/haskell",
20
- "languages/haskell/ghc",
21
- "languages/haskell/ghci",
22
- "languages/haskell/cabal",
23
- "languages/haskell/stack"
20
+ "languages/haskell/ghc",
21
+ "languages/haskell/ghci",
22
+ "languages/haskell/cabal",
23
+ "languages/haskell/stack"
24
24
 
25
25
  depends "languages"
26
26
 
@@ -115,7 +115,8 @@ Ohai.plugin(:Hostname) do
115
115
  end
116
116
  rescue
117
117
  logger.trace(
118
- "Plugin Hostname: hostname returned an error, probably no domain set")
118
+ "Plugin Hostname: hostname returned an error, probably no domain set"
119
+ )
119
120
  end
120
121
  domain collect_domain
121
122
  end
@@ -63,6 +63,7 @@ Ohai.plugin(:Java) do
63
63
  # workaround for this particular annoyance.
64
64
  def has_real_java?
65
65
  return true unless on_darwin?
66
+
66
67
  shell_out("/usr/libexec/java_home").status.success?
67
68
  end
68
69
 
@@ -32,9 +32,9 @@ Ohai.plugin(:Kernel) do
32
32
  [["uname -s", :name], ["uname -r", :release],
33
33
  ["uname -v", :version], ["uname -m", :machine],
34
34
  ["uname -p", :processor]].each do |cmd, property|
35
- so = shell_out(cmd)
36
- kernel[property] = so.stdout.split($/)[0]
37
- end
35
+ so = shell_out(cmd)
36
+ kernel[property] = so.stdout.split($/)[0]
37
+ end
38
38
  kernel
39
39
  end
40
40
 
@@ -71,8 +71,9 @@ Ohai.plugin(:Kernel) do
71
71
  43, # Storage Server Express Core
72
72
  44, # Storage Server Standard Core
73
73
  45, # Storage Server Workgroup Core
74
- 29 # Web Server Core
74
+ 29, # Web Server Core
75
75
  ].include?(sku)
76
+
76
77
  false
77
78
  end
78
79
 
@@ -84,6 +85,7 @@ Ohai.plugin(:Kernel) do
84
85
  def arch_lookup(sys_type)
85
86
  return "x86_64" if sys_type == "x64-based PC"
86
87
  return "i386" if sys_type == "X86-based PC"
88
+
87
89
  sys_type
88
90
  end
89
91
 
@@ -94,6 +96,7 @@ Ohai.plugin(:Kernel) do
94
96
  # @return [String] Workstation or Server
95
97
  def product_type_decode(type)
96
98
  return "Workstation" if type == 1
99
+
97
100
  "Server"
98
101
  end
99
102
 
@@ -226,7 +229,7 @@ Ohai.plugin(:Kernel) do
226
229
  so = shell_out("uname -s")
227
230
  kernel[:os] = so.stdout.split($/)[0]
228
231
 
229
- so = File.open("/etc/release") { |file| file.gets }
232
+ so = File.open("/etc/release", &:gets)
230
233
  md = /(?<update>\d.*\d)/.match(so)
231
234
  kernel[:update] = md[:update] if md
232
235
 
@@ -260,6 +263,7 @@ Ohai.plugin(:Kernel) do
260
263
  kernel[:os_info] = Mash.new
261
264
  host.wmi_ole_object.properties_.each do |p|
262
265
  next if blacklisted_wmi_name?(p.name.wmi_underscore)
266
+
263
267
  kernel[:os_info][p.name.wmi_underscore.to_sym] = host[p.name.downcase]
264
268
  end
265
269
 
@@ -274,6 +278,7 @@ Ohai.plugin(:Kernel) do
274
278
  host = wmi.first_of("Win32_ComputerSystem")
275
279
  host.wmi_ole_object.properties_.each do |p|
276
280
  next if blacklisted_wmi_name?(p.name.wmi_underscore)
281
+
277
282
  kernel[:cs_info][p.name.wmi_underscore.to_sym] = host[p.name.downcase]
278
283
  end
279
284
 
@@ -57,7 +57,7 @@ Ohai.plugin(:Linode) do
57
57
  linode Mash.new
58
58
  get_ip_address(:public_ip, :eth0)
59
59
  get_ip_address(:private_ip, "eth0:1")
60
- hint?("linode").each { |k, v| linode[k] = v } if hint?("linode").kind_of?(Hash)
60
+ hint?("linode").each { |k, v| linode[k] = v } if hint?("linode").is_a?(Hash)
61
61
  else
62
62
  logger.trace("Plugin Linode: looks_like_linode? == false")
63
63
  end
@@ -30,7 +30,7 @@ Ohai.plugin(:Lspci) do
30
30
  hh = /#{h}#{h}/ # any 2 hex digits
31
31
  hhhh = /#{h}#{h}#{h}#{h}/ # any 4 hex digits
32
32
 
33
- d_id = String.new # This identifies our pci devices
33
+ d_id = "" # This identifies our pci devices
34
34
 
35
35
  def standard_form(devices, d_id, hhhh, tag, line)
36
36
  tmp = line.scan(/(.*)\s\[(#{hhhh})\]/)[0]
@@ -39,7 +39,7 @@ Ohai.plugin(:Lspci) do
39
39
  end
40
40
 
41
41
  def standard_array(devices, d_id, tag, line)
42
- if !devices[d_id][tag].kind_of?(Array)
42
+ if !devices[d_id][tag].is_a?(Array)
43
43
  devices[d_id][tag] = [line]
44
44
  else
45
45
  devices[d_id][tag].push(line)
@@ -49,6 +49,7 @@ Ohai.plugin(:Lspci) do
49
49
  lspci.stdout.split("\n").each do |line|
50
50
  dev = line.scan(/^(.*):\s(.*)$/)[0]
51
51
  next if dev.nil?
52
+
52
53
  case dev[0]
53
54
  when "Device" # There are two different Device tags
54
55
  if ( tmp = dev[1].match(/(#{hh}:#{hh}.#{h})/) )
@@ -30,6 +30,7 @@ Ohai.plugin(:Network) do
30
30
  return "IPIP" if encap.eql?("IPIP Tunnel")
31
31
  return "6to4" if encap.eql?("IPv6-in-IPv4")
32
32
  return "Ethernet" if encap.eql?("ether")
33
+
33
34
  encap
34
35
  end
35
36
 
@@ -120,7 +121,7 @@ Ohai.plugin(:Network) do
120
121
  end
121
122
  end
122
123
 
123
- iface[route_int][:routes] = Array.new unless iface[route_int][:routes]
124
+ iface[route_int][:routes] = [] unless iface[route_int][:routes]
124
125
  iface[route_int][:routes] << route_entry
125
126
  end
126
127
  end
@@ -149,9 +150,11 @@ Ohai.plugin(:Network) do
149
150
  # determine layer 1 details for the interface using ethtool
150
151
  def ethernet_layer_one(iface)
151
152
  return iface unless ethtool_binary_path
153
+
152
154
  keys = %w{ Speed Duplex Port Transceiver Auto-negotiation MDI-X }
153
155
  iface.each_key do |tmp_int|
154
156
  next unless iface[tmp_int][:encapsulation] == "Ethernet"
157
+
155
158
  so = shell_out("#{ethtool_binary_path} #{tmp_int}")
156
159
  so.stdout.lines do |line|
157
160
  line.chomp!
@@ -159,6 +162,7 @@ Ohai.plugin(:Network) do
159
162
  line.lstrip!
160
163
  k, v = line.split(": ")
161
164
  next unless keys.include? k
165
+
162
166
  k.downcase!.tr!("-", "_")
163
167
  if k == "speed"
164
168
  k = "link_speed" # This is not necessarily the maximum speed the NIC supports
@@ -173,8 +177,10 @@ Ohai.plugin(:Network) do
173
177
  # determine ring parameters for the interface using ethtool
174
178
  def ethernet_ring_parameters(iface)
175
179
  return iface unless ethtool_binary_path
180
+
176
181
  iface.each_key do |tmp_int|
177
182
  next unless iface[tmp_int][:encapsulation] == "Ethernet"
183
+
178
184
  so = shell_out("#{ethtool_binary_path} -g #{tmp_int}")
179
185
  logger.trace("Plugin Network: Parsing ethtool output: #{so.stdout}")
180
186
  type = nil
@@ -182,6 +188,7 @@ Ohai.plugin(:Network) do
182
188
  so.stdout.lines.each do |line|
183
189
  next if line.start_with?("Ring parameters for")
184
190
  next if line.strip.nil?
191
+
185
192
  if line =~ /Pre-set maximums/
186
193
  type = "max"
187
194
  next
@@ -192,7 +199,7 @@ Ohai.plugin(:Network) do
192
199
  end
193
200
  key, val = line.split(/:\s+/)
194
201
  if type && val
195
- ring_key = "#{type}_#{key.downcase.tr(' ', '_')}"
202
+ ring_key = "#{type}_#{key.downcase.tr(" ", "_")}"
196
203
  iface[tmp_int]["ring_params"][ring_key] = val.to_i
197
204
  end
198
205
  end
@@ -276,7 +283,8 @@ Ohai.plugin(:Network) do
276
283
  end
277
284
  end
278
285
 
279
- if line =~ /state (\w+)/
286
+ # https://rubular.com/r/JRp6lNANmpcLV5
287
+ if line =~ /\sstate (\w+)/
280
288
  iface[tmp_int]["state"] = $1.downcase
281
289
  end
282
290
  end
@@ -317,7 +325,7 @@ Ohai.plugin(:Network) do
317
325
  end
318
326
 
319
327
  def parse_ip_addr_link_line(cint, iface, line)
320
- if line =~ /link\/(\w+) ([\da-f\:]+) /
328
+ if line =~ %r{link/(\w+) ([\da-f\:]+) }
321
329
  iface[cint][:encapsulation] = linux_encaps_lookup($1)
322
330
  unless $2 == "00:00:00:00:00:00"
323
331
  iface[cint][:addresses] ||= Mash.new
@@ -327,7 +335,7 @@ Ohai.plugin(:Network) do
327
335
  end
328
336
 
329
337
  def parse_ip_addr_inet_line(cint, iface, line)
330
- if line =~ /inet (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})(\/(\d{1,2}))?/
338
+ if line =~ %r{inet (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})(/(\d{1,2}))?}
331
339
  tmp_addr, tmp_prefix = $1, $3
332
340
  tmp_prefix ||= "32"
333
341
  original_int = nil
@@ -364,7 +372,7 @@ Ohai.plugin(:Network) do
364
372
  end
365
373
 
366
374
  def parse_ip_addr_inet6_line(cint, iface, line)
367
- if line =~ /inet6 ([a-f0-9\:]+)\/(\d+) scope (\w+)( .*)?/
375
+ if line =~ %r{inet6 ([a-f0-9\:]+)/(\d+) scope (\w+)( .*)?}
368
376
  iface[cint][:addresses] ||= Mash.new
369
377
  tmp_addr = $1
370
378
  tags = $4 || ""
@@ -395,11 +403,13 @@ Ohai.plugin(:Network) do
395
403
 
396
404
  def interface_has_no_addresses_in_family?(iface, family)
397
405
  return true if iface[:addresses].nil?
406
+
398
407
  iface[:addresses].values.all? { |addr| addr["family"] != family }
399
408
  end
400
409
 
401
410
  def interface_have_address?(iface, address)
402
411
  return false if iface[:addresses].nil?
412
+
403
413
  iface[:addresses].key?(address)
404
414
  end
405
415
 
@@ -605,7 +615,7 @@ Ohai.plugin(:Network) do
605
615
  iface[cint][:addresses][$1] = { "family" => "inet" }
606
616
  tmp_addr = $1
607
617
  end
608
- if line =~ /inet6 addr: ([a-f0-9\:]+)\/(\d+) Scope:(\w+)/
618
+ if line =~ %r{inet6 addr: ([a-f0-9\:]+)/(\d+) Scope:(\w+)}
609
619
  iface[cint][:addresses] ||= Mash.new
610
620
  iface[cint][:addresses][$1] = { "family" => "inet6", "prefixlen" => $2, "scope" => ($3.eql?("Host") ? "Node" : $3) }
611
621
  end
@@ -650,6 +660,7 @@ Ohai.plugin(:Network) do
650
660
  so.stdout.lines do |line|
651
661
  if line =~ /^\S+ \((\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\) at ([a-fA-F0-9\:]+) \[(\w+)\] on ([0-9a-zA-Z\.\:\-]+)/
652
662
  next unless iface[$4] # this should never happen
663
+
653
664
  iface[$4][:arp] ||= Mash.new
654
665
  iface[$4][:arp][$1] = $2.downcase
655
666
  end
@@ -32,6 +32,7 @@ Ohai.plugin(:Platform) do
32
32
  "opensuse-leap" => "opensuseleap",
33
33
  "xenenterprise" => "xenserver",
34
34
  "cumulus-linux" => "cumulus",
35
+ "archarm" => "arch",
35
36
  }.freeze
36
37
 
37
38
  # @deprecated
@@ -39,20 +40,14 @@ Ohai.plugin(:Platform) do
39
40
  contents[/^Red Hat/i] ? "redhat" : contents[/(\w+)/i, 1].downcase
40
41
  end
41
42
 
42
- # Amazon Linux AMI release 2013.09
43
- # Amazon Linux 2
44
- # Amazon Linux 2 (Karoo)
45
- # Fedora release 28 (Twenty Eight)
46
- # CentOS release 5.8 (Final)
47
- # CentOS release 6.7 (Final)
48
- # Red Hat Enterprise Linux Server release 7.5 (Maipo)
43
+ # See https://rubular.com/r/78c1yXYa7zDhdV for example matches
49
44
  #
50
45
  # @param contents [String] the contents of /etc/redhat-release
51
46
  #
52
47
  # @returns [String] the version string
53
48
  #
54
49
  def get_redhatish_version(contents)
55
- contents[/Rawhide/i] ? contents[/((\d+) \(Rawhide\))/i, 1].downcase : contents[/(release)? ([\d\.]+)/, 2]
50
+ contents[/(release)? ([\d\.]+)/, 2]
56
51
  end
57
52
 
58
53
  #
@@ -64,6 +59,7 @@ Ohai.plugin(:Platform) do
64
59
  #
65
60
  def read_os_release_info(file)
66
61
  return nil unless File.exist?(file)
62
+
67
63
  File.read(file).split.inject({}) do |map, line|
68
64
  key, value = line.split("=")
69
65
  map[key] = value.gsub(/\A"|"\Z/, "") if value