ohai 16.5.4 → 16.8.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (158) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +7 -8
  3. data/bin/ohai +1 -0
  4. data/lib/ohai.rb +1 -0
  5. data/lib/ohai/application.rb +40 -0
  6. data/lib/ohai/common/dmi.rb +8 -3
  7. data/lib/ohai/config.rb +1 -0
  8. data/lib/ohai/dsl.rb +1 -0
  9. data/lib/ohai/dsl/plugin.rb +9 -1
  10. data/lib/ohai/dsl/plugin/versionvii.rb +28 -17
  11. data/lib/ohai/exception.rb +1 -0
  12. data/lib/ohai/hints.rb +1 -0
  13. data/lib/ohai/log.rb +1 -0
  14. data/lib/ohai/mash.rb +1 -0
  15. data/lib/ohai/mixin/azure_metadata.rb +4 -3
  16. data/lib/ohai/mixin/chef_utils_wiring.rb +14 -1
  17. data/lib/ohai/mixin/command.rb +1 -0
  18. data/lib/ohai/mixin/constant_helper.rb +1 -0
  19. data/lib/ohai/mixin/dmi_decode.rb +1 -0
  20. data/lib/ohai/mixin/do_metadata.rb +3 -2
  21. data/lib/ohai/mixin/ec2_metadata.rb +10 -9
  22. data/lib/ohai/mixin/gce_metadata.rb +4 -3
  23. data/lib/ohai/mixin/http_helper.rb +1 -0
  24. data/lib/ohai/mixin/network_helper.rb +1 -0
  25. data/lib/ohai/mixin/os.rb +67 -1
  26. data/lib/ohai/mixin/scaleway_metadata.rb +3 -2
  27. data/lib/ohai/mixin/seconds_to_human.rb +1 -0
  28. data/lib/ohai/mixin/shell_out.rb +1 -0
  29. data/lib/ohai/mixin/softlayer_metadata.rb +2 -1
  30. data/lib/ohai/mixin/string.rb +1 -0
  31. data/lib/ohai/mixin/train_helpers.rb +36 -0
  32. data/lib/ohai/mixin/which.rb +1 -0
  33. data/lib/ohai/plugin_config.rb +1 -0
  34. data/lib/ohai/plugins/aix/kernel.rb +7 -4
  35. data/lib/ohai/plugins/aix/memory.rb +4 -3
  36. data/lib/ohai/plugins/aix/network.rb +51 -58
  37. data/lib/ohai/plugins/aix/platform.rb +3 -2
  38. data/lib/ohai/plugins/aix/uptime.rb +3 -2
  39. data/lib/ohai/plugins/aix/virtualization.rb +6 -6
  40. data/lib/ohai/plugins/azure.rb +25 -4
  41. data/lib/ohai/plugins/bsd/virtualization.rb +3 -2
  42. data/lib/ohai/plugins/c.rb +4 -3
  43. data/lib/ohai/plugins/chef.rb +2 -1
  44. data/lib/ohai/plugins/cloud.rb +2 -1
  45. data/lib/ohai/plugins/command.rb +1 -0
  46. data/lib/ohai/plugins/cpu.rb +31 -32
  47. data/lib/ohai/plugins/darwin/hardware.rb +1 -0
  48. data/lib/ohai/plugins/darwin/memory.rb +2 -3
  49. data/lib/ohai/plugins/darwin/network.rb +8 -9
  50. data/lib/ohai/plugins/darwin/platform.rb +1 -0
  51. data/lib/ohai/plugins/darwin/virtualization.rb +2 -1
  52. data/lib/ohai/plugins/digital_ocean.rb +3 -1
  53. data/lib/ohai/plugins/dmi.rb +6 -5
  54. data/lib/ohai/plugins/docker.rb +2 -1
  55. data/lib/ohai/plugins/dragonflybsd/memory.rb +9 -8
  56. data/lib/ohai/plugins/dragonflybsd/network.rb +1 -0
  57. data/lib/ohai/plugins/dragonflybsd/platform.rb +3 -2
  58. data/lib/ohai/plugins/ec2.rb +14 -7
  59. data/lib/ohai/plugins/elixir.rb +1 -1
  60. data/lib/ohai/plugins/erlang.rb +1 -0
  61. data/lib/ohai/plugins/eucalyptus.rb +4 -1
  62. data/lib/ohai/plugins/filesystem.rb +4 -4
  63. data/lib/ohai/plugins/fips.rb +1 -0
  64. data/lib/ohai/plugins/freebsd/memory.rb +9 -8
  65. data/lib/ohai/plugins/freebsd/network.rb +1 -0
  66. data/lib/ohai/plugins/freebsd/platform.rb +3 -2
  67. data/lib/ohai/plugins/gce.rb +3 -2
  68. data/lib/ohai/plugins/go.rb +1 -1
  69. data/lib/ohai/plugins/groovy.rb +1 -1
  70. data/lib/ohai/plugins/grub2.rb +40 -0
  71. data/lib/ohai/plugins/haskell.rb +1 -0
  72. data/lib/ohai/plugins/hostname.rb +2 -2
  73. data/lib/ohai/plugins/init_package.rb +2 -1
  74. data/lib/ohai/plugins/java.rb +1 -0
  75. data/lib/ohai/plugins/kernel.rb +14 -11
  76. data/lib/ohai/plugins/keys.rb +1 -0
  77. data/lib/ohai/plugins/languages.rb +1 -0
  78. data/lib/ohai/plugins/libvirt.rb +4 -3
  79. data/lib/ohai/plugins/linode.rb +22 -14
  80. data/lib/ohai/plugins/linux/block_device.rb +9 -8
  81. data/lib/ohai/plugins/linux/hostnamectl.rb +3 -2
  82. data/lib/ohai/plugins/linux/interrupts.rb +4 -3
  83. data/lib/ohai/plugins/linux/ipc.rb +2 -1
  84. data/lib/ohai/plugins/linux/lsb.rb +7 -20
  85. data/lib/ohai/plugins/linux/lspci.rb +1 -1
  86. data/lib/ohai/plugins/linux/machineid.rb +5 -4
  87. data/lib/ohai/plugins/linux/mdadm.rb +3 -2
  88. data/lib/ohai/plugins/linux/memory.rb +38 -37
  89. data/lib/ohai/plugins/linux/network.rb +7 -6
  90. data/lib/ohai/plugins/linux/platform.rb +31 -30
  91. data/lib/ohai/plugins/linux/selinux.rb +1 -0
  92. data/lib/ohai/plugins/linux/sessions.rb +1 -0
  93. data/lib/ohai/plugins/linux/sysctl.rb +1 -0
  94. data/lib/ohai/plugins/linux/systemd_paths.rb +1 -0
  95. data/lib/ohai/plugins/linux/virtualization.rb +24 -23
  96. data/lib/ohai/plugins/lua.rb +1 -1
  97. data/lib/ohai/plugins/mono.rb +1 -1
  98. data/lib/ohai/plugins/netbsd/memory.rb +1 -0
  99. data/lib/ohai/plugins/netbsd/network.rb +1 -0
  100. data/lib/ohai/plugins/netbsd/platform.rb +3 -2
  101. data/lib/ohai/plugins/network.rb +2 -1
  102. data/lib/ohai/plugins/nodejs.rb +1 -1
  103. data/lib/ohai/plugins/ohai.rb +1 -0
  104. data/lib/ohai/plugins/ohai_time.rb +2 -1
  105. data/lib/ohai/plugins/openbsd/memory.rb +1 -0
  106. data/lib/ohai/plugins/openbsd/network.rb +1 -0
  107. data/lib/ohai/plugins/openbsd/platform.rb +3 -2
  108. data/lib/ohai/plugins/openstack.rb +1 -0
  109. data/lib/ohai/plugins/os.rb +6 -1
  110. data/lib/ohai/plugins/packages.rb +2 -1
  111. data/lib/ohai/plugins/passwd.rb +58 -1
  112. data/lib/ohai/plugins/perl.rb +1 -1
  113. data/lib/ohai/plugins/php.rb +1 -1
  114. data/lib/ohai/plugins/platform.rb +1 -0
  115. data/lib/ohai/plugins/powershell.rb +1 -1
  116. data/lib/ohai/plugins/ps.rb +1 -0
  117. data/lib/ohai/plugins/python.rb +1 -1
  118. data/lib/ohai/plugins/rackspace.rb +6 -5
  119. data/lib/ohai/plugins/root_group.rb +1 -0
  120. data/lib/ohai/plugins/ruby.rb +3 -2
  121. data/lib/ohai/plugins/rust.rb +1 -1
  122. data/lib/ohai/plugins/scala.rb +1 -0
  123. data/lib/ohai/plugins/scaleway.rb +3 -2
  124. data/lib/ohai/plugins/scsi.rb +1 -1
  125. data/lib/ohai/plugins/shard.rb +1 -1
  126. data/lib/ohai/plugins/shells.rb +3 -2
  127. data/lib/ohai/plugins/softlayer.rb +1 -0
  128. data/lib/ohai/plugins/solaris2/dmi.rb +2 -1
  129. data/lib/ohai/plugins/solaris2/memory.rb +1 -0
  130. data/lib/ohai/plugins/solaris2/network.rb +2 -1
  131. data/lib/ohai/plugins/solaris2/platform.rb +8 -14
  132. data/lib/ohai/plugins/solaris2/virtualization.rb +4 -4
  133. data/lib/ohai/plugins/ssh_host_key.rb +13 -12
  134. data/lib/ohai/plugins/sysconf.rb +1 -0
  135. data/lib/ohai/plugins/timezone.rb +1 -0
  136. data/lib/ohai/plugins/train.rb +35 -0
  137. data/lib/ohai/plugins/uptime.rb +2 -1
  138. data/lib/ohai/plugins/virtualbox.rb +2 -1
  139. data/lib/ohai/plugins/vmware.rb +3 -3
  140. data/lib/ohai/plugins/windows/dmi.rb +1 -0
  141. data/lib/ohai/plugins/windows/drivers.rb +1 -0
  142. data/lib/ohai/plugins/windows/memory.rb +1 -0
  143. data/lib/ohai/plugins/windows/network.rb +2 -1
  144. data/lib/ohai/plugins/windows/platform.rb +1 -0
  145. data/lib/ohai/plugins/windows/system_enclosure.rb +1 -0
  146. data/lib/ohai/plugins/windows/virtualization.rb +1 -0
  147. data/lib/ohai/plugins/zpools.rb +5 -3
  148. data/lib/ohai/provides_map.rb +1 -0
  149. data/lib/ohai/runner.rb +7 -4
  150. data/lib/ohai/system.rb +33 -4
  151. data/lib/ohai/train_transport.rb +29 -0
  152. data/lib/ohai/util/file_helper.rb +1 -0
  153. data/lib/ohai/util/ip_helper.rb +2 -1
  154. data/lib/ohai/util/win32.rb +1 -0
  155. data/lib/ohai/version.rb +2 -1
  156. data/ohai.gemspec +3 -1
  157. metadata +21 -4
  158. data/lib/ohai/plugins/joyent.rb +0 -77
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  #
2
3
  # Author:: Adam Jacob (<adam@chef.io>)
3
4
  # Copyright:: Copyright (c) Chef Software Inc.
@@ -43,9 +44,9 @@ Ohai.plugin(:Platform) do
43
44
  # @returns [Hash] the file parsed into a Hash or nil
44
45
  #
45
46
  def read_os_release_info(file)
46
- return nil unless File.exist?(file)
47
+ return nil unless file_exist?(file)
47
48
 
48
- File.read(file).split.inject({}) do |map, line|
49
+ file_read(file).split.inject({}) do |map, line|
49
50
  key, value = line.split("=")
50
51
  map[key] = value.gsub(/\A"|"\Z/, "") if value
51
52
  map
@@ -64,7 +65,7 @@ Ohai.plugin(:Platform) do
64
65
  begin
65
66
  os_release_info = read_os_release_info("/etc/os-release")
66
67
  cisco_release_info = os_release_info["CISCO_RELEASE_INFO"] if os_release_info
67
- if cisco_release_info && File.exist?(cisco_release_info)
68
+ if cisco_release_info && file_exist?(cisco_release_info)
68
69
  os_release_info.merge!(read_os_release_info(cisco_release_info))
69
70
  end
70
71
  os_release_info
@@ -77,7 +78,7 @@ Ohai.plugin(:Platform) do
77
78
  # @returns [Boolean] if we are Cisco according to /etc/os-release
78
79
  #
79
80
  def os_release_file_is_cisco?
80
- File.exist?("/etc/os-release") && os_release_info["CISCO_RELEASE_INFO"]
81
+ file_exist?("/etc/os-release") && os_release_info["CISCO_RELEASE_INFO"]
81
82
  end
82
83
 
83
84
  #
@@ -88,7 +89,7 @@ Ohai.plugin(:Platform) do
88
89
  # @returns [String] bigip Linux version from /etc/f5-release
89
90
  #
90
91
  def bigip_version
91
- release_contents = File.read("/etc/f5-release")
92
+ release_contents = file_read("/etc/f5-release")
92
93
  release_contents.match(/BIG-IP release (\S*)/)[1] # http://rubular.com/r/O8nlrBVqSb
93
94
  rescue NoMethodError, Errno::ENOENT, Errno::EACCES # rescue regex failure, file missing, or permission denied
94
95
  logger.warn("Detected F5 Big-IP, but /etc/f5-release could not be parsed to determine platform_version")
@@ -132,7 +133,7 @@ Ohai.plugin(:Platform) do
132
133
  #
133
134
  def platform_family_from_platform(plat)
134
135
  case plat
135
- when /debian/, /ubuntu/, /linuxmint/, /raspbian/, /cumulus/, /kali/
136
+ when /debian/, /ubuntu/, /linuxmint/, /raspbian/, /cumulus/, /kali/, /pop/
136
137
  # apt-get+dpkg almost certainly goes here
137
138
  "debian"
138
139
  when /oracle/, /centos/, /redhat/, /scientific/, /enterpriseenterprise/, /xcp/, /xenserver/, /cloudlinux/, /ibm_powerkvm/, /parallels/, /nexus_centos/, /clearos/, /bigip/ # Note that 'enterpriseenterprise' is oracle's LSB "distributor ID"
@@ -178,18 +179,18 @@ Ohai.plugin(:Platform) do
178
179
  # @deprecated
179
180
  def legacy_platform_detection
180
181
  # platform [ and platform_version ? ] should be lower case to avoid dealing with RedHat/Redhat/redhat matching
181
- if File.exist?("/etc/oracle-release")
182
- contents = File.read("/etc/oracle-release").chomp
182
+ if file_exist?("/etc/oracle-release")
183
+ contents = file_read("/etc/oracle-release").chomp
183
184
  platform "oracle"
184
185
  platform_version get_redhatish_version(contents)
185
- elsif File.exist?("/etc/enterprise-release")
186
- contents = File.read("/etc/enterprise-release").chomp
186
+ elsif file_exist?("/etc/enterprise-release")
187
+ contents = file_read("/etc/enterprise-release").chomp
187
188
  platform "oracle"
188
189
  platform_version get_redhatish_version(contents)
189
- elsif File.exist?("/etc/f5-release")
190
+ elsif file_exist?("/etc/f5-release")
190
191
  platform "bigip"
191
192
  platform_version bigip_version
192
- elsif File.exist?("/etc/debian_version")
193
+ elsif file_exist?("/etc/debian_version")
193
194
  # Ubuntu and Debian both have /etc/debian_version
194
195
  # Ubuntu should always have a working lsb, debian does not by default
195
196
  if /Ubuntu/i.match?(lsb[:id])
@@ -197,25 +198,25 @@ Ohai.plugin(:Platform) do
197
198
  platform_version lsb[:release]
198
199
  else
199
200
  platform "debian"
200
- platform_version File.read("/etc/debian_version").chomp
201
+ platform_version file_read("/etc/debian_version").chomp
201
202
  end
202
- elsif File.exist?("/etc/parallels-release")
203
- contents = File.read("/etc/parallels-release").chomp
203
+ elsif file_exist?("/etc/parallels-release")
204
+ contents = file_read("/etc/parallels-release").chomp
204
205
  platform get_redhatish_platform(contents)
205
206
  platform_version contents.match(/(\d\.\d\.\d)/)[0]
206
- elsif File.exist?("/etc/Eos-release")
207
+ elsif file_exist?("/etc/Eos-release")
207
208
  platform "arista_eos"
208
- platform_version File.read("/etc/Eos-release").strip.split[-1]
209
- elsif File.exist?("/etc/redhat-release")
210
- contents = File.read("/etc/redhat-release").chomp
209
+ platform_version file_read("/etc/Eos-release").strip.split[-1]
210
+ elsif file_exist?("/etc/redhat-release")
211
+ contents = file_read("/etc/redhat-release").chomp
211
212
  platform get_redhatish_platform(contents)
212
213
  platform_version get_redhatish_version(contents)
213
- elsif File.exist?("/etc/system-release")
214
- contents = File.read("/etc/system-release").chomp
214
+ elsif file_exist?("/etc/system-release")
215
+ contents = file_read("/etc/system-release").chomp
215
216
  platform get_redhatish_platform(contents)
216
217
  platform_version get_redhatish_version(contents)
217
- elsif File.exist?("/etc/SuSE-release")
218
- suse_release = File.read("/etc/SuSE-release")
218
+ elsif file_exist?("/etc/SuSE-release")
219
+ suse_release = file_read("/etc/SuSE-release")
219
220
  suse_version = suse_release.scan(/VERSION = (\d+)\nPATCHLEVEL = (\d+)/).flatten.join(".")
220
221
  suse_version = suse_release[/VERSION = ([\d\.]{2,})/, 1] if suse_version == ""
221
222
  platform_version suse_version
@@ -243,16 +244,16 @@ Ohai.plugin(:Platform) do
243
244
  end
244
245
 
245
246
  platform_version os_release_info["VERSION"]
246
- elsif File.exist?("/etc/slackware-version")
247
+ elsif file_exist?("/etc/slackware-version")
247
248
  platform "slackware"
248
- platform_version File.read("/etc/slackware-version").scan(/(\d+|\.+)/).join
249
- elsif File.exist?("/etc/exherbo-release")
249
+ platform_version file_read("/etc/slackware-version").scan(/(\d+|\.+)/).join
250
+ elsif file_exist?("/etc/exherbo-release")
250
251
  platform "exherbo"
251
252
  # no way to determine platform_version in a rolling release distribution
252
253
  # kernel release will be used - ex. 3.13
253
254
  platform_version shell_out("/bin/uname -r").stdout.strip
254
- elsif File.exist?("/usr/lib/os-release")
255
- contents = File.read("/usr/lib/os-release")
255
+ elsif file_exist?("/usr/lib/os-release")
256
+ contents = file_read("/usr/lib/os-release")
256
257
  if /clear-linux-os/.match?(contents) # Clear Linux https://clearlinux.org/
257
258
  platform "clearlinux"
258
259
  platform_version contents[/VERSION_ID=(\d+)/, 1]
@@ -285,14 +286,14 @@ Ohai.plugin(:Platform) do
285
286
  def determine_os_version
286
287
  # centos only includes the major version in os-release for some reason
287
288
  if os_release_info["ID"] == "centos"
288
- get_redhatish_version(File.read("/etc/redhat-release").chomp)
289
+ get_redhatish_version(file_read("/etc/redhat-release").chomp)
289
290
  else
290
291
  os_release_info["VERSION_ID"] || shell_out("/bin/uname -r").stdout.strip
291
292
  end
292
293
  end
293
294
 
294
295
  collect_data(:linux) do
295
- if ::File.exist?("/etc/os-release")
296
+ if file_exist?("/etc/os-release")
296
297
  logger.trace("Plugin platform: Using /etc/os-release for platform detection")
297
298
 
298
299
  # fixup os-release names to ohai platform names
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  #
2
3
  # Author:: Davide Cavalca <dcavalca@fb.com>
3
4
  # Copyright:: Copyright (c) 2020 Facebook
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  #
2
3
  # Author:: Davide Cavalca <dcavalca@fb.com>
3
4
  # Copyright:: Copyright (c) 2016 Facebook
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  #
2
3
  # Author:: Joshua Miller <joshmiller@fb.com>
3
4
  # Copyright:: Copyright (c) 2019 Facebook
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  #
2
3
  # Author:: Davide Cavalca <dcavalca@fb.com>
3
4
  # Copyright:: Copyright (c) 2017 Facebook
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  #
2
3
  # Author:: Thom May (<thom@clearairturbulence.org>)
3
4
  # Copyright:: Copyright (c) Chef Software Inc.
@@ -51,15 +52,15 @@ Ohai.plugin(:Virtualization) do
51
52
  # - may be able to determine if under paravirt from /dev/xen/evtchn (See OHAI-253)
52
53
  # - Additional edge cases likely should not change the above assumptions
53
54
  # but rather be additive - btm
54
- if File.exist?("/proc/xen")
55
+ if file_exist?("/proc/xen")
55
56
  virtualization[:system] = "xen"
56
57
  # Assume guest
57
58
  virtualization[:role] = "guest"
58
59
  virtualization[:systems][:xen] = "guest"
59
60
 
60
61
  # This file should exist on most Xen systems, normally empty for guests
61
- if File.exist?("/proc/xen/capabilities")
62
- if /control_d/i.match?(File.read("/proc/xen/capabilities"))
62
+ if file_exist?("/proc/xen/capabilities")
63
+ if /control_d/i.match?(file_read("/proc/xen/capabilities"))
63
64
  logger.trace("Plugin Virtualization: /proc/xen/capabilities contains control_d. Detecting as Xen host")
64
65
  virtualization[:role] = "host"
65
66
  virtualization[:systems][:xen] = "host"
@@ -68,8 +69,8 @@ Ohai.plugin(:Virtualization) do
68
69
  end
69
70
 
70
71
  # Detect Virtualbox from kernel module
71
- if File.exist?("/proc/modules")
72
- modules = File.read("/proc/modules")
72
+ if file_exist?("/proc/modules")
73
+ modules = file_read("/proc/modules")
73
74
  if /^vboxdrv/.match?(modules)
74
75
  logger.trace("Plugin Virtualization: /proc/modules contains vboxdrv. Detecting as vbox host")
75
76
  virtualization[:system] = "vbox"
@@ -92,8 +93,8 @@ Ohai.plugin(:Virtualization) do
92
93
  end
93
94
 
94
95
  # Detect paravirt KVM/QEMU from cpuinfo, report as KVM
95
- if File.exist?("/proc/cpuinfo")
96
- if /QEMU Virtual CPU|Common KVM processor|Common 32-bit KVM processor/.match?(File.read("/proc/cpuinfo"))
96
+ if file_exist?("/proc/cpuinfo")
97
+ if /QEMU Virtual CPU|Common KVM processor|Common 32-bit KVM processor/.match?(file_read("/proc/cpuinfo"))
97
98
  logger.trace("Plugin Virtualization: /proc/cpuinfo lists a KVM paravirt CPU string. Detecting as kvm guest")
98
99
  virtualization[:system] = "kvm"
99
100
  virtualization[:role] = "guest"
@@ -103,9 +104,9 @@ Ohai.plugin(:Virtualization) do
103
104
 
104
105
  # Detect KVM systems via /sys
105
106
  # guests will have the hypervisor cpu feature that hosts don't have
106
- if File.exist?("/sys/devices/virtual/misc/kvm")
107
+ if file_exist?("/sys/devices/virtual/misc/kvm")
107
108
  virtualization[:system] = "kvm"
108
- if /hypervisor/.match?(File.read("/proc/cpuinfo"))
109
+ if /hypervisor/.match?(file_read("/proc/cpuinfo"))
109
110
  logger.trace("Plugin Virtualization: /sys/devices/virtual/misc/kvm present and /proc/cpuinfo lists the hypervisor feature. Detecting as kvm guest")
110
111
  virtualization[:role] = "guest"
111
112
  virtualization[:systems][:kvm] = "guest"
@@ -129,12 +130,12 @@ Ohai.plugin(:Virtualization) do
129
130
 
130
131
  # Detect OpenVZ / Virtuozzo.
131
132
  # http://wiki.openvz.org/BC_proc_entries
132
- if File.exist?("/proc/bc/0")
133
+ if file_exist?("/proc/bc/0")
133
134
  logger.trace("Plugin Virtualization: /proc/bc/0 exists. Detecting as openvz host")
134
135
  virtualization[:system] = "openvz"
135
136
  virtualization[:role] = "host"
136
137
  virtualization[:systems][:openvz] = "host"
137
- elsif File.exist?("/proc/vz")
138
+ elsif file_exist?("/proc/vz")
138
139
  logger.trace("Plugin Virtualization: /proc/vz exists. Detecting as openvz guest")
139
140
  virtualization[:system] = "openvz"
140
141
  virtualization[:role] = "guest"
@@ -142,9 +143,9 @@ Ohai.plugin(:Virtualization) do
142
143
  end
143
144
 
144
145
  # Detect Hyper-V guest and the hostname of the host
145
- if File.exist?("/var/lib/hyperv/.kvp_pool_3")
146
+ if file_exist?("/var/lib/hyperv/.kvp_pool_3")
146
147
  logger.trace("Plugin Virtualization: /var/lib/hyperv/.kvp_pool_3 contains string indicating Hyper-V guest")
147
- data = File.read("/var/lib/hyperv/.kvp_pool_3")
148
+ data = file_read("/var/lib/hyperv/.kvp_pool_3")
148
149
  hyperv_host = data[/\HostName(.*?)HostingSystemEditionId/, 1].scan(/[[:print:]]/).join.downcase
149
150
  virtualization[:system] = "hyperv"
150
151
  virtualization[:role] = "guest"
@@ -153,8 +154,8 @@ Ohai.plugin(:Virtualization) do
153
154
  end
154
155
 
155
156
  # Detect Linux-VServer
156
- if File.exist?("/proc/self/status")
157
- proc_self_status = File.read("/proc/self/status")
157
+ if file_exist?("/proc/self/status")
158
+ proc_self_status = file_read("/proc/self/status")
158
159
  vxid = proc_self_status.match(/^(s_context|VxID):\s*(\d+)$/)
159
160
  if vxid && vxid[2]
160
161
  virtualization[:system] = "linux-vserver"
@@ -188,8 +189,8 @@ Ohai.plugin(:Virtualization) do
188
189
  #
189
190
  # Full notes, https://tickets.opscode.com/browse/OHAI-551
190
191
  # Kernel docs, https://www.kernel.org/doc/Documentation/cgroups
191
- if File.exist?("/proc/self/cgroup")
192
- cgroup_content = File.read("/proc/self/cgroup")
192
+ if file_exist?("/proc/self/cgroup")
193
+ cgroup_content = file_read("/proc/self/cgroup")
193
194
  # These two REs catch many different examples. Here's a specific one
194
195
  # from when it is docker and there is no subsystem name.
195
196
  # https://rubular.com/r/dV13hiU9KxmiWB
@@ -199,17 +200,17 @@ Ohai.plugin(:Virtualization) do
199
200
  virtualization[:system] = $1
200
201
  virtualization[:role] = "guest"
201
202
  virtualization[:systems][$1.to_sym] = "guest"
202
- elsif /container=lxc/.match?(File.read("/proc/1/environ"))
203
+ elsif /container=lxc/.match?(file_read("/proc/1/environ"))
203
204
  logger.trace("Plugin Virtualization: /proc/1/environ indicates lxc container. Detecting as lxc guest")
204
205
  virtualization[:system] = "lxc"
205
206
  virtualization[:role] = "guest"
206
207
  virtualization[:systems][:lxc] = "guest"
207
- elsif /container=systemd-nspawn/.match?(File.read("/proc/1/environ"))
208
+ elsif /container=systemd-nspawn/.match?(file_read("/proc/1/environ"))
208
209
  logger.trace("Plugin Virtualization: /proc/1/environ indicates nspawn container. Detecting as nspawn guest")
209
210
  virtualization[:system] = "nspawn"
210
211
  virtualization[:role] = "guest"
211
212
  virtualization[:systems][:nspawn] = "guest"
212
- elsif lxc_version_exists? && File.read("/proc/self/cgroup") =~ %r{\d:[^:]+:/$}
213
+ elsif lxc_version_exists? && file_read("/proc/self/cgroup") =~ %r{\d:[^:]+:/$}
213
214
  # lxc-version shouldn't be installed by default
214
215
  # Even so, it is likely we are on an LXC capable host that is not being used as such
215
216
  # So we're cautious here to not overwrite other existing values (OHAI-573)
@@ -224,7 +225,7 @@ Ohai.plugin(:Virtualization) do
224
225
  # If so, we may need to look further for a differentiator (OHAI-573)
225
226
  virtualization[:systems][:lxc] = "host"
226
227
  end
227
- elsif File.exist?("/.dockerenv") || File.exist?("/.dockerinit")
228
+ elsif file_exist?("/.dockerenv") || file_exist?("/.dockerinit")
228
229
  logger.trace("Plugin Virtualization: .dockerenv or .dockerinit exist. Detecting as docker guest")
229
230
  virtualization[:system] = "docker"
230
231
  virtualization[:role] = "guest"
@@ -233,7 +234,7 @@ Ohai.plugin(:Virtualization) do
233
234
 
234
235
  # Detect LXD
235
236
  # See https://github.com/lxc/lxd/blob/master/doc/dev-lxd.md
236
- if File.exist?("/dev/lxd/sock")
237
+ if file_exist?("/dev/lxd/sock")
237
238
  logger.trace("Plugin Virtualization: /dev/lxd/sock exists. Detecting as lxd guest")
238
239
  virtualization[:system] = "lxd"
239
240
  virtualization[:role] = "guest"
@@ -248,7 +249,7 @@ Ohai.plugin(:Virtualization) do
248
249
  # Snap based installations utilize '/var/snap/lxd/common/lxd/'
249
250
  # - includes all future releases starting with 2.21, and will be the only source of 3.1+ feature releases post-bionic
250
251
  ["/var/lib/lxd/devlxd", "/var/snap/lxd/common/lxd/devlxd"].each do |devlxd|
251
- if File.exist?(devlxd)
252
+ if file_exist?(devlxd)
252
253
  logger.trace("Plugin Virtualization: #{devlxd} exists. Detecting as lxd host")
253
254
  virtualization[:system] = "lxd"
254
255
  virtualization[:role] = "host"
@@ -18,7 +18,7 @@
18
18
 
19
19
  Ohai.plugin(:Lua) do
20
20
  provides "languages/lua"
21
- depends "languages"
21
+ depends "languages".freeze
22
22
 
23
23
  collect_data do
24
24
 
@@ -18,7 +18,7 @@
18
18
 
19
19
  Ohai.plugin(:Mono) do
20
20
  provides "languages/mono"
21
- depends "languages"
21
+ depends "languages".freeze
22
22
 
23
23
  collect_data do
24
24
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  #
2
3
  # Author:: Mathieu Sauve-Frankel <msf@kisoku.net>
3
4
  # Copyright:: Copyright (c) 2009 Bryan McLellan
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  #
2
3
  # Author:: Bryan McLellan (btm@loftninjas.org)
3
4
  # Copyright:: Copyright (c) 2009 Bryan McLellan
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  #
2
3
  # Author:: Bryan McLellan (btm@loftninjas.org)
3
4
  # Copyright:: Copyright (c) 2009 Bryan McLellan
@@ -20,8 +21,8 @@ Ohai.plugin(:Platform) do
20
21
  provides "platform", "platform_version", "platform_family"
21
22
 
22
23
  collect_data(:netbsd) do
23
- platform shell_out("uname -s").stdout.split($/)[0].downcase
24
- platform_version shell_out("uname -r").stdout.split($/)[0]
24
+ platform shell_out("uname -s").stdout.strip.downcase
25
+ platform_version shell_out("uname -r").stdout.strip
25
26
  platform_family "netbsd"
26
27
  end
27
28
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  #
2
3
  # Author:: Adam Jacob (<adam@chef.io>)
3
4
  # Copyright:: Copyright (c) Chef Software Inc.
@@ -38,7 +39,7 @@ Ohai.plugin(:NetworkAddresses) do
38
39
  next if iface_v.nil? || !iface_v.key?("addresses")
39
40
 
40
41
  iface_v["addresses"].each do |addr, addr_v|
41
- next if addr_v.nil? || (not addr_v.key? "family") || addr_v["family"] != family
42
+ next if addr_v.nil? || (!addr_v.key? "family") || addr_v["family"] != family
42
43
 
43
44
  ipaddresses << {
44
45
  ipaddress: addr_v["prefixlen"] ? IPAddress("#{addr}/#{addr_v["prefixlen"]}") : IPAddress("#{addr}/#{addr_v["netmask"]}"),
@@ -18,7 +18,7 @@
18
18
 
19
19
  Ohai.plugin(:Nodejs) do
20
20
  provides "languages/nodejs"
21
- depends "languages"
21
+ depends "languages".freeze
22
22
 
23
23
  collect_data do
24
24
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  #
2
3
  # Author:: Tollef Fog Heen <tfheen@err.no>
3
4
  # Copyright:: Copyright (c) 2010 Tollef Fog Heen
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  #
2
3
  # Author:: Adam Jacob (<adam@chef.io>)
3
4
  # Copyright:: Copyright (c) Chef Software Inc.
@@ -19,7 +20,7 @@
19
20
  Ohai.plugin(:OhaiTime) do
20
21
  provides "ohai_time"
21
22
 
22
- collect_data do
23
+ collect_data(:default, :target) do
23
24
  ohai_time Time.now.to_f
24
25
  end
25
26
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  #
2
3
  # Author:: Mathieu Sauve-Frankel <msf@kisoku.net>
3
4
  # Copyright:: Copyright (c) 2009 Bryan McLellan
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  #
2
3
  # Author:: Bryan McLellan (btm@loftninjas.org)
3
4
  # Copyright:: Copyright (c) 2009 Bryan McLellan
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  #
2
3
  # Author:: Bryan McLellan (btm@loftninjas.org)
3
4
  # Copyright:: Copyright (c) 2009 Bryan McLellan
@@ -20,8 +21,8 @@ Ohai.plugin(:Platform) do
20
21
  provides "platform", "platform_version", "platform_family"
21
22
 
22
23
  collect_data(:openbsd) do
23
- platform shell_out("uname -s").stdout.split($/)[0].downcase
24
- platform_version shell_out("uname -r").stdout.split($/)[0]
24
+ platform shell_out("uname -s").stdout.strip.downcase
25
+ platform_version shell_out("uname -r").stdout.strip
25
26
  platform_family "openbsd"
26
27
  end
27
28
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  #
2
3
  # Author:: Matt Ray (<matt@chef.io>)
3
4
  # Author:: Tim Smith (<tsmith@chef.io>)