ohai 16.2.0 → 16.4.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +2 -1
  3. data/bin/ohai +0 -2
  4. data/lib/ohai/application.rb +2 -2
  5. data/lib/ohai/dsl/plugin.rb +1 -1
  6. data/lib/ohai/loader.rb +1 -2
  7. data/lib/ohai/log.rb +1 -1
  8. data/lib/ohai/mixin/command.rb +1 -1
  9. data/lib/ohai/mixin/dmi_decode.rb +2 -2
  10. data/lib/ohai/mixin/os.rb +1 -1
  11. data/lib/ohai/mixin/softlayer_metadata.rb +1 -1
  12. data/lib/ohai/plugins/aix/memory.rb +3 -3
  13. data/lib/ohai/plugins/aix/network.rb +2 -1
  14. data/lib/ohai/plugins/aix/uptime.rb +2 -2
  15. data/lib/ohai/plugins/aix/virtualization.rb +5 -5
  16. data/lib/ohai/plugins/azure.rb +1 -1
  17. data/lib/ohai/plugins/bsd/virtualization.rb +2 -2
  18. data/lib/ohai/plugins/c.rb +2 -2
  19. data/lib/ohai/plugins/cloud.rb +1 -1
  20. data/lib/ohai/plugins/cpu.rb +2 -2
  21. data/lib/ohai/plugins/darwin/hardware.rb +2 -2
  22. data/lib/ohai/plugins/darwin/network.rb +3 -3
  23. data/lib/ohai/plugins/darwin/platform.rb +3 -6
  24. data/lib/ohai/plugins/darwin/virtualization.rb +1 -1
  25. data/lib/ohai/plugins/docker.rb +2 -2
  26. data/lib/ohai/plugins/dragonflybsd/platform.rb +2 -4
  27. data/lib/ohai/plugins/ec2.rb +8 -7
  28. data/lib/ohai/plugins/eucalyptus.rb +1 -1
  29. data/lib/ohai/plugins/filesystem.rb +11 -17
  30. data/lib/ohai/plugins/fips.rb +1 -5
  31. data/lib/ohai/plugins/freebsd/platform.rb +2 -4
  32. data/lib/ohai/plugins/gce.rb +3 -3
  33. data/lib/ohai/plugins/hostname.rb +16 -16
  34. data/lib/ohai/plugins/kernel.rb +1 -1
  35. data/lib/ohai/plugins/linux/hostnamectl.rb +1 -2
  36. data/lib/ohai/plugins/linux/interrupts.rb +1 -1
  37. data/lib/ohai/plugins/linux/lsb.rb +1 -2
  38. data/lib/ohai/plugins/linux/lspci.rb +1 -2
  39. data/lib/ohai/plugins/linux/machineid.rb +2 -2
  40. data/lib/ohai/plugins/linux/mdadm.rb +1 -1
  41. data/lib/ohai/plugins/linux/network.rb +19 -9
  42. data/lib/ohai/plugins/linux/platform.rb +22 -25
  43. data/lib/ohai/plugins/linux/virtualization.rb +12 -9
  44. data/lib/ohai/plugins/netbsd/network.rb +4 -8
  45. data/lib/ohai/plugins/netbsd/platform.rb +2 -4
  46. data/lib/ohai/plugins/network.rb +5 -4
  47. data/lib/ohai/plugins/openbsd/network.rb +4 -8
  48. data/lib/ohai/plugins/openbsd/platform.rb +2 -4
  49. data/lib/ohai/plugins/openstack.rb +3 -2
  50. data/lib/ohai/plugins/packages.rb +1 -1
  51. data/lib/ohai/plugins/passwd.rb +2 -1
  52. data/lib/ohai/plugins/rackspace.rb +5 -4
  53. data/lib/ohai/plugins/root_group.rb +1 -1
  54. data/lib/ohai/plugins/ruby.rb +4 -15
  55. data/lib/ohai/plugins/scaleway.rb +1 -1
  56. data/lib/ohai/plugins/shard.rb +1 -1
  57. data/lib/ohai/plugins/solaris2/dmi.rb +2 -3
  58. data/lib/ohai/plugins/solaris2/memory.rb +1 -2
  59. data/lib/ohai/plugins/solaris2/network.rb +2 -6
  60. data/lib/ohai/plugins/solaris2/platform.rb +1 -2
  61. data/lib/ohai/plugins/solaris2/virtualization.rb +3 -6
  62. data/lib/ohai/plugins/ssh_host_key.rb +1 -1
  63. data/lib/ohai/plugins/uptime.rb +1 -1
  64. data/lib/ohai/plugins/vmware.rb +2 -2
  65. data/lib/ohai/plugins/windows/dmi.rb +2 -2
  66. data/lib/ohai/plugins/windows/drivers.rb +1 -1
  67. data/lib/ohai/plugins/windows/memory.rb +1 -1
  68. data/lib/ohai/plugins/windows/network.rb +3 -3
  69. data/lib/ohai/plugins/windows/platform.rb +1 -1
  70. data/lib/ohai/plugins/windows/virtualization.rb +1 -1
  71. data/lib/ohai/provides_map.rb +2 -2
  72. data/lib/ohai/runner.rb +1 -1
  73. data/lib/ohai/util/ip_helper.rb +2 -2
  74. data/lib/ohai/util/win32.rb +1 -1
  75. data/lib/ohai/version.rb +1 -1
  76. data/ohai.gemspec +0 -1
  77. metadata +2 -16
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b01a821d5ffa3a329d434aa798b7e6396cd38329a5aed167cc9fa5d790e1e40b
4
- data.tar.gz: 832b596c834b379cd996bdad0d097e38684be9e175fcd50d59fce4cebc04ec19
3
+ metadata.gz: 68766eeef1353df87e6a89c047bfe2d056be75698cf3e5db73f093a0d40059c5
4
+ data.tar.gz: 39b483600849fe31706da87bf2c70eda6a7fa7dec69f1155d12ce49e124581c6
5
5
  SHA512:
6
- metadata.gz: ad4cbe610a98f04f3525b4d025e7053712dbe7c9218d38e506dd6beb031ded0e5d969ede709a0b2fdf95cea747905d18b021eea7d29db25271f24792c439bc4b
7
- data.tar.gz: 5359aff83afbfceb44068bc838ce4a8153e863a6684319a65b1164e48169e6ba406e38e537c4686d1102e4bfc29e1f783fe4bdc216654fd0d19af53d8c5fbbf0
6
+ metadata.gz: 7730a85e74744663d1d7d282e07dbc249a4be8cfa0be63ee68b0e2fc09140c4053c0a97892295fcbf769c7653327898f77d1df482eb08734ce791cf4f6713aba
7
+ data.tar.gz: a299e3ebccb093d8bde8a0941ece0e8f085b496610623265e149aeefb545020cbfb497db85de53d0e1e1c640d2edce8f724b508d467d1cfdbbbea35a1edc0ef7
data/Gemfile CHANGED
@@ -5,6 +5,7 @@ gemspec
5
5
  # NOTE: do not submit PRs to add pry as a dep, add to your Gemfile.local
6
6
  group :development do
7
7
  gem "chefstyle", git: "https://github.com/chef/chefstyle.git", branch: "master"
8
+ gem "rubocop-performance", "1.7.1"
8
9
  gem "rake", ">= 10.1.0"
9
10
  gem "rspec-core", "~> 3.0"
10
11
  gem "rspec-expectations", "~> 3.0"
@@ -24,4 +25,4 @@ group :debug do
24
25
  gem "pry-byebug"
25
26
  gem "pry-stack_explorer", "~> 0.4.0" # pin until we drop ruby < 2.6
26
27
  gem "rb-readline"
27
- end
28
+ end
data/bin/ohai CHANGED
@@ -1,7 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
  #
3
- # ./ohai - I'm in ur serverz, showin you the daters
4
- #
5
3
  # Author:: Adam Jacob (<adam@chef.io>)
6
4
  # Copyright:: Copyright (c) 2008-2016 Chef Software, Inc.
7
5
  # License:: Apache License, Version 2.0
@@ -18,9 +18,9 @@
18
18
  require "chef-config/path_helper"
19
19
  require "chef-config/workstation_config_loader"
20
20
  require_relative "../ohai"
21
- require_relative "log"
21
+ require_relative "log" unless defined?(Ohai::Log)
22
22
  require "mixlib/cli" unless defined?(Mixlib::CLI)
23
- require "benchmark"
23
+ require "benchmark" unless defined?(Benchmark)
24
24
 
25
25
  # The Application class is what is called by the Ohai CLI binary. It handles:
26
26
  # - CLI options and attribute arguments
@@ -65,7 +65,7 @@ module Ohai
65
65
  #
66
66
  # @return [String]
67
67
  def self.dev_null
68
- if RUBY_PLATFORM =~ /mswin|mingw|windows/
68
+ if RUBY_PLATFORM.match?(/mswin|mingw|windows/)
69
69
  "NUL"
70
70
  else
71
71
  "/dev/null"
@@ -71,8 +71,7 @@ module Ohai
71
71
  from = [ Ohai.config[:plugin_path], from].flatten
72
72
  plugin_files_by_dir(from).collect do |plugin_file|
73
73
  logger.trace "Loading additional plugin: #{plugin_file}"
74
- plugin = load_plugin_class(plugin_file)
75
- load_v7_plugin(plugin)
74
+ load_v7_plugin(load_plugin_class(plugin_file))
76
75
  end
77
76
  end
78
77
 
@@ -16,7 +16,7 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require "mixlib/log"
19
+ require "mixlib/log" unless defined?(Mixlib::Log)
20
20
 
21
21
  module Ohai
22
22
  # the Ohai Logger which is just Mixlib::Log defaulting to STDERR and :info level
@@ -30,7 +30,7 @@ module Ohai
30
30
  options = options.dup
31
31
  # unless specified by the caller timeout after configured timeout (default 30 seconds)
32
32
  options[:timeout] ||= Ohai::Config.ohai[:shellout_timeout]
33
- unless RUBY_PLATFORM =~ /mswin|mingw32|windows/
33
+ unless RUBY_PLATFORM.match?(/mswin|mingw32|windows/)
34
34
  options[:env] = options.key?(:env) ? options[:env].dup : {}
35
35
  options[:env]["PATH"] ||= ((ENV["PATH"] || "").split(":") + %w{/usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin}).join(":")
36
36
  end
@@ -26,7 +26,7 @@ module ::Ohai::Mixin::DmiDecode
26
26
  when /VMware/
27
27
  return "vmware"
28
28
  when /Microsoft/
29
- return "hyperv" if product =~ /Virtual Machine/
29
+ return "hyperv" if /Virtual Machine/.match?(product)
30
30
  when /Amazon EC2/
31
31
  return "amazonec2"
32
32
  when /QEMU/
@@ -40,7 +40,7 @@ module ::Ohai::Mixin::DmiDecode
40
40
  case product
41
41
  when /VirtualBox/
42
42
  return "vbox"
43
- when /OpenStack/ # yes this is here twice. Product catches Redhat's version
43
+ when /OpenStack/ # yes this is here twice. Product catches Red Hat's version
44
44
  return "openstack"
45
45
  when /(KVM|RHEV)/
46
46
  return "kvm"
@@ -17,7 +17,7 @@
17
17
  # limitations under the License.
18
18
  #
19
19
 
20
- require "rbconfig"
20
+ require "rbconfig" unless defined?(RbConfig)
21
21
 
22
22
  module Ohai
23
23
  module Mixin
@@ -17,7 +17,7 @@
17
17
  # See the License for the specific language governing permissions and
18
18
  # limitations under the License.
19
19
 
20
- require "net/https"
20
+ require "net/http" unless defined?(Net::HTTP)
21
21
  require "uri" unless defined?(URI)
22
22
 
23
23
  # https://softlayer.github.io/reference/services/SoftLayer_Resource_Metadata/
@@ -29,8 +29,8 @@ Ohai.plugin(:Memory) do
29
29
  memory[:total] = "#{total_in_mb.to_i * 1024}kB"
30
30
  memory[:free] = "#{free_in_mb.to_i * 1024}kB"
31
31
 
32
- swapinfo = shell_out("swap -s").stdout.split # returns swap info in 4K blocks
33
- memory[:swap]["total"] = "#{(swapinfo[2].to_i) * 4}kB"
34
- memory[:swap]["free"] = "#{(swapinfo[10].to_i) * 4}kB"
32
+ swap_info = shell_out("swap -s").stdout.split # returns swap info in 4K blocks
33
+ memory[:swap]["total"] = "#{(swap_info[2].to_i) * 4}kB"
34
+ memory[:swap]["free"] = "#{(swap_info[10].to_i) * 4}kB"
35
35
  end
36
36
  end
@@ -19,7 +19,6 @@
19
19
  #
20
20
 
21
21
  Ohai.plugin(:Network) do
22
- require "ipaddr"
23
22
  require_relative "../../mixin/network_helper"
24
23
 
25
24
  provides "network", "counters/network", "macaddress"
@@ -27,6 +26,8 @@ Ohai.plugin(:Network) do
27
26
  include Ohai::Mixin::NetworkHelper
28
27
 
29
28
  collect_data(:aix) do
29
+ require "ipaddr" unless defined?(IPAddr)
30
+
30
31
  # Loads following information.
31
32
  # :default_interface, :default_gateway - route -n get 0
32
33
  # :interfaces
@@ -21,7 +21,7 @@ Ohai.plugin(:Uptime) do
21
21
  provides "uptime", "uptime_seconds"
22
22
 
23
23
  collect_data(:aix) do
24
- require "date"
24
+ require "date" unless defined?(DateTime)
25
25
  # below we're going to assume that PID 1 is init (this is true 99.99999% of the time)
26
26
  # output will look like this
27
27
  # 1148-20:54:50
@@ -30,7 +30,7 @@ Ohai.plugin(:Uptime) do
30
30
  so = shell_out("LC_ALL=POSIX ps -o etime= -p 1").stdout.strip
31
31
 
32
32
  # Here we'll check our shell_out for a dash, which indicates there is a # of days involved
33
- # We'll chunk off the days, hours (where applicable), minutes, seconds into seperate vars
33
+ # We'll chunk off the days, hours (where applicable), minutes, seconds into separate vars
34
34
  # We also need to do this because ps -o etime= will not display days if the machine has been up for less than 24 hours
35
35
  # If the machine has been up for less than one hour, the shell_out will not output hours hence our else
36
36
  # see here: https://www.ibm.com/support/knowledgecenter/en/ssw_aix_72/com.ibm.aix.cmds4/ps.htm#ps__row-d3e109655
@@ -57,7 +57,7 @@ Ohai.plugin(:Virtualization) do
57
57
  sections.each do |line|
58
58
  case title
59
59
  when "network"
60
- next if line =~ /^Interface|^---/
60
+ next if /^Interface|^---/.match?(line)
61
61
 
62
62
  splat = line.strip.split
63
63
  key = splat[0].downcase
@@ -68,7 +68,7 @@ Ohai.plugin(:Virtualization) do
68
68
  }
69
69
  wpars[wpar_name][title][key] = value
70
70
  when "user-specified routes"
71
- next if line =~ /^Type|^---/
71
+ next if /^Type|^---/.match?(line)
72
72
 
73
73
  splat = line.strip.split
74
74
  key = splat[2].downcase
@@ -78,7 +78,7 @@ Ohai.plugin(:Virtualization) do
78
78
  }
79
79
  wpars[wpar_name][title][key] = value
80
80
  when "file systems"
81
- next if line =~ /^MountPoint|^---/
81
+ next if /^MountPoint|^---/.match?(line)
82
82
 
83
83
  splat = line.strip.split
84
84
  key = splat[1].downcase
@@ -93,7 +93,7 @@ Ohai.plugin(:Virtualization) do
93
93
  privileges ||= ""
94
94
  wpars[wpar_name][title]["Privileges"] ||= []
95
95
 
96
- if line =~ /^Privileges/
96
+ if /^Privileges/.match?(line)
97
97
  privileges << line.split(":")[1].strip
98
98
  else
99
99
  privileges << line.strip
@@ -101,7 +101,7 @@ Ohai.plugin(:Virtualization) do
101
101
 
102
102
  wpars[wpar_name][title]["Privileges"] += privileges.split(",")
103
103
  when "device exports"
104
- next if line =~ /^Name|^---/
104
+ next if /^Name|^---/.match?(line)
105
105
 
106
106
  splat = line.strip.split
107
107
  key = splat[0].downcase
@@ -57,7 +57,7 @@ Ohai.plugin(:Azure) do
57
57
  has_245 = false
58
58
  if File.exist?("/var/lib/dhcp/dhclient.eth0.leases")
59
59
  File.open("/var/lib/dhcp/dhclient.eth0.leases").each do |line|
60
- if line =~ /unknown-245/
60
+ if /unknown-245/.match?(line)
61
61
  logger.trace("Plugin Azure: Found unknown-245 DHCP option used by Azure.")
62
62
  has_245 = true
63
63
  break
@@ -76,7 +76,7 @@ Ohai.plugin(:Virtualization) do
76
76
  # Detect KVM/QEMU paravirt guests from cpu, report as KVM
77
77
  # hw.model: QEMU Virtual CPU version 0.9.1
78
78
  so = shell_out("sysctl -n hw.model")
79
- if so.stdout =~ /QEMU Virtual CPU|KVM processor/
79
+ if /QEMU Virtual CPU|KVM processor/.match?(so.stdout)
80
80
  virtualization[:system] = "kvm"
81
81
  virtualization[:role] = "guest"
82
82
  virtualization[:systems][:kvm] = "guest"
@@ -96,7 +96,7 @@ Ohai.plugin(:Virtualization) do
96
96
  "xen"
97
97
  when /kvm/
98
98
  so = shell_out("sysctl -n kern.hostuuid")
99
- so.stdout =~ /^ec2/ ? "amazonec2" : "kvm"
99
+ /^ec2/.match?(so.stdout) ? "amazonec2" : "kvm"
100
100
  when /bhyve/
101
101
  "bhyve"
102
102
  end
@@ -137,7 +137,7 @@ Ohai.plugin(:C) do
137
137
  logger.trace("Plugin C: 'xlc' binary could not be found. Skipping data.")
138
138
  end
139
139
 
140
- def collect_sunpro
140
+ def collect_sun_pro
141
141
  # sun pro
142
142
  collect("cc -V -flags") do |so|
143
143
  output = so.stderr.split
@@ -173,7 +173,7 @@ Ohai.plugin(:C) do
173
173
  @c = Mash.new
174
174
  collect_gcc
175
175
  collect_glibc
176
- collect_sunpro
176
+ collect_sun_pro
177
177
  languages[:c] = @c unless @c.empty?
178
178
  end
179
179
  end
@@ -320,7 +320,7 @@ Ohai.plugin(:Cloud) do
320
320
  end
321
321
 
322
322
  collect_data do
323
- require "ipaddr"
323
+ require "ipaddr" unless defined?(IPAddr)
324
324
 
325
325
  @cloud_attr_obj = CloudAttrs.new
326
326
 
@@ -305,7 +305,7 @@ Ohai.plugin(:CPU) do
305
305
  cpu[index] = Mash.new
306
306
  cpu[index][:status] = status
307
307
  cpu[index][:location] = location
308
- if status =~ /Available/
308
+ if /Available/.match?(status)
309
309
  cpu[:available] += 1
310
310
  lsattr = shell_out("lsattr -El #{name}").stdout.lines
311
311
  lsattr.each do |attribute|
@@ -377,7 +377,7 @@ Ohai.plugin(:CPU) do
377
377
  end
378
378
 
379
379
  collect_data(:windows) do
380
- require "wmi-lite/wmi"
380
+ require "wmi-lite/wmi" unless defined?(WmiLite::Wmi)
381
381
 
382
382
  cpu Mash.new
383
383
  cores = 0
@@ -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*(.*)$/
@@ -66,8 +66,8 @@ Ohai.plugin(:Network) do
66
66
 
67
67
  def scope_lookup(scope)
68
68
  return "Node" if scope.eql?("::1")
69
- return "Link" if scope =~ /^fe80\:/
70
- return "Site" if scope =~ /^fec0\:/
69
+ return "Link" if /^fe80\:/.match?(scope)
70
+ return "Site" if /^fec0\:/.match?(scope)
71
71
 
72
72
  "Global"
73
73
  end
@@ -79,7 +79,7 @@ Ohai.plugin(:Network) do
79
79
  def locate_interface(ifaces, ifname, mac)
80
80
  return ifname unless ifaces[ifname].nil?
81
81
  # oh well, time to go hunting!
82
- return ifname.chop if ifname =~ /\*$/
82
+ return ifname.chop if /\*$/.match?(ifname)
83
83
 
84
84
  ifaces.each_key do |ifc|
85
85
  ifaces[ifc][:addresses].each_key do |addr|
@@ -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
@@ -82,7 +82,7 @@ Ohai.plugin(:Virtualization) do
82
82
  virtualization[:systems][:parallels] = "host"
83
83
  elsif ioreg_exists?
84
84
  so = shell_out("ioreg -l")
85
- if so.stdout =~ /pci1ab8,4000/
85
+ if /pci1ab8,4000/.match?(so.stdout)
86
86
  virtualization[:system] = "parallels"
87
87
  virtualization[:role] = "guest"
88
88
  virtualization[:systems][:parallels] = "guest"
@@ -16,8 +16,6 @@
16
16
  #
17
17
 
18
18
  Ohai.plugin(:Docker) do
19
- require "json"
20
-
21
19
  provides "docker"
22
20
  depends "virtualization"
23
21
 
@@ -50,6 +48,8 @@ Ohai.plugin(:Docker) do
50
48
  end
51
49
 
52
50
  collect_data do
51
+ require "json" unless defined?(JSON)
52
+
53
53
  if virtualization[:systems][:docker]
54
54
  docker_ohai_data(docker_info_json)
55
55
  end
@@ -20,10 +20,8 @@ Ohai.plugin(:Platform) do
20
20
  provides "platform", "platform_version", "platform_family"
21
21
 
22
22
  collect_data(:dragonflybsd) do
23
- so = shell_out("uname -s")
24
- platform so.stdout.split($/)[0].downcase
25
- so = shell_out("uname -r")
26
- platform_version so.stdout.split($/)[0]
23
+ platform shell_out("uname -s").stdout.split($/)[0].downcase
24
+ platform_version shell_out("uname -r").stdout.split($/)[0]
27
25
  platform_family "dragonflybsd"
28
26
  end
29
27
  end
@@ -28,7 +28,6 @@
28
28
  Ohai.plugin(:EC2) do
29
29
  require_relative "../mixin/ec2_metadata"
30
30
  require_relative "../mixin/http_helper"
31
- require "base64"
32
31
 
33
32
  include Ohai::Mixin::Ec2Metadata
34
33
  include Ohai::Mixin::HttpHelper
@@ -41,7 +40,7 @@ Ohai.plugin(:EC2) do
41
40
  # @return [Boolean] do we have Amazon DMI data?
42
41
  def has_ec2_amazon_dmi?
43
42
  # detect a version of '4.2.amazon'
44
- if file_val_if_exists("/sys/class/dmi/id/bios_vendor") =~ /Amazon/
43
+ if /Amazon/.match?(file_val_if_exists("/sys/class/dmi/id/bios_vendor"))
45
44
  logger.trace("Plugin EC2: has_ec2_amazon_dmi? == true")
46
45
  true
47
46
  else
@@ -56,7 +55,7 @@ Ohai.plugin(:EC2) do
56
55
  # @return [Boolean] do we have Amazon DMI data?
57
56
  def has_ec2_xen_dmi?
58
57
  # detect a version of '4.2.amazon'
59
- if file_val_if_exists("/sys/class/dmi/id/bios_version") =~ /amazon/
58
+ if /amazon/.match?(file_val_if_exists("/sys/class/dmi/id/bios_version"))
60
59
  logger.trace("Plugin EC2: has_ec2_xen_dmi? == true")
61
60
  true
62
61
  else
@@ -68,7 +67,7 @@ Ohai.plugin(:EC2) do
68
67
  # looks for a xen UUID that starts with ec2 from within the Linux sys tree
69
68
  # @return [Boolean] do we have a Xen UUID or not?
70
69
  def has_ec2_xen_uuid?
71
- if file_val_if_exists("/sys/hypervisor/uuid") =~ /^ec2/
70
+ if /^ec2/.match?(file_val_if_exists("/sys/hypervisor/uuid"))
72
71
  logger.trace("Plugin EC2: has_ec2_xen_uuid? == true")
73
72
  return true
74
73
  end
@@ -81,10 +80,10 @@ Ohai.plugin(:EC2) do
81
80
  # linux hosts
82
81
  # @return [Boolean] do we have a Xen Identifying Number or not?
83
82
  def has_ec2_identifying_number?
84
- if RUBY_PLATFORM =~ /mswin|mingw32|windows/
85
- require "wmi-lite/wmi"
83
+ if RUBY_PLATFORM.match?(/mswin|mingw32|windows/)
84
+ require "wmi-lite/wmi" unless defined?(WmiLite::Wmi)
86
85
  wmi = WmiLite::Wmi.new
87
- if wmi.first_of("Win32_ComputerSystemProduct")["identifyingnumber"] =~ /^ec2/
86
+ if /^ec2/.match?(wmi.first_of("Win32_ComputerSystemProduct")["identifyingnumber"])
88
87
  logger.trace("Plugin EC2: has_ec2_identifying_number? == true")
89
88
  true
90
89
  end
@@ -115,6 +114,8 @@ Ohai.plugin(:EC2) do
115
114
  end
116
115
 
117
116
  collect_data do
117
+ require "base64"
118
+
118
119
  if looks_like_ec2?
119
120
  logger.trace("Plugin EC2: looks_like_ec2? == true")
120
121
  ec2 Mash.new