ohai 15.6.3 → 15.12.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 257f27a9e93bbd45470aa2e42c2a9e1e503e8d2e6568a5cbca4d8d964724e854
4
- data.tar.gz: aa10fc60bdf94170e7d14f9bf38278974baf68995869c7a9467f45081d193e61
3
+ metadata.gz: 3cc502163cd1c79f43b4b934c425a00b2b00c2626cefb82882659fa4756dd82f
4
+ data.tar.gz: 2eadca5148f5f1c0706157f3b2c7c2cfe6606c304f249815c418aba69ca87c53
5
5
  SHA512:
6
- metadata.gz: 2595eef2b22bcafea6af89415c1ab6566036badb6b8ffba253be3ada2529632ad8210201d38bd5b56d2087cb5b2f2f513479a77ba8e0af5385ade1c250ae50dc
7
- data.tar.gz: 4b8c0e3daa5eda327ce6f48f4c7ed34f7e045262e68a3f99c7e78667cc00f15ec4674c37efe4f134c71768841635739cfef06814b598c435cf70cd0d4058ffdb
6
+ metadata.gz: d3e0b6ae3e18c740ca5e30db4d4db8200c1cae7b742bd5cdda9541c05cc30e8d0570250b86b51dc5397cd8cc383d63d82240ffb5bb069ce9457b536a6c87dfed
7
+ data.tar.gz: 3925101539b829009b8215eddaccb20d6b88c791ee69224cddd7d4c824bc5939dab97352e97184183d8f1561b3a14108187370e37ac006869cbc8cceae7ce4f2
data/Gemfile CHANGED
@@ -2,9 +2,8 @@ source "https://rubygems.org"
2
2
 
3
3
  gemspec
4
4
 
5
- # NOTE: do not submit PRs to add pry as a dep, add to your Gemfile.local
6
5
  group :development do
7
- gem "chefstyle", git: "https://github.com/chef/chefstyle.git", branch: "master"
6
+ gem "chefstyle", "~> 1.0"
8
7
  gem "rake", ">= 10.1.0"
9
8
  gem "rspec-core", "~> 3.0"
10
9
  gem "rspec-expectations", "~> 3.0"
@@ -26,6 +25,6 @@ end
26
25
  group :debug do
27
26
  gem "pry"
28
27
  gem "pry-byebug"
29
- gem "pry-stack_explorer"
28
+ gem "pry-stack_explorer", "~> 0.4.0" # pin until we drop ruby < 2.6
30
29
  gem "rb-readline"
31
30
  end
@@ -117,12 +117,12 @@ module Ohai
117
117
  def convenience_keys(dmi)
118
118
  dmi.each do |type, records|
119
119
  in_common = Mash.new
120
- next unless records.class.to_s == "Mash"
120
+ next unless records.is_a?(Mash)
121
121
  next unless records.key?("all_records")
122
122
 
123
123
  records[:all_records].each do |record|
124
124
  record.each do |field, value|
125
- next if value.class.to_s == "Mash"
125
+ next if value.is_a?(Mash)
126
126
  next if field.to_s == "application_identifier"
127
127
  next if field.to_s == "size"
128
128
  next if field.to_s == "record_id"
@@ -39,7 +39,7 @@ module Ohai
39
39
  # causes all optional plugins to be run.
40
40
  default :run_all_plugins, false
41
41
  # optional plugins are the set of plugins that are marked optional but you wish to run.
42
- default :optional_plugins, []
42
+ default(:optional_plugins, []).writes_value { |arr| arr.map(&:to_sym) }
43
43
  default :shellout_timeout, 30
44
44
  end
45
45
  end
@@ -41,8 +41,8 @@ Ohai.plugin(:Hardware) do
41
41
  hardware.merge!(hw_hash[0]["_items"][0])
42
42
 
43
43
  # ProductName: Mac OS X
44
- # ProductVersion: 10.12.5
45
- # BuildVersion: 16F73
44
+ # ProductVersion: 10.15.6
45
+ # BuildVersion: 19G46c
46
46
  shell_out("sw_vers").stdout.lines.each do |line|
47
47
  case line
48
48
  when /^ProductName:\s*(.*)$/
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Adam Jacob (<adam@chef.io>)
3
- # Copyright:: Copyright (c) 2008-2016 Chef Software, Inc.
3
+ # Copyright:: Copyright (c) Chef Software, Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -23,11 +23,6 @@ Ohai.plugin(:Platform) do
23
23
  so = shell_out((Ohai.abs_path( "/usr/bin/sw_vers" )).to_s)
24
24
  so.stdout.lines do |line|
25
25
  case line
26
- when /^ProductName:\s+(.+)$/
27
- macname = $1
28
- macname.downcase!
29
- macname.tr!(" ", "_")
30
- platform macname
31
26
  when /^ProductVersion:\s+(.+)$/
32
27
  platform_version $1
33
28
  when /^BuildVersion:\s+(.+)$/
@@ -35,6 +30,8 @@ Ohai.plugin(:Platform) do
35
30
  end
36
31
  end
37
32
 
33
+ # if we're on darwin assume we're on mac_os_x
34
+ platform "mac_os_x"
38
35
  platform_family "mac_os_x"
39
36
  end
40
37
  end
@@ -162,6 +162,9 @@ Ohai.plugin(:Filesystem) do
162
162
  end
163
163
 
164
164
  ### Windows specific methods BEGINS
165
+ # Drive types
166
+ DRIVE_TYPE ||= %w{unknown no_root_dir removable local network cd ram}.freeze
167
+
165
168
  # Volume encryption or decryption status
166
169
  #
167
170
  # @see https://docs.microsoft.com/en-us/windows/desktop/SecProv/getconversionstatus-win32-encryptablevolume#parameters
@@ -173,7 +176,7 @@ Ohai.plugin(:Filesystem) do
173
176
 
174
177
  # Returns a Mash loaded with logical details
175
178
  #
176
- # Uses Win32_LogicalDisk and logical_properties to return encryption details of volumes.
179
+ # Uses Win32_LogicalDisk and logical_properties to return general details of volumes.
177
180
  #
178
181
  # Returns an empty Mash in case of any WMI exception.
179
182
  #
@@ -184,7 +187,7 @@ Ohai.plugin(:Filesystem) do
184
187
  def logical_info
185
188
  wmi = WmiLite::Wmi.new("Root\\CIMV2")
186
189
 
187
- # Note: we should really be parsing Win32_Volume and Win32_Mapped drive.
190
+ # TODO: We should really be parsing Win32_Volume and Win32_MountPoint.
188
191
  disks = wmi.instances_of("Win32_LogicalDisk")
189
192
  logical_properties(disks)
190
193
  rescue WmiLite::WmiException
@@ -234,9 +237,9 @@ Ohai.plugin(:Filesystem) do
234
237
  properties = Mash.new
235
238
  disks.each do |disk|
236
239
  property = Mash.new
237
- # In windows the closet thing we have to a device is the volume_name
240
+ # In windows the closest thing we have to a device is the volume name
238
241
  # and the "mountpoint" is the drive letter...
239
- device = disk["volume_name"].to_s.downcase
242
+ device = disk["volumename"].to_s.downcase
240
243
  mount = disk["deviceid"]
241
244
  property[:kb_size] = disk["size"] ? disk["size"].to_i / 1000 : 0
242
245
  property[:kb_available] = disk["freespace"].to_i / 1000
@@ -244,7 +247,10 @@ Ohai.plugin(:Filesystem) do
244
247
  property[:percent_used] = (property[:kb_size] == 0 ? 0 : (property[:kb_used] * 100 / property[:kb_size]))
245
248
  property[:mount] = mount
246
249
  property[:fs_type] = disk["filesystem"].to_s.downcase
247
- property[:volume_name] = device
250
+ property[:drive_type] = disk["drivetype"].to_i
251
+ property[:drive_type_string] = DRIVE_TYPE[disk["drivetype"].to_i]
252
+ property[:drive_type_human] = disk["description"].to_s
253
+ property[:volume_name] = disk["volumename"].to_s
248
254
  property[:device] = device
249
255
 
250
256
  key = "#{device},#{mount}"
@@ -747,7 +753,7 @@ Ohai.plugin(:Filesystem) do
747
753
 
748
754
  collect_data(:windows) do
749
755
  require "wmi-lite/wmi"
750
- require "ohai/mash"
756
+ require_relative "../mash"
751
757
 
752
758
  fs = merge_info(logical_info, encryptable_info)
753
759
 
@@ -4,7 +4,7 @@
4
4
  # Author:: Bryan McLellan (<btm@loftninjas.org>)
5
5
  # Author:: Claire McQuin (<claire@chef.io>)
6
6
  # Author:: James Gartrell (<jgartrel@gmail.com>)
7
- # Copyright:: Copyright (c) 2008-2018 Chef Software, Inc.
7
+ # Copyright:: Copyright (c) Chef Software, Inc.
8
8
  # Copyright:: Copyright (c) 2009 Bryan McLellan
9
9
  # License:: Apache License, Version 2.0
10
10
  #
@@ -137,11 +137,12 @@ Ohai.plugin(:Kernel) do
137
137
  end
138
138
  end
139
139
 
140
- # see if a WMI name is blacklisted so we can avoid writing out
141
- # useless data to ohai
140
+ # see if a WMI name is in the blocked list so we can avoid writing
141
+ # out useless data to ohai
142
+ #
142
143
  # @param [String] name the wmi name to check
143
- # @return [Boolean] is the wmi name blacklisted
144
- def blacklisted_wmi_name?(name)
144
+ # @return [Boolean] is the wmi name in the blocked list
145
+ def blocked_wmi_name?(name)
145
146
  [
146
147
  "creation_class_name", # this is just the wmi name
147
148
  "cs_creation_class_name", # this is just the wmi name
@@ -262,7 +263,7 @@ Ohai.plugin(:Kernel) do
262
263
  host = wmi.first_of("Win32_OperatingSystem")
263
264
  kernel[:os_info] = Mash.new
264
265
  host.wmi_ole_object.properties_.each do |p|
265
- next if blacklisted_wmi_name?(p.name.wmi_underscore)
266
+ next if blocked_wmi_name?(p.name.wmi_underscore)
266
267
 
267
268
  kernel[:os_info][p.name.wmi_underscore.to_sym] = host[p.name.downcase]
268
269
  end
@@ -277,7 +278,7 @@ Ohai.plugin(:Kernel) do
277
278
  kernel[:cs_info] = Mash.new
278
279
  host = wmi.first_of("Win32_ComputerSystem")
279
280
  host.wmi_ole_object.properties_.each do |p|
280
- next if blacklisted_wmi_name?(p.name.wmi_underscore)
281
+ next if blocked_wmi_name?(p.name.wmi_underscore)
281
282
 
282
283
  kernel[:cs_info][p.name.wmi_underscore.to_sym] = host[p.name.downcase]
283
284
  end
@@ -118,8 +118,8 @@ Ohai.plugin(:Virtualization) do
118
118
 
119
119
  # parse dmi to discover various virtualization guests
120
120
  # we do this *after* the kvm detection so that OpenStack isn't detected as KVM
121
- logger.trace("Looking up DMI data manufacturer: '#{get_attribute(:dmi, :system, :manufacturer)}' product: '#{get_attribute(:dmi, :system, :product)}' version: '#{get_attribute(:dmi, :system, :version)}'")
122
- guest = guest_from_dmi_data(get_attribute(:dmi, :system, :manufacturer), get_attribute(:dmi, :system, :product), get_attribute(:dmi, :system, :version))
121
+ logger.trace("Looking up DMI data manufacturer: '#{get_attribute(:dmi, :system, :manufacturer)}' product_name: '#{get_attribute(:dmi, :system, :product_name)}' version: '#{get_attribute(:dmi, :system, :version)}'")
122
+ guest = guest_from_dmi_data(get_attribute(:dmi, :system, :manufacturer), get_attribute(:dmi, :system, :product_name), get_attribute(:dmi, :system, :version))
123
123
  if guest
124
124
  logger.trace("Plugin Virtualization: DMI data indicates #{guest} guest")
125
125
  virtualization[:system] = guest
@@ -51,11 +51,11 @@ Ohai.plugin(:Openstack) do
51
51
  # dream host doesn't support windows so bail early if we're on windows
52
52
  return "openstack" if RUBY_PLATFORM =~ /mswin|mingw32|windows/
53
53
 
54
- if Etc.getpwnam("dhc-user")
54
+ if Etc::Passwd.entries.map(&:name).include?("dhc-user")
55
55
  "dreamhost"
56
+ else
57
+ "openstack"
56
58
  end
57
- rescue ArgumentError # getpwnam raises ArgumentError if the user is not found
58
- "openstack"
59
59
  end
60
60
 
61
61
  collect_data do
@@ -22,10 +22,12 @@ Ohai.plugin(:ShardSeed) do
22
22
 
23
23
  def get_dmi_property(dmi, thing)
24
24
  %w{system base_board chassis}.each do |section|
25
- unless dmi[section][thing].strip.empty?
25
+ if dmi[section] && dmi[section][thing] && !dmi[section][thing].strip.empty?
26
26
  return dmi[section][thing]
27
27
  end
28
28
  end
29
+ Ohai::Log.error("shard_seed: Failed to get dmi property #{thing}: is dmidecode installed?")
30
+ raise "Failed to generate shard_seed"
29
31
  end
30
32
 
31
33
  def default_sources
@@ -77,11 +79,16 @@ Ohai.plugin(:ShardSeed) do
77
79
  yield(src)
78
80
  end
79
81
  end
82
+ if data.empty?
83
+ Ohai::Log.error("shard_seed: Unable to generate seed! Either ensure 'dmidecode' is installed, or use 'Ohai.config[:plugin][:shard_seed][:sources]' to set different sources.")
84
+ raise "Failed to generate shard_seed"
85
+ end
80
86
  shard_seed digest_algorithm.hexdigest(data)[0...7].to_i(16)
81
87
  end
82
88
 
83
89
  collect_data do
84
90
  create_seed do |src|
91
+ Ohai::Log.error("shard_seed: No such source #{src}")
85
92
  raise "No such shard_seed source: #{src}"
86
93
  end
87
94
  end
@@ -99,6 +106,7 @@ Ohai.plugin(:ShardSeed) do
99
106
  when :uuid
100
107
  wmi.first_of("Win32_ComputerSystemProduct")["UUID"]
101
108
  else
109
+ Ohai::Log.error("shard_seed: No such source #{src}")
102
110
  raise "No such shard_seed source: #{src}"
103
111
  end
104
112
  end
@@ -112,6 +120,7 @@ Ohai.plugin(:ShardSeed) do
112
120
  when :uuid
113
121
  hardware["platform_UUID"]
114
122
  else
123
+ Ohai::Log.error("shard_seed: No such source #{src}")
115
124
  raise "No such shard_seed source: #{src}"
116
125
  end
117
126
  end
@@ -125,6 +134,7 @@ Ohai.plugin(:ShardSeed) do
125
134
  when :uuid
126
135
  get_dmi_property(dmi, :uuid)
127
136
  else
137
+ Ohai::Log.error("shard_seed: No such source #{src}")
128
138
  raise "No such shard_seed source: #{src}"
129
139
  end
130
140
  end
@@ -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") && (dmi.keys.length > 1)
27
+ if dmi.is_a?(Mash) && dmi.keys.length > 1
28
28
  logger.trace("Plugin DMI: skipping smbios output, since DMI information has already been provided")
29
29
  return
30
30
  end
@@ -177,7 +177,7 @@ Ohai.plugin(:DMI) do
177
177
  next
178
178
  end
179
179
  # overwrite "raw" value with a new Mash
180
- dmi[dmi_record[:type]][:all_records][dmi_record[:position]][field] = Mash.new unless dmi[dmi_record[:type]][:all_records][dmi_record[:position]][field].class.to_s == "Mash"
180
+ dmi[dmi_record[:type]][:all_records][dmi_record[:position]][field] = Mash.new unless dmi[dmi_record[:type]][:all_records][dmi_record[:position]][field].is_a?(Mash)
181
181
  dmi[dmi_record[:type]][:all_records][dmi_record[:position]][field][extended_data[1]] = extended_data[2]
182
182
 
183
183
  else
@@ -18,5 +18,5 @@
18
18
 
19
19
  module Ohai
20
20
  OHAI_ROOT = File.expand_path(File.dirname(__FILE__))
21
- VERSION = "15.6.3".freeze
21
+ VERSION = "15.12.0".freeze
22
22
  end
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: 15.6.3
4
+ version: 15.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Jacob
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-12-06 00:00:00.000000000 Z
11
+ date: 2020-06-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: systemu