ohai 17.6.0 → 17.7.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 98c016d2839114bfe15deee549cf97ba8ff627ab2931207a105a42a154746cc7
4
- data.tar.gz: '06687f5ca824b9489e3140b19415ae8c99e1afefc053d9c4519b4d7af9d85cf8'
3
+ metadata.gz: 19b09efb3e8a7318b9401b9faf1fb17a472544ec5c7f45e7be090bcaafac9d93
4
+ data.tar.gz: d6deeb673906082bda7ab8ac7b4b1b5fb8dc41c22720ab4f4d47dfa994479be6
5
5
  SHA512:
6
- metadata.gz: 7a8b2890b42b09e33d01a67ff589f587029d052a7a55a2ba09d1f2dd482afce275201e06cf968492f0645b8273f9b69890c7f082af878883ee66bc615828a96a
7
- data.tar.gz: 3de0474524e3e9825e74f645630fc9e721f2ddbecd2a16bb337a21a02fa25d25cab469a5a810e8e2461ed137aab78f03abde064887993f64c784399b0ab8bdd9
6
+ metadata.gz: a8aec83f05fb402a2cc08efa9ce6d6fc81a0c2133bc57f60c9cbedff90236812e30e65373b5bb4813590ea2c7d5ae6c763caa58bbf56ef10c4ac5362df1dbc59
7
+ data.tar.gz: 948e93dddd2a283f43350795e15b46d83fe31db12d9f988bbe594882295fb7c57e576bc18be0a4db1d22002a177a6dddcce49f041dbc24cd777c75b59e62bce4
@@ -23,7 +23,7 @@ module Ohai
23
23
  module ConstantHelper
24
24
 
25
25
  def remove_constants
26
- new_object_constants = Object.constants - @object_pristine.constants
26
+ new_object_constants = Object.constants - @object_pristine.constants - [ :SortedSet ]
27
27
  new_object_constants.each do |constant|
28
28
  Object.send(:remove_const, constant) unless Object.const_get(constant).is_a?(Module)
29
29
  end
@@ -32,6 +32,24 @@ module Ohai
32
32
  [2, 4, 6].each { |n| dec = dec + "." + netmask[n..n + 1].to_i(16).to_s(10) }
33
33
  dec
34
34
  end
35
+
36
+ # This does a forward and reverse lookup on the hostname to return what should be
37
+ # the FQDN for the host determined by name lookup (generally DNS)
38
+ #
39
+ def canonicalize_hostname(hostname)
40
+ Addrinfo.getaddrinfo(hostname, nil).first.getnameinfo.first
41
+ end
42
+
43
+ def canonicalize_hostname_with_retries(hostname)
44
+ retries = 3
45
+ begin
46
+ canonicalize_hostname(hostname)
47
+ rescue
48
+ retries -= 1
49
+ retry if retries > 0
50
+ nil
51
+ end
52
+ end
35
53
  end
36
54
  end
37
55
  end
data/lib/ohai/mixin/os.rb CHANGED
@@ -82,13 +82,13 @@ module Ohai
82
82
  else
83
83
  # now we have something like an IPMI console that isn't Unix-like or Windows, presumably cannot run ruby, and
84
84
  # so we just trust the train O/S information.
85
- transport_connection.os
85
+ transport_connection.os.name
86
86
  end
87
87
  end
88
88
 
89
89
  # @api private
90
90
  def nonruby_target?
91
- transport_connection && !transport_connection.os.unix? && !transport_connection.os.windows
91
+ transport_connection && !transport_connection.os.unix? && !transport_connection.os.windows?
92
92
  end
93
93
 
94
94
  # @api private
@@ -499,7 +499,7 @@ Ohai.plugin(:CPU) do
499
499
 
500
500
  cpu[:total] = shell_out("pmcycles -m").stdout.lines.length
501
501
 
502
- # The below is only relevent on an LPAR
502
+ # The below is only relevant on an LPAR
503
503
  if shell_out("uname -W").stdout.strip == "0"
504
504
 
505
505
  # At least one CPU will be available, but we'll wait to increment this later.
@@ -26,7 +26,11 @@
26
26
  # limitations under the License.
27
27
  #
28
28
 
29
+ require_relative "../mixin/network_helper"
30
+
29
31
  Ohai.plugin(:Hostname) do
32
+ include Ohai::Mixin::NetworkHelper
33
+
30
34
  provides "domain", "hostname", "fqdn", "machinename"
31
35
 
32
36
  # hostname : short hostname
@@ -42,38 +46,8 @@ Ohai.plugin(:Hostname) do
42
46
  end
43
47
 
44
48
  # forward and reverse lookup to canonicalize FQDN (hostname -f equivalent)
45
- # this is ipv6-safe, works on ruby 1.8.7+
46
49
  def resolve_fqdn
47
- require "socket" unless defined?(Socket)
48
- require "ipaddr" unless defined?(IPAddr)
49
-
50
- hostname = from_cmd("hostname")
51
- begin
52
- addrinfo = Socket.getaddrinfo(hostname, nil).first
53
- rescue SocketError
54
- # In the event that we got an exception from Socket, it's possible
55
- # that it will work if we restrict it to IPv4 only either because of
56
- # IPv6 misconfiguration or other bugs.
57
- #
58
- # Specifically it's worth noting that on macOS, getaddrinfo() will choke
59
- # if it gets back a link-local address (say if you have 'fe80::1 myhost'
60
- # in /etc/hosts). This will raise:
61
- # SocketError (getnameinfo: Non-recoverable failure in name resolution)
62
- #
63
- # But general misconfiguration could cause similar issues, so attempt to
64
- # fall back to v4-only
65
- begin
66
- addrinfo = Socket.getaddrinfo(hostname, nil, :INET).first
67
- rescue
68
- # and if *that* fails, then try v6-only, in case we're in a v6-only
69
- # environment with v4 config issues
70
- addrinfo = Socket.getaddrinfo(hostname, nil, :INET6).first
71
- end
72
- end
73
- iaddr = IPAddr.new(addrinfo[3])
74
- Socket.gethostbyaddr(iaddr.hton)[0]
75
- rescue
76
- nil
50
+ canonicalize_hostname_with_retries(from_cmd("hostname"))
77
51
  end
78
52
 
79
53
  def collect_domain
@@ -119,58 +93,21 @@ Ohai.plugin(:Hostname) do
119
93
  collect_data(:darwin) do
120
94
  hostname from_cmd("hostname -s")
121
95
  machinename from_cmd("hostname")
122
- begin
123
- our_fqdn = resolve_fqdn
124
- # Sometimes... very rarely, but sometimes, 'hostname --fqdn' falsely
125
- # returns a blank string. WTF.
126
- if our_fqdn.nil? || our_fqdn.empty?
127
- logger.trace("Plugin Hostname: hostname returned an empty string, retrying once.")
128
- our_fqdn = resolve_fqdn
129
- end
130
-
131
- if our_fqdn.nil? || our_fqdn.empty?
132
- logger.trace("Plugin Hostname: hostname returned an empty string twice and will" +
133
- "not be set.")
134
- else
135
- fqdn our_fqdn
136
- end
137
- rescue
138
- logger.trace(
139
- "Plugin Hostname: hostname returned an error, probably no domain set"
140
- )
141
- end
96
+ fqdn resolve_fqdn
142
97
  domain collect_domain
143
98
  end
144
99
 
145
100
  collect_data(:freebsd) do
146
101
  hostname from_cmd("hostname -s")
147
102
  machinename from_cmd("hostname")
148
- fqdn from_cmd("hostname -f")
103
+ fqdn resolve_fqdn
149
104
  collect_domain
150
105
  end
151
106
 
152
107
  collect_data(:linux) do
153
108
  hostname from_cmd("hostname -s")
154
109
  machinename from_cmd("hostname")
155
- begin
156
- our_fqdn = from_cmd("hostname --fqdn")
157
- # Sometimes... very rarely, but sometimes, 'hostname --fqdn' falsely
158
- # returns a blank string. WTF.
159
- if our_fqdn.nil? || our_fqdn.empty?
160
- logger.trace("Plugin Hostname: hostname --fqdn returned an empty string, retrying " +
161
- "once.")
162
- our_fqdn = from_cmd("hostname --fqdn")
163
- end
164
-
165
- if our_fqdn.nil? || our_fqdn.empty?
166
- logger.trace("Plugin Hostname: hostname --fqdn returned an empty string twice and " +
167
- "will not be set.")
168
- else
169
- fqdn our_fqdn
170
- end
171
- rescue
172
- logger.trace("Plugin Hostname: hostname --fqdn returned an error, probably no domain set")
173
- end
110
+ fqdn resolve_fqdn
174
111
  domain collect_domain
175
112
  end
176
113
 
@@ -190,22 +127,7 @@ Ohai.plugin(:Hostname) do
190
127
 
191
128
  hostname host["dnshostname"].to_s
192
129
  machinename host["name"].to_s
193
-
194
- info = Socket.gethostbyname(Socket.gethostname)
195
- if /.+?\.(.*)/.match?(info.first)
196
- fqdn info.first
197
- else
198
- # host is not in dns. optionally use:
199
- # C:\WINDOWS\system32\drivers\etc\hosts
200
- info[3..info.length].reverse_each do |addr|
201
- hostent = Socket.gethostbyaddr(addr)
202
- if /.+?\.(.*)/.match?(hostent.first)
203
- fqdn hostent.first
204
- break
205
- end
206
- end
207
- fqdn info.first unless fqdn
208
- end
130
+ fqdn canonicalize_hostname_with_retries(Socket.gethostname)
209
131
  domain collect_domain
210
132
  end
211
133
  end
@@ -40,6 +40,12 @@ Ohai.plugin(:OS) do
40
40
 
41
41
  collect_data(:target) do
42
42
  os collect_os
43
+ os_version "unknown"
44
+ end
45
+
46
+ collect_data(:api) do
47
+ os collect_os
48
+ os_version "unknown"
43
49
  end
44
50
 
45
51
  collect_data do
@@ -134,9 +134,9 @@ Ohai.plugin(:Packages) do
134
134
  require "win32/registry" unless defined?(Win32::Registry)
135
135
  packages Mash.new
136
136
  collect_programs_from_registry_key(Win32::Registry::HKEY_LOCAL_MACHINE, 'Software\Microsoft\Windows\CurrentVersion\Uninstall')
137
- collect_programs_from_registry_key(Win32::Registry::HKEY_CURRENT_USER, 'Software\Microsoft\Windows\CurrentVersion\Uninstall')
137
+ # on 64 bit systems, 32 bit programs are stored here moved before HKEY_CURRENT_USER otherwise it is not collected (impacts both ohai 16 & 17)
138
138
  collect_programs_from_registry_key(Win32::Registry::HKEY_LOCAL_MACHINE, 'Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall')
139
- # on 64 bit systems, 32 bit programs are stored here
139
+ collect_programs_from_registry_key(Win32::Registry::HKEY_CURRENT_USER, 'Software\Microsoft\Windows\CurrentVersion\Uninstall') rescue nil
140
140
  end
141
141
 
142
142
  collect_data(:aix) do
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.6.0"
22
+ VERSION = "17.7.5"
23
23
  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: 17.6.0
4
+ version: 17.7.5
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-09-30 00:00:00.000000000 Z
11
+ date: 2021-10-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chef-config