ohai 18.1.18 → 18.2.6

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: ba5e0cd23be58860dbaeaa8215628de72afb4ca181235acacd356064c8cdcdb6
4
- data.tar.gz: 8059d2d3e7bf4c4a68b75f926165929446a3dbe280402438eba20be552c05fec
3
+ metadata.gz: bc1e862dfe2a3422ef70b91b2564c12e2ca00d48bee8b48960b89af65e07bc5c
4
+ data.tar.gz: efcd968a8da9052c51bfc3aaffddd8fe8c57fe571700196f9326821f24d2f852
5
5
  SHA512:
6
- metadata.gz: 5161f55dba454fff218dd4545a940cb0b324e3802930bf01b3b0d62730026d470961d4138259c4b6c8f76e3ed4059eb98e1a37b188823e02808d1e35817254e3
7
- data.tar.gz: 27e98bd57c54192067a797a1303466becf7fa0eff0448665b35782613abbe238ae8c623192afd0ac6acd270a313212384e25c98373b0f101cd766dbece762358
6
+ metadata.gz: 1717b87c35a7b0dde1b5df9366fef96b2656d63a15be005baa52c42206e811623922421fc9aaf6ceb2fce61edb077e95d3613a057f73d69d2297f94cd52661f3
7
+ data.tar.gz: ead72e1e179af3e3c2037deda21c4a4fc1a8cc8f56aa75784759f143c412c113a92ee5b1a6baf8a89ab8336dde6e84cd1aea9ef49947e30e36eac93562c411ba
data/Gemfile CHANGED
@@ -4,12 +4,12 @@ source "https://rubygems.org"
4
4
  gemspec
5
5
 
6
6
  # pull these gems from main of chef/chef so that we're testing against what we will release
7
- gem "chef-config", git: "https://github.com/chef/chef", branch: "main", glob: "chef-config/chef-config.gemspec"
8
- gem "chef-utils", git: "https://github.com/chef/chef", branch: "main", glob: "chef-utils/chef-utils.gemspec"
7
+ gem "chef-config", git: "https://github.com/chef/chef", branch: "chef-18", glob: "chef-config/chef-config.gemspec"
8
+ gem "chef-utils", git: "https://github.com/chef/chef", branch: "chef-18", glob: "chef-utils/chef-utils.gemspec"
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.2.2"
12
+ gem "cookstyle", ">= 7.32.8"
13
13
  gem "ipaddr_extensions"
14
14
  gem "rake", ">= 10.1.0"
15
15
  gem "rspec-collection_matchers", "~> 1.0"
@@ -49,7 +49,7 @@ class Ohai::Application
49
49
  short: "-l LEVEL",
50
50
  long: "--log_level LEVEL",
51
51
  description: "Set the log level (debug, info, warn, error, fatal)",
52
- proc: lambda { |l| l.to_sym }
52
+ proc: lambda(&:to_sym)
53
53
 
54
54
  option :log_location,
55
55
  short: "-L LOGLOCATION",
@@ -149,11 +149,11 @@ module Ohai
149
149
  end
150
150
 
151
151
  def provides(*paths)
152
- logger.warn("[UNSUPPORTED OPERATION] \'provides\' is no longer supported in a \'collect_data\' context. Please specify \'provides\' before collecting plugin data. Ignoring command \'provides #{paths.join(", ")}")
152
+ logger.warn("[UNSUPPORTED OPERATION] 'provides' is no longer supported in a 'collect_data' context. Please specify 'provides' before collecting plugin data. Ignoring command 'provides #{paths.join(", ")}")
153
153
  end
154
154
 
155
155
  def require_plugin(*args)
156
- logger.warn("[UNSUPPORTED OPERATION] \'require_plugin\' is no longer supported. Please use \'depends\' instead.\nIgnoring plugin(s) #{args.join(", ")}")
156
+ logger.warn("[UNSUPPORTED OPERATION] 'require_plugin' is no longer supported. Please use 'depends' instead.\nIgnoring plugin(s) #{args.join(", ")}")
157
157
  end
158
158
 
159
159
  def configuration(option, *options)
data/lib/ohai/loader.rb CHANGED
@@ -100,7 +100,7 @@ module Ohai
100
100
  contents = ""
101
101
  begin
102
102
  logger.trace("Loading plugin at #{plugin_path}")
103
- contents << IO.read(plugin_path)
103
+ contents << File.read(plugin_path)
104
104
  rescue IOError, Errno::ENOENT
105
105
  logger.warn("Unable to open or read plugin at #{plugin_path}")
106
106
  return nil
@@ -110,9 +110,9 @@ module Ohai
110
110
  if contents.include?("Ohai.plugin")
111
111
  load_v7_plugin_class(contents, plugin_path)
112
112
  else
113
- raise Exceptions::IllegalPluginDefinition, "[DEPRECATION] Plugin at #{plugin_path}"\
114
- " is a version 6 plugin. Version 6 plugins are no longer supported by Ohai. This"\
115
- " plugin will need to be updated to the v7 Ohai plugin format. See"\
113
+ raise Exceptions::IllegalPluginDefinition, "[DEPRECATION] Plugin at #{plugin_path}" \
114
+ " is a version 6 plugin. Version 6 plugins are no longer supported by Ohai. This" \
115
+ " plugin will need to be updated to the v7 Ohai plugin format. See" \
116
116
  " https://docs.chef.io/ohai_custom.html for v7 syntax."
117
117
  end
118
118
  end
@@ -151,7 +151,7 @@ module Ohai
151
151
  rescue Ohai::Exceptions::IllegalPluginDefinition => e
152
152
  logger.warn("Plugin Definition Error: <#{plugin_path}>: #{e.message}")
153
153
  rescue NoMethodError => e
154
- logger.warn("Plugin Method Error: <#{plugin_path}>: unsupported operation \'#{e.name}\'")
154
+ logger.warn("Plugin Method Error: <#{plugin_path}>: unsupported operation '#{e.name}'")
155
155
  rescue SyntaxError => e
156
156
  # split on occurrences of
157
157
  # <env>: syntax error,
@@ -248,8 +248,14 @@ module Ohai
248
248
  private
249
249
 
250
250
  def expand_path(file_name)
251
- path = file_name.gsub(/\=.*$/, "/")
252
- # ignore "./" and "../"
251
+ # First substitution - exactly matches original behavior but safer
252
+ path = if file_name.include?("=")
253
+ file_name[0...file_name.index("=")] + "/"
254
+ else
255
+ file_name.dup
256
+ end
257
+
258
+ # Handle relative path components
253
259
  path.gsub(%r{/\.\.?(?:/|$)}, "/")
254
260
  .sub(%r{^\.\.?(?:/|$)}, "")
255
261
  .sub(/^$/, "/")
@@ -25,7 +25,7 @@ class String
25
25
  # ActiveSupport::CoreExtensions::String::Inflections
26
26
  # @return [String]
27
27
  def wmi_underscore
28
- gsub(/::/, "/").gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
28
+ gsub("::", "/").gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
29
29
  .gsub(/([a-z\d])([A-Z])/, '\1_\2').tr("-", "_").downcase
30
30
  end
31
31
  end
@@ -26,11 +26,11 @@ Ohai.plugin(:Kernel) do
26
26
 
27
27
  uname_so = shell_out("uname -rvp").stdout.split
28
28
 
29
- kernel[:name] = "aix" # this is here for historical reasons, but it's always aix
29
+ kernel[:name] = "aix" # this is here for historical reasons, but it's always aix
30
30
  kernel[:release] = uname_so[0]
31
31
  kernel[:version] = uname_so[1]
32
32
  kernel[:machine] = uname_so[2]
33
- kernel[:bits] = shell_out("getconf KERNEL_BITMODE").stdout.strip
33
+ kernel[:bits] = shell_out("getconf KERNEL_BITMODE").stdout.strip
34
34
 
35
35
  modules = Mash.new
36
36
  so = shell_out("genkex -d")
@@ -120,7 +120,7 @@ Ohai.plugin(:Network) do
120
120
  interface = $6
121
121
  ifaces[interface][:routes] ||= []
122
122
  ifaces[interface][:routes] << Mash.new( destination: $1, family: family,
123
- via: $2, flags: $3)
123
+ via: $2, flags: $3)
124
124
  end
125
125
  end
126
126
  end
@@ -143,7 +143,7 @@ Ohai.plugin(:Virtualization) do
143
143
  evalstr = "wpars['#{wpar_name}']"
144
144
  breadcrumb = attribute.split(".")
145
145
  breadcrumb.each do |node|
146
- evalstr << "[\'#{node}\']"
146
+ evalstr << "['#{node}']"
147
147
  end
148
148
  wpars[wpar_name][breadcrumb[-1]] = eval evalstr # rubocop: disable Security/Eval
149
149
  end
@@ -54,7 +54,7 @@ Ohai.plugin(:Alibaba) do
54
54
  # a single check that combines all the various detection methods for Alibaba
55
55
  # @return [Boolean] Does the system appear to be on Alibaba
56
56
  def looks_like_alibaba?
57
- return true if hint?("alibaba") || has_ali_dmi?
57
+ true if hint?("alibaba") || has_ali_dmi?
58
58
  end
59
59
 
60
60
  collect_data do
@@ -63,7 +63,8 @@ Ohai.plugin(:CPU) do
63
63
  def parse_lscpu(cpu_info)
64
64
  lscpu_info = Mash.new
65
65
  begin
66
- so = shell_out("lscpu")
66
+ # Pipe to cat to retain previous output on newer util-linux (see lscpu(1))
67
+ so = shell_out("lscpu | cat")
67
68
  cpu_cores = shell_out("lscpu -p=CPU,CORE,SOCKET")
68
69
  if so.exitstatus == 0 && cpu_cores.exitstatus == 0
69
70
  lscpu_info[:numa_node_cpus] = Mash.new
@@ -96,10 +97,12 @@ Ohai.plugin(:CPU) do
96
97
  end
97
98
  when /^Thread\(s\) per core:\s+(.+)/ # http://rubular.com/r/lOw2pRrw1q
98
99
  lscpu_info[:threads_per_core] = $1.to_i
99
- when /^Core\(s\) per socket:\s+(.+)/ # http://rubular.com/r/lOw2pRrw1q
100
+ when /^Core\(s\) per (?:socket|cluster):\s+(.+)/ # http://rubular.com/r/lOw2pRrw1q
100
101
  lscpu_info[:cores_per_socket] = $1.to_i
101
102
  when /^Socket\(s\):\s+(.+)/ # http://rubular.com/r/DIzmPtJFvK
102
103
  lscpu_info[:sockets] = $1.to_i
104
+ when /^Clusters\(s\):\s+(.+)/
105
+ lscpu_info[:clusters] = $1.to_i
103
106
  when /^Socket\(s\) per book:\s+(.+)/
104
107
  lscpu_info[:sockets_per_book] = $1.to_i
105
108
  when /^Book\(s\) per drawer:\s+(.+)/
@@ -110,6 +113,10 @@ Ohai.plugin(:CPU) do
110
113
  lscpu_info[:numa_nodes] = $1.to_i
111
114
  when /^Vendor ID:\s+(.+)/
112
115
  lscpu_info[:vendor_id] = $1
116
+ when /^BIOS Vendor ID:\s+(.+)/
117
+ lscpu_info[:bios_vendor_id] = $1
118
+ when /^BIOS Model name:\s+(.+)/
119
+ lscpu_info[:bios_model_name] = $1.strip
113
120
  when /^Machine type:\s+(.+)/
114
121
  lscpu_info[:machine_type] = $1
115
122
  when /^CPU family:\s+(.+)/
@@ -630,6 +637,6 @@ Ohai.plugin(:CPU) do
630
637
 
631
638
  cpu[:total] = logical_processors
632
639
  cpu[:cores] = cores
633
- cpu[:real] = processors.length
640
+ cpu[:real] = processors.length
634
641
  end
635
642
  end
@@ -36,7 +36,7 @@ Ohai.plugin(:Virtualization) do
36
36
  end
37
37
 
38
38
  def fusion_exists?
39
- file_exist?("/Applications/VMware\ Fusion.app/")
39
+ file_exist?("/Applications/VMware Fusion.app/")
40
40
  end
41
41
 
42
42
  def docker_exists?
@@ -276,19 +276,21 @@ Ohai.plugin(:Filesystem) do
276
276
  if entry[:fs_type] == "btrfs" && entry["uuid"]
277
277
  uuid = entry["uuid"]
278
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
279
+ if Dir.exist?(alloc)
280
+ %w{data metadata system}.each do |bg_type|
281
+ dir = "#{alloc}/#{bg_type}"
282
+ %w{single dup}.each do |raid|
283
+ if file_exist?("#{dir}/#{raid}")
284
+ btrfs["raid"] = raid
285
+ end
286
+ end
287
+ logger.trace("Plugin Filesystem: reading btrfs allocation files at #{dir}")
288
+ btrfs["allocation"] ||= Mash.new
289
+ btrfs["allocation"][bg_type] ||= Mash.new
290
+ %w{total_bytes bytes_used}.each do |field|
291
+ bytes = file_read("#{dir}/#{field}").chomp.to_i
292
+ btrfs["allocation"][bg_type][field] = "#{bytes}"
284
293
  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
294
  end
293
295
  end
294
296
  end
@@ -72,7 +72,7 @@ Ohai.plugin(:GCE) do
72
72
  return true if hint?("gce")
73
73
 
74
74
  if has_gce_dmi? || has_gce_system_info?
75
- return true if can_socket_connect?(Ohai::Mixin::GCEMetadata::GCE_METADATA_ADDR, 80)
75
+ true if can_socket_connect?(Ohai::Mixin::GCEMetadata::GCE_METADATA_ADDR, 80)
76
76
  end
77
77
  end
78
78
 
@@ -27,9 +27,8 @@ Ohai.plugin(:Interrupts) do
27
27
  # each bit is a CPU, right to left ordering (i.e. CPU0 is rightmost)
28
28
  def parse_smp_affinity(path, cpus)
29
29
  masks = file_read(path).strip
30
- bit_masks = []
31
- masks.split(",").each do |mask|
32
- bit_masks << mask.rjust(8, "0").to_i(16).to_s(2)
30
+ bit_masks = masks.split(",").map do |mask|
31
+ mask.rjust(8, "0").to_i(16).to_s(2)
33
32
  end
34
33
  affinity_mask = bit_masks.join
35
34
  affinity_by_cpu = affinity_mask.split("").reverse
@@ -104,7 +104,7 @@ Ohai.plugin(:Network) do
104
104
  end
105
105
  route_endings.each do |route_ending|
106
106
  route_entry = Mash.new(destination: route_dest,
107
- family: family[:name])
107
+ family: family[:name])
108
108
  route_int = nil
109
109
  if route_ending =~ /\bdev\s+([^\s]+)\b/
110
110
  route_int = $1
@@ -31,7 +31,7 @@ Ohai.plugin(:Passwd) do
31
31
 
32
32
  Etc.group do |entry|
33
33
  group_entry = Mash.new(gid: entry.gid,
34
- members: entry.mem.map { |u| fix_encoding(u) })
34
+ members: entry.mem.map { |u| fix_encoding(u) })
35
35
 
36
36
  etc[:group][fix_encoding(entry.name)] = group_entry
37
37
  end
@@ -18,12 +18,24 @@
18
18
  #
19
19
 
20
20
  Ohai.plugin(:Platform) do
21
- provides "platform", "platform_version", "platform_family"
21
+ provides "platform", "platform_version", "platform_family", "platform_backend"
22
22
  depends "os", "os_version"
23
23
 
24
24
  collect_data(:default) do
25
25
  platform os unless attribute?("platform")
26
26
  platform_version os_version unless attribute?("platform_version")
27
27
  platform_family platform unless attribute?("platform_family")
28
+
29
+ platform_backend Mash.new
30
+ platform_backend["type"] = "local"
31
+ platform_backend["uri"] = "local://"
32
+
33
+ if connection
34
+ platform_backend["type"] = connection.backend_type
35
+ if connection.respond_to?(:uri)
36
+ platform_backend["type"] = connection.uri.split(":").first
37
+ platform_backend["uri"] = connection.uri
38
+ end
39
+ end
28
40
  end
29
41
  end
@@ -115,7 +115,7 @@ Ohai.plugin(:Rackspace) do
115
115
  def get_instance_id
116
116
  so = shell_out("xenstore-read name")
117
117
  if so.exitstatus == 0
118
- rackspace[:instance_id] = so.stdout.gsub(/instance-/, "")
118
+ rackspace[:instance_id] = so.stdout.gsub("instance-", "")
119
119
  end
120
120
  rescue Ohai::Exceptions::Exec
121
121
  logger.trace("Plugin Rackspace: Unable to find xenstore-read, cannot capture instance ID information for Rackspace cloud")
@@ -65,8 +65,8 @@ module Ohai
65
65
  plugins = []
66
66
  attributes.each do |attribute|
67
67
  attrs = select_subtree(@map, attribute)
68
- raise Ohai::Exceptions::AttributeNotFound, "No such attribute: \'#{attribute}\'" unless attrs
69
- raise Ohai::Exceptions::ProviderNotFound, "Cannot find plugin providing attribute: \'#{attribute}\'" unless attrs[:_plugins]
68
+ raise Ohai::Exceptions::AttributeNotFound, "No such attribute: '#{attribute}'" unless attrs
69
+ raise Ohai::Exceptions::ProviderNotFound, "Cannot find plugin providing attribute: '#{attribute}'" unless attrs[:_plugins]
70
70
 
71
71
  plugins += attrs[:_plugins]
72
72
  end
@@ -93,7 +93,7 @@ module Ohai
93
93
  attrs = select_closest_subtree(@map, attribute)
94
94
 
95
95
  unless attrs
96
- raise Ohai::Exceptions::AttributeNotFound, "No such attribute: \'#{attribute}\'"
96
+ raise Ohai::Exceptions::AttributeNotFound, "No such attribute: '#{attribute}'"
97
97
  end
98
98
  end
99
99
 
@@ -115,10 +115,10 @@ module Ohai
115
115
  plugins = []
116
116
  attributes.each do |attribute|
117
117
  parts = normalize_and_validate(attribute)
118
- raise Ohai::Exceptions::AttributeNotFound, "No such attribute: \'#{attribute}\'" unless @map[parts[0]]
118
+ raise Ohai::Exceptions::AttributeNotFound, "No such attribute: '#{attribute}'" unless @map[parts[0]]
119
119
 
120
120
  attrs = select_closest_subtree(@map, attribute)
121
- raise Ohai::Exceptions::ProviderNotFound, "Cannot find plugin providing attribute: \'#{attribute}\'" unless attrs
121
+ raise Ohai::Exceptions::ProviderNotFound, "Cannot find plugin providing attribute: '#{attribute}'" unless attrs
122
122
 
123
123
  plugins += attrs[:_plugins]
124
124
  end
data/lib/ohai/runner.rb CHANGED
@@ -119,9 +119,7 @@ module Ohai
119
119
  # cycle. Does not include plugins that aren't a part of the cycle
120
120
  def get_cycle(plugins, cycle_start)
121
121
  cycle = plugins.drop_while { |plugin| !plugin.eql?(cycle_start) }
122
- names = []
123
- cycle.each { |plugin| names << plugin.name }
124
- names
122
+ cycle.map(&:name)
125
123
  end
126
124
 
127
125
  end
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 = "18.1.18"
22
+ VERSION = "18.2.6"
23
23
  end
data/ohai.gemspec CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |s|
16
16
 
17
17
  s.add_dependency "chef-config", ">= 14.12", "< 19"
18
18
  s.add_dependency "chef-utils", ">= 16.0", "< 19"
19
- s.add_dependency "ffi", "~> 1.9"
19
+ s.add_dependency "ffi", "~> 1.9", "<= 1.17.0"
20
20
  s.add_dependency "ffi-yajl", "~> 2.2"
21
21
  s.add_dependency "ipaddress"
22
22
  s.add_dependency "mixlib-cli", ">= 1.7.0" # 1.7+ needed to support passing multiple options
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: 18.1.18
4
+ version: 18.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Jacob
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-05-28 00:00:00.000000000 Z
11
+ date: 2025-05-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chef-config
@@ -57,6 +57,9 @@ dependencies:
57
57
  - - "~>"
58
58
  - !ruby/object:Gem::Version
59
59
  version: '1.9'
60
+ - - "<="
61
+ - !ruby/object:Gem::Version
62
+ version: 1.17.0
60
63
  type: :runtime
61
64
  prerelease: false
62
65
  version_requirements: !ruby/object:Gem::Requirement
@@ -64,6 +67,9 @@ dependencies:
64
67
  - - "~>"
65
68
  - !ruby/object:Gem::Version
66
69
  version: '1.9'
70
+ - - "<="
71
+ - !ruby/object:Gem::Version
72
+ version: 1.17.0
67
73
  - !ruby/object:Gem::Dependency
68
74
  name: ffi-yajl
69
75
  requirement: !ruby/object:Gem::Requirement
@@ -401,7 +407,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
401
407
  - !ruby/object:Gem::Version
402
408
  version: '0'
403
409
  requirements: []
404
- rubygems_version: 3.2.3
410
+ rubygems_version: 3.3.27
405
411
  signing_key:
406
412
  specification_version: 4
407
413
  summary: Ohai profiles your system and emits JSON