ohai 17.9.0 → 18.0.14

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4d6aab3006a40779de433a6634b5be22fcb2ed1950c4b67d22eaa1fc18cc8993
4
- data.tar.gz: ae3152a23474650f3d5c497ff8e966273a14656dc6d8f454ce4ac769a6259f1a
3
+ metadata.gz: e3f13e229791bcb56c90dfc30f3fa5fea108b9d185c1c0492a5198c2e6bae93b
4
+ data.tar.gz: 60134dedd0d7da72c1932dc987b143303d9f832bf123380ab22db9462e6799b2
5
5
  SHA512:
6
- metadata.gz: 1d7331b209e4d513403cd87949ab0eb4f65a00597da848e22042c2658734cd999c9419ea2fa135e8fcb253eb69c97881324ccbb519198726ba445aec71cb8732
7
- data.tar.gz: 6673a8e0fcdaa7cc26fddf35ef54fc88169bcccbecb9f00d85cfa3584661c0c4803869c86b71615f9f69a65dd45aefdd0e22bd6a3a426a34ab8180370312f49e
6
+ metadata.gz: 735fb50fdd3ee96a1325eaae9847d0f998b72b50116963d829bd7b350d5b6af4e76089083612c7a66f7ec7e80a374e45b25b711b38e6ff5c0435f9ac66ae39ec
7
+ data.tar.gz: ed81c806e9d91688e5c7aa5a4246aea55e62a8dbca35e3c89698795c29f45083572bafdf62382abcce201c53b736a1f11b2fcd17e4ff5aa61a114707fc2f1b11
data/Gemfile CHANGED
@@ -9,14 +9,14 @@ gem "chef-utils", git: "https://github.com/chef/chef", branch: "main", glob: "ch
9
9
 
10
10
  # NOTE: do not submit PRs to add pry as a dep, add to your Gemfile.local
11
11
  group :development do
12
- gem "chefstyle", "2.1.3"
12
+ gem "chefstyle", "2.2.2"
13
13
  gem "ipaddr_extensions"
14
14
  gem "rake", ">= 10.1.0"
15
15
  gem "rspec-collection_matchers", "~> 1.0"
16
16
  gem "rspec-core", "~> 3.0"
17
17
  gem "rspec-expectations", "~> 3.0"
18
18
  gem "rspec-mocks", "~> 3.0"
19
- gem "rubocop-performance", "1.12.0"
19
+ gem "rubocop-performance", "1.13.3"
20
20
  gem "rubocop-rspec"
21
21
  end
22
22
 
@@ -35,9 +35,10 @@ module Ohai
35
35
  AZURE_METADATA_ADDR ||= "169.254.169.254"
36
36
 
37
37
  # it's important that the newer versions are at the end of this array so we can skip sorting it
38
- AZURE_SUPPORTED_VERSIONS ||= %w{ 2017-04-02 2017-08-01 2017-12-01 2018-02-01 2018-04-02
39
- 2018-10-01 2019-02-01 2019-03-11 2019-04-30 2019-06-01
40
- 2019-06-04 2019-08-01 2019-08-15 2019-11-01 }.freeze
38
+ AZURE_SUPPORTED_VERSIONS ||= %w{ 2018-10-01 2019-02-01 2019-03-11 2019-04-30 2019-06-01
39
+ 2019-06-04 2019-08-01 2019-08-15 2019-11-01 2020-06-01
40
+ 2020-07-15 2020-09-01 2020-10-01 2020-12-01 2021-01-01
41
+ 2021-02-01 2021-03-01 2021-05-01 2021-10-01 }.freeze
41
42
 
42
43
  def best_api_version
43
44
  @api_version ||= begin
data/lib/ohai/mixin/os.rb CHANGED
@@ -110,7 +110,7 @@ module Ohai
110
110
  "dragonflybsd"
111
111
  when /solaris2/
112
112
  "solaris2"
113
- when /mswin|mingw32|windows/
113
+ when /mswin|mingw|windows/
114
114
  # After long discussion in IRC the "powers that be" have come to a consensus
115
115
  # that no Windows platform exists that was not based on the
116
116
  # Windows_NT kernel, so we herby decree that "windows" will refer to all
@@ -73,9 +73,11 @@ Ohai.plugin(:Azure) do
73
73
  end
74
74
 
75
75
  def tcp_ip_dhcp_domain
76
- return unless RUBY_PLATFORM.match?(/mswin|mingw32|windows/)
76
+ return unless RUBY_PLATFORM.match?(/mswin|mingw|windows/)
77
77
 
78
- require "win32/registry" unless defined?(Win32::Registry)
78
+ if ChefUtils.windows?
79
+ require "win32/registry" unless defined?(Win32::Registry)
80
+ end
79
81
 
80
82
  begin
81
83
  key = Win32::Registry::HKEY_LOCAL_MACHINE.open("SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters")
@@ -81,7 +81,7 @@ Ohai.plugin(:EC2) do
81
81
  # linux hosts
82
82
  # @return [Boolean] do we have a Xen Identifying Number or not?
83
83
  def has_ec2_identifying_number?
84
- if RUBY_PLATFORM.match?(/mswin|mingw32|windows/)
84
+ if RUBY_PLATFORM.match?(/mswin|mingw|windows/)
85
85
  require "wmi-lite/wmi" unless defined?(WmiLite::Wmi)
86
86
  wmi = WmiLite::Wmi.new
87
87
  if /^ec2/.match?(wmi.first_of("Win32_ComputerSystemProduct")["identifyingnumber"])
@@ -142,8 +142,8 @@ Ohai.plugin(:EC2) do
142
142
  ec2[:account_id] = fetch_dynamic_data["accountId"]
143
143
  ec2[:availability_zone] = fetch_dynamic_data["availabilityZone"]
144
144
  ec2[:region] = fetch_dynamic_data["region"]
145
- # ASCII-8BIT is equivalent to BINARY in this case
146
- if ec2[:userdata] && ec2[:userdata].encoding.to_s == "ASCII-8BIT"
145
+
146
+ if ec2[:userdata] && ec2[:userdata].encoding == Encoding::BINARY
147
147
  logger.trace("Plugin EC2: Binary UserData Found. Storing in base64")
148
148
  ec2[:userdata] = Base64.encode64(ec2[:userdata])
149
149
  end
@@ -271,6 +271,30 @@ Ohai.plugin(:Filesystem) do
271
271
  fs
272
272
  end
273
273
 
274
+ def collect_btrfs_data(entry)
275
+ btrfs = Mash.new
276
+ if entry[:fs_type] == "btrfs" && entry["uuid"]
277
+ uuid = entry["uuid"]
278
+ alloc = "/sys/fs/btrfs/#{uuid}/allocation"
279
+ %w{data metadata system}.each do |bg_type|
280
+ dir = "#{alloc}/#{bg_type}"
281
+ %w{single dup}.each do |raid|
282
+ if file_exist?("#{dir}/#{raid}")
283
+ btrfs["raid"] = raid
284
+ end
285
+ end
286
+ logger.trace("Plugin Filesystem: reading btrfs allocation files at #{dir}")
287
+ btrfs["allocation"] ||= Mash.new
288
+ btrfs["allocation"][bg_type] ||= Mash.new
289
+ %w{total_bytes bytes_used}.each do |field|
290
+ bytes = file_read("#{dir}/#{field}").chomp.to_i
291
+ btrfs["allocation"][bg_type][field] = "#{bytes}"
292
+ end
293
+ end
294
+ end
295
+ btrfs
296
+ end
297
+
274
298
  collect_data(:linux) do
275
299
  fs = Mash.new
276
300
 
@@ -394,6 +418,12 @@ Ohai.plugin(:Filesystem) do
394
418
  end
395
419
  end
396
420
 
421
+ fs.each do |key, entry|
422
+ if entry[:fs_type] == "btrfs"
423
+ fs[key][:btrfs] = collect_btrfs_data(entry)
424
+ end
425
+ end
426
+
397
427
  by_pair = fs
398
428
  by_device = generate_device_view(fs)
399
429
  by_mountpoint = generate_mountpoint_view(fs)
@@ -49,7 +49,7 @@ Ohai.plugin(:GCE) do
49
49
  # looks at the Manufacturer and Model WMI values to see if they starts with Google.
50
50
  # @return [Boolean] Are the manufacturer and model Google?
51
51
  def has_gce_system_info?
52
- if RUBY_PLATFORM.match?(/mswin|mingw32|windows/)
52
+ if RUBY_PLATFORM.match?(/mswin|mingw|windows/)
53
53
  require "wmi-lite/wmi" unless defined?(WmiLite::Wmi)
54
54
  wmi = WmiLite::Wmi.new
55
55
  computer_system = wmi.first_of("Win32_ComputerSystem")
@@ -35,6 +35,8 @@ Ohai.plugin(:Mdadm) do
35
35
  device_mash[:size] = Regexp.last_match[1].to_f
36
36
  when /State\s+: ([a-z]+)/
37
37
  device_mash[:state] = Regexp.last_match[1]
38
+ when /UUID\s+: ([0-9a-z:]+)/
39
+ device_mash[:UUID] = Regexp.last_match[1]
38
40
  when /Total Devices\s+: ([0-9]+)/
39
41
  device_mash[:device_counts][:total] = Regexp.last_match[1].to_i
40
42
  when /Raid Devices\s+: ([0-9]+)/
@@ -80,9 +80,22 @@ Ohai.plugin(:Network) do
80
80
  line.strip!
81
81
  logger.trace("Plugin Network: Parsing #{line}")
82
82
  if /\\/.match?(line)
83
+ # If we have multipath routing, then the first part will be a normal
84
+ # looking route:
85
+ # default proto ra metric 1024 <other options>
86
+ # Each successive part after that is a hop without those options.
87
+ # So the first thing we do is grab that first part, and split it into
88
+ # the route destination ("default"), and the route options.
83
89
  parts = line.split("\\")
84
- route_dest = parts.shift.strip
85
- route_endings = parts
90
+ route_dest, dest_opts = parts.first.split(nil, 2)
91
+ # Then all the route endings, generally just nexthops.
92
+ route_endings = parts[1..]
93
+ if dest_opts && !dest_opts.empty?
94
+ # Route options like proto, metric, etc. only appear once for each
95
+ # multipath configuration. Prepend this information to the route
96
+ # endings so the code below will assign the fields properly.
97
+ route_endings.map! { |e| e.include?("nexthop") ? "#{dest_opts} #{e}" : e }
98
+ end
86
99
  elsif line =~ /^([^\s]+)\s(.*)$/
87
100
  route_dest = $1
88
101
  route_endings = [$2]
@@ -90,9 +103,24 @@ Ohai.plugin(:Network) do
90
103
  next
91
104
  end
92
105
  route_endings.each do |route_ending|
106
+ route_entry = Mash.new(destination: route_dest,
107
+ family: family[:name])
108
+ route_int = nil
93
109
  if route_ending =~ /\bdev\s+([^\s]+)\b/
94
110
  route_int = $1
95
- else
111
+ end
112
+ # does any known interface own the src address?
113
+ # we try to infer the interface/device from its address if it isn't specified
114
+ # we want to override the interface set via nexthop but only if possible
115
+ if line =~ /\bsrc\s+([^\s]+)\b/ && (!route_int || line.include?("nexthop"))
116
+ # only clobber previously set route_int if we find a match
117
+ if (match = iface.select { |name, intf| intf.fetch("addresses", {}).any? { |addr, _| addr == $1 } }.keys.first)
118
+ route_int = match
119
+ route_entry[:inferred] = true
120
+ end
121
+ end
122
+
123
+ unless route_int
96
124
  logger.trace("Plugin Network: Skipping route entry without a device: '#{line}'")
97
125
  next
98
126
  end
@@ -103,8 +131,6 @@ Ohai.plugin(:Network) do
103
131
  next
104
132
  end
105
133
 
106
- route_entry = Mash.new(destination: route_dest,
107
- family: family[:name])
108
134
  %w{via scope metric proto src}.each do |k|
109
135
  # http://rubular.com/r/pwTNp65VFf
110
136
  route_entry[k] = $1 if route_ending =~ /\b#{k}\s+([^\s]+)/
@@ -350,6 +376,7 @@ Ohai.plugin(:Network) do
350
376
  so = shell_out("ip -d -s link")
351
377
  tmp_int = nil
352
378
  on_rx = true
379
+ xdp_mode = nil
353
380
  so.stdout.lines do |line|
354
381
  if line =~ IPROUTE_INT_REGEX
355
382
  tmp_int = $2
@@ -425,6 +452,30 @@ Ohai.plugin(:Network) do
425
452
  if line =~ /\sstate (\w+)/
426
453
  iface[tmp_int]["state"] = $1.downcase
427
454
  end
455
+
456
+ if line.include?("xdp")
457
+ mode = line.scan(/\s(xdp|xdpgeneric|xdpoffload|xdpmulti)\s/).flatten[0]
458
+ # Fetches and sets the mode from the first line.
459
+ unless mode.nil?
460
+ iface[tmp_int][:xdp] = {}
461
+ if mode.eql?("xdp")
462
+ # In case of xdpdrv, mode is xdp,
463
+ # to keep it consistent, keeping mode as xdpdrv.
464
+ mode = "xdpdrv"
465
+ end
466
+ xdp_mode = mode
467
+ iface[tmp_int][:xdp][:attached] = []
468
+ end
469
+
470
+ if line =~ %r{prog/(\w+) id (\d+) tag (\w+)}
471
+ mode = $1.eql?("xdp") ? xdp_mode : $1
472
+ iface[tmp_int][:xdp][:attached] << {
473
+ mode: mode,
474
+ id: $2,
475
+ tag: $3,
476
+ }
477
+ end
478
+ end
428
479
  end
429
480
  iface
430
481
  end
@@ -607,10 +658,12 @@ Ohai.plugin(:Network) do
607
658
  # sorting the selected routes:
608
659
  # - getting default routes first
609
660
  # - then sort by metric
661
+ # - then sort by if the device was inferred or not (preferring explicit to inferred)
610
662
  # - then by prefixlen
611
663
  [
612
664
  r[:destination] == "default" ? 0 : 1,
613
665
  r[:metric].nil? ? 0 : r[:metric].to_i,
666
+ r[:inferred] ? 1 : 0,
614
667
  # for some reason IPAddress doesn't accept "::/0", it doesn't like prefix==0
615
668
  # just a quick workaround: use 0 if IPAddress fails
616
669
  begin
@@ -49,7 +49,7 @@ Ohai.plugin(:Openstack) do
49
49
  # https://help.dreamhost.com/hc/en-us/articles/228377408-How-to-find-the-default-user-of-an-image
50
50
  def openstack_provider
51
51
  # dream host doesn't support windows so bail early if we're on windows
52
- return "openstack" if RUBY_PLATFORM.match?(/mswin|mingw32|windows/)
52
+ return "openstack" if RUBY_PLATFORM.match?(/mswin|mingw|windows/)
53
53
 
54
54
  if Etc::Passwd.entries.map(&:name).include?("dhc-user")
55
55
  "dreamhost"
@@ -48,7 +48,7 @@ Ohai.plugin(:Rackspace) do
48
48
  # true:: If the rackspace cloud can be identified
49
49
  # false:: Otherwise
50
50
  def has_rackspace_manufacturer?
51
- return false unless RUBY_PLATFORM.match?(/mswin|mingw32|windows/)
51
+ return false unless RUBY_PLATFORM.match?(/mswin|mingw|windows/)
52
52
 
53
53
  require "wmi-lite/wmi" unless defined?(WmiLite::Wmi)
54
54
  wmi = WmiLite::Wmi.new
data/lib/ohai/version.rb CHANGED
@@ -19,5 +19,5 @@
19
19
 
20
20
  module Ohai
21
21
  OHAI_ROOT = File.expand_path(__dir__)
22
- VERSION = "17.9.0"
22
+ VERSION = "18.0.14"
23
23
  end
data/ohai.gemspec CHANGED
@@ -14,8 +14,8 @@ Gem::Specification.new do |s|
14
14
 
15
15
  s.required_ruby_version = ">= 2.7"
16
16
 
17
- s.add_dependency "chef-config", ">= 14.12", "< 18"
18
- s.add_dependency "chef-utils", ">= 16.0", "< 18"
17
+ s.add_dependency "chef-config", ">= 14.12", "< 19"
18
+ s.add_dependency "chef-utils", ">= 16.0", "< 19"
19
19
  s.add_dependency "ffi", "~> 1.9"
20
20
  s.add_dependency "ffi-yajl", "~> 2.2"
21
21
  s.add_dependency "ipaddress"
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.9.0
4
+ version: 18.0.14
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-12-10 00:00:00.000000000 Z
11
+ date: 2022-06-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chef-config
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: '14.12'
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '18'
22
+ version: '19'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,7 @@ dependencies:
29
29
  version: '14.12'
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '18'
32
+ version: '19'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: chef-utils
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -39,7 +39,7 @@ dependencies:
39
39
  version: '16.0'
40
40
  - - "<"
41
41
  - !ruby/object:Gem::Version
42
- version: '18'
42
+ version: '19'
43
43
  type: :runtime
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
@@ -49,7 +49,7 @@ dependencies:
49
49
  version: '16.0'
50
50
  - - "<"
51
51
  - !ruby/object:Gem::Version
52
- version: '18'
52
+ version: '19'
53
53
  - !ruby/object:Gem::Dependency
54
54
  name: ffi
55
55
  requirement: !ruby/object:Gem::Requirement