ohai 14.2.0 → 14.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (130) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -1
  3. data/Rakefile +1 -1
  4. data/lib/ohai/application.rb +29 -29
  5. data/lib/ohai/common/dmi.rb +5 -5
  6. data/lib/ohai/dsl/plugin.rb +3 -3
  7. data/lib/ohai/dsl/plugin/versionvii.rb +3 -3
  8. data/lib/ohai/mixin/azure_metadata.rb +2 -2
  9. data/lib/ohai/mixin/do_metadata.rb +3 -3
  10. data/lib/ohai/mixin/ec2_metadata.rb +8 -8
  11. data/lib/ohai/mixin/gce_metadata.rb +2 -2
  12. data/lib/ohai/mixin/network_constants.rb +1 -1
  13. data/lib/ohai/mixin/scaleway_metadata.rb +3 -3
  14. data/lib/ohai/mixin/softlayer_metadata.rb +1 -1
  15. data/lib/ohai/mixin/string.rb +2 -2
  16. data/lib/ohai/plugins/aix/cpu.rb +3 -3
  17. data/lib/ohai/plugins/aix/filesystem.rb +1 -1
  18. data/lib/ohai/plugins/aix/kernel.rb +1 -1
  19. data/lib/ohai/plugins/aix/memory.rb +1 -1
  20. data/lib/ohai/plugins/aix/network.rb +3 -3
  21. data/lib/ohai/plugins/bsd/virtualization.rb +1 -1
  22. data/lib/ohai/plugins/cloud.rb +1 -1
  23. data/lib/ohai/plugins/darwin/hardware.rb +1 -1
  24. data/lib/ohai/plugins/darwin/network.rb +5 -5
  25. data/lib/ohai/plugins/darwin/platform.rb +1 -1
  26. data/lib/ohai/plugins/dmi.rb +6 -6
  27. data/lib/ohai/plugins/filesystem.rb +5 -5
  28. data/lib/ohai/plugins/hostname.rb +5 -5
  29. data/lib/ohai/plugins/kernel.rb +8 -8
  30. data/lib/ohai/plugins/linux/lspci.rb +4 -4
  31. data/lib/ohai/plugins/linux/memory.rb +4 -4
  32. data/lib/ohai/plugins/linux/network.rb +16 -16
  33. data/lib/ohai/plugins/linux/platform.rb +7 -1
  34. data/lib/ohai/plugins/netbsd/network.rb +1 -1
  35. data/lib/ohai/plugins/network.rb +5 -5
  36. data/lib/ohai/plugins/openbsd/network.rb +1 -1
  37. data/lib/ohai/plugins/packages.rb +1 -1
  38. data/lib/ohai/plugins/passwd.rb +4 -4
  39. data/lib/ohai/plugins/ruby.rb +13 -13
  40. data/lib/ohai/plugins/solaris2/dmi.rb +3 -3
  41. data/lib/ohai/plugins/solaris2/filesystem.rb +6 -6
  42. data/lib/ohai/plugins/solaris2/memory.rb +2 -2
  43. data/lib/ohai/plugins/solaris2/network.rb +36 -36
  44. data/lib/ohai/plugins/windows/network.rb +2 -2
  45. data/lib/ohai/util/win32/group_helper.rb +1 -1
  46. data/lib/ohai/version.rb +1 -1
  47. data/spec/functional/application_spec.rb +6 -6
  48. data/spec/functional/loader_spec.rb +4 -4
  49. data/spec/functional/plugins/windows/uptime_spec.rb +1 -2
  50. data/spec/spec_helper.rb +5 -5
  51. data/spec/unit/application_spec.rb +11 -11
  52. data/spec/unit/config_spec.rb +5 -5
  53. data/spec/unit/dsl/plugin_spec.rb +5 -5
  54. data/spec/unit/hints_spec.rb +2 -2
  55. data/spec/unit/loader_spec.rb +41 -41
  56. data/spec/unit/mixin/azure_metadata_spec.rb +3 -3
  57. data/spec/unit/mixin/command_spec.rb +64 -64
  58. data/spec/unit/mixin/ec2_metadata_spec.rb +6 -6
  59. data/spec/unit/mixin/softlayer_metadata_spec.rb +1 -1
  60. data/spec/unit/plugin_config_spec.rb +9 -9
  61. data/spec/unit/plugins/abort_spec.rb +6 -6
  62. data/spec/unit/plugins/aix/cpu_spec.rb +16 -16
  63. data/spec/unit/plugins/aix/filesystem_spec.rb +57 -57
  64. data/spec/unit/plugins/aix/network_spec.rb +35 -35
  65. data/spec/unit/plugins/aix/virtualization_spec.rb +210 -210
  66. data/spec/unit/plugins/azure_spec.rb +49 -49
  67. data/spec/unit/plugins/bsd/filesystem_spec.rb +13 -13
  68. data/spec/unit/plugins/bsd/virtualization_spec.rb +10 -10
  69. data/spec/unit/plugins/c_spec.rb +54 -54
  70. data/spec/unit/plugins/chef_spec.rb +3 -3
  71. data/spec/unit/plugins/darwin/cpu_spec.rb +54 -54
  72. data/spec/unit/plugins/darwin/filesystem_spec.rb +34 -34
  73. data/spec/unit/plugins/darwin/hardware_system_profiler_output.rb +1070 -1070
  74. data/spec/unit/plugins/darwin/memory_spec.rb +16 -16
  75. data/spec/unit/plugins/darwin/network_spec.rb +382 -382
  76. data/spec/unit/plugins/digital_ocean_spec.rb +7 -7
  77. data/spec/unit/plugins/dmi_spec.rb +83 -83
  78. data/spec/unit/plugins/docker_spec.rb +2 -2
  79. data/spec/unit/plugins/ec2_spec.rb +156 -156
  80. data/spec/unit/plugins/eucalyptus_spec.rb +19 -19
  81. data/spec/unit/plugins/fail_spec.rb +14 -14
  82. data/spec/unit/plugins/freebsd/cpu_spec.rb +18 -18
  83. data/spec/unit/plugins/freebsd/kernel_spec.rb +1 -1
  84. data/spec/unit/plugins/gce_spec.rb +1 -1
  85. data/spec/unit/plugins/init_package_spec.rb +1 -1
  86. data/spec/unit/plugins/java_spec.rb +4 -4
  87. data/spec/unit/plugins/joyent_spec.rb +9 -9
  88. data/spec/unit/plugins/linux/block_device_spec.rb +1 -1
  89. data/spec/unit/plugins/linux/cpu_spec.rb +155 -155
  90. data/spec/unit/plugins/linux/filesystem_spec.rb +229 -229
  91. data/spec/unit/plugins/linux/kernel_spec.rb +9 -9
  92. data/spec/unit/plugins/linux/lsb_spec.rb +18 -18
  93. data/spec/unit/plugins/linux/lspci_spec.rb +58 -58
  94. data/spec/unit/plugins/linux/mdadm_spec.rb +54 -54
  95. data/spec/unit/plugins/linux/memory_spec.rb +35 -35
  96. data/spec/unit/plugins/linux/network_spec.rb +464 -464
  97. data/spec/unit/plugins/linux/platform_spec.rb +84 -68
  98. data/spec/unit/plugins/linux/systemd_paths_spec.rb +40 -40
  99. data/spec/unit/plugins/linux/uptime_spec.rb +1 -1
  100. data/spec/unit/plugins/linux/virtualization_spec.rb +197 -197
  101. data/spec/unit/plugins/mono_spec.rb +11 -11
  102. data/spec/unit/plugins/netbsd/kernel_spec.rb +1 -1
  103. data/spec/unit/plugins/network_spec.rb +2 -2
  104. data/spec/unit/plugins/openstack_spec.rb +43 -43
  105. data/spec/unit/plugins/os_spec.rb +1 -1
  106. data/spec/unit/plugins/passwd_spec.rb +9 -9
  107. data/spec/unit/plugins/php_spec.rb +22 -22
  108. data/spec/unit/plugins/powershell_spec.rb +13 -13
  109. data/spec/unit/plugins/rackspace_spec.rb +38 -38
  110. data/spec/unit/plugins/ruby_spec.rb +14 -14
  111. data/spec/unit/plugins/scaleway_spec.rb +6 -6
  112. data/spec/unit/plugins/scsi_spec.rb +7 -7
  113. data/spec/unit/plugins/solaris2/cpu_spec.rb +2594 -2594
  114. data/spec/unit/plugins/solaris2/dmi_spec.rb +91 -91
  115. data/spec/unit/plugins/solaris2/filesystem.rb +8 -8
  116. data/spec/unit/plugins/solaris2/kernel_spec.rb +1 -1
  117. data/spec/unit/plugins/solaris2/network_spec.rb +92 -93
  118. data/spec/unit/plugins/solaris2/platform_spec.rb +24 -24
  119. data/spec/unit/plugins/solaris2/virtualization_spec.rb +22 -22
  120. data/spec/unit/plugins/ssh_host_keys_spec.rb +12 -12
  121. data/spec/unit/plugins/sysconf_spec.rb +321 -321
  122. data/spec/unit/plugins/virtualbox_spec.rb +27 -27
  123. data/spec/unit/plugins/windows/cpu_spec.rb +9 -9
  124. data/spec/unit/plugins/windows/kernel_spec.rb +12 -12
  125. data/spec/unit/plugins/windows/uptime_spec.rb +1 -1
  126. data/spec/unit/plugins/zpools_spec.rb +41 -41
  127. data/spec/unit/runner_spec.rb +2 -2
  128. data/spec/unit/system_spec.rb +55 -55
  129. metadata +3 -4
  130. data/docs/man/man1/ohai.1 +0 -97
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b945f38a205eba8ba878ca75cb0e060ce08659f75cc854fe9e430bd7ed133961
4
- data.tar.gz: a709b76357dc0c705e4a57602be622773362890e0467ed7049985b6e83a71daa
3
+ metadata.gz: 63dacc5848d269ab4c734b26cfd943b4918d5cdfbe640fce1b8b1804a9094198
4
+ data.tar.gz: '0885d6bbffe839c17f2683f75c11cae64b2177c2e12effeefa8abd09b5198a16'
5
5
  SHA512:
6
- metadata.gz: ba896baca29452e5bfe0dba1f296df3cab45bb9a22fdb68ca61617e597788f1d3ec6f8245bd8b15ab25e7cba733d1f35e90946088407885488a83ec8c45f9c24
7
- data.tar.gz: b037ad1653096e4579e8b1ac0375d1e542fbcabee595414dabca26746bc2c75936199ef6da2ed471534934fbf24f701a788f4dae67444f62ab777fa64d9df6ae
6
+ metadata.gz: 815b9e031ecece77af44c06828dadd7c95db98d651b8b732c4b5b8d95376676905cd48ea3ba02bb409f38d65ca796c1707df9b880cbcae09305c1638257a454b
7
+ data.tar.gz: dc225e37afcc613a73c6ed3f02b47718052263a43d7c66d2dbf763e9955ed60860d600f7f33b584a1fefa3a610e8524995fe08680eb74fa817871e0b2d14278b
data/Gemfile CHANGED
@@ -4,7 +4,7 @@ gemspec
4
4
 
5
5
  # NOTE: do not submit PRs to add pry as a dep, add to your Gemfile.local
6
6
  group :development do
7
- gem "chefstyle"
7
+ gem "chefstyle", git: "https://github.com/chef/chefstyle.git", branch: "master"
8
8
  gem "rake", ">= 10.1.0"
9
9
  gem "rspec-core", "~> 3.0"
10
10
  gem "rspec-expectations", "~> 3.0"
data/Rakefile CHANGED
@@ -15,7 +15,7 @@ rescue LoadError
15
15
  end
16
16
  end
17
17
 
18
- task :default => :spec
18
+ task default: :spec
19
19
 
20
20
  require "chefstyle"
21
21
  require "rubocop/rake_task"
@@ -26,45 +26,45 @@ class Ohai::Application
26
26
  include Mixlib::CLI
27
27
 
28
28
  option :config_file,
29
- :short => "-c CONFIG",
30
- :long => "--config CONFIG",
31
- :description => "A configuration file to use",
32
- :proc => lambda { |path| File.expand_path(path, Dir.pwd) }
29
+ short: "-c CONFIG",
30
+ long: "--config CONFIG",
31
+ description: "A configuration file to use",
32
+ proc: lambda { |path| File.expand_path(path, Dir.pwd) }
33
33
 
34
34
  option :directory,
35
- :short => "-d DIRECTORY",
36
- :long => "--directory DIRECTORY",
37
- :description => "A directory to add to the Ohai plugin search path",
38
- :proc => lambda { |path| Ohai::Config.platform_specific_path(path) }
35
+ short: "-d DIRECTORY",
36
+ long: "--directory DIRECTORY",
37
+ description: "A directory to add to the Ohai plugin search path",
38
+ proc: lambda { |path| Ohai::Config.platform_specific_path(path) }
39
39
 
40
40
  option :log_level,
41
- :short => "-l LEVEL",
42
- :long => "--log_level LEVEL",
43
- :description => "Set the log level (debug, info, warn, error, fatal)",
44
- :proc => lambda { |l| l.to_sym }
41
+ short: "-l LEVEL",
42
+ long: "--log_level LEVEL",
43
+ description: "Set the log level (debug, info, warn, error, fatal)",
44
+ proc: lambda { |l| l.to_sym }
45
45
 
46
46
  option :log_location,
47
- :short => "-L LOGLOCATION",
48
- :long => "--logfile LOGLOCATION",
49
- :description => "Set the log file location, defaults to STDOUT - recommended for daemonizing",
50
- :proc => nil
47
+ short: "-L LOGLOCATION",
48
+ long: "--logfile LOGLOCATION",
49
+ description: "Set the log file location, defaults to STDOUT - recommended for daemonizing",
50
+ proc: nil
51
51
 
52
52
  option :help,
53
- :short => "-h",
54
- :long => "--help",
55
- :description => "Show this message",
56
- :on => :tail,
57
- :boolean => true,
58
- :show_options => true,
59
- :exit => 0
53
+ short: "-h",
54
+ long: "--help",
55
+ description: "Show this message",
56
+ on: :tail,
57
+ boolean: true,
58
+ show_options: true,
59
+ exit: 0
60
60
 
61
61
  option :version,
62
- :short => "-v",
63
- :long => "--version",
64
- :description => "Show Ohai version",
65
- :boolean => true,
66
- :proc => lambda { |v| puts "Ohai: #{::Ohai::VERSION}" },
67
- :exit => 0
62
+ short: "-v",
63
+ long: "--version",
64
+ description: "Show Ohai version",
65
+ boolean: true,
66
+ proc: lambda { |v| puts "Ohai: #{::Ohai::VERSION}" },
67
+ exit: 0
68
68
 
69
69
  def initialize
70
70
  super
@@ -70,11 +70,11 @@ module Ohai
70
70
  42 => "management_controller_host_interfaces",
71
71
  126 => "disabled_entries",
72
72
  127 => "end_of_table_marker",
73
- }
73
+ }.freeze
74
74
 
75
75
  # list of IDs to collect from config or default to a sane list that prunes
76
76
  # away some of the less useful IDs
77
- ID_TO_CAPTURE = [ 0, 1, 2, 3, 4, 6, 11 ]
77
+ ID_TO_CAPTURE = [ 0, 1, 2, 3, 4, 6, 11 ].freeze
78
78
 
79
79
  # the whitelisted DMI IDs. This is combination of the defaults + any additional
80
80
  # IDs defined in the :additional_dmi_ids config
@@ -100,7 +100,7 @@ module Ohai
100
100
  id = id.to_i
101
101
  if (id >= 128) && (id <= 255)
102
102
  id = "oem_data_#{id}"
103
- elsif DMI::ID_TO_DESCRIPTION.has_key?(id)
103
+ elsif DMI::ID_TO_DESCRIPTION.key?(id)
104
104
  id = DMI::ID_TO_DESCRIPTION[id]
105
105
  else
106
106
  Ohai::Log.debug("unrecognized header id; falling back to 'unknown'")
@@ -118,7 +118,7 @@ module Ohai
118
118
  dmi.each do |type, records|
119
119
  in_common = Mash.new
120
120
  next unless records.class.to_s == "Mash"
121
- next unless records.has_key?("all_records")
121
+ next unless records.key?("all_records")
122
122
  records[:all_records].each do |record|
123
123
  record.each do |field, value|
124
124
  next if value.class.to_s == "Mash"
@@ -127,7 +127,7 @@ module Ohai
127
127
  next if field.to_s == "record_id"
128
128
  translated = field.downcase.gsub(/[^a-z0-9]/, "_")
129
129
  value = value.strip
130
- if in_common.has_key?(translated)
130
+ if in_common.key?(translated)
131
131
  in_common[translated] = nil unless in_common[translated] == value
132
132
  else
133
133
  in_common[translated] = value
@@ -128,7 +128,7 @@ module Ohai
128
128
  end
129
129
 
130
130
  def has_key?(name)
131
- @data.has_key?(name)
131
+ @data.key?(name)
132
132
  end
133
133
 
134
134
  def attribute?(name, *keys)
@@ -140,7 +140,7 @@ module Ohai
140
140
  end
141
141
 
142
142
  def from(cmd)
143
- _status, stdout, _stderr = run_command(:command => cmd)
143
+ _status, stdout, _stderr = run_command(command: cmd)
144
144
  return "" if stdout.nil? || stdout.empty?
145
145
  stdout.strip
146
146
  end
@@ -150,7 +150,7 @@ module Ohai
150
150
  # the value.
151
151
  def from_with_regex(cmd, *regex_list)
152
152
  regex_list.flatten.each do |regex|
153
- _status, stdout, _stderr = run_command(:command => cmd)
153
+ _status, stdout, _stderr = run_command(command: cmd)
154
154
  return "" if stdout.nil? || stdout.empty?
155
155
  stdout.chomp!.strip
156
156
  md = stdout.match(regex)
@@ -108,7 +108,7 @@ module Ohai
108
108
  # @param block [block] the actual code to collect data for the specified platforms
109
109
  def self.collect_data(platform = :default, *other_platforms, &block)
110
110
  [platform, other_platforms].flatten.each do |plat|
111
- if data_collector.has_key?(plat)
111
+ if data_collector.key?(plat)
112
112
  raise Ohai::Exceptions::IllegalPluginDefinition, "collect_data already defined on platform #{plat}"
113
113
  else
114
114
  data_collector[plat] = block
@@ -125,9 +125,9 @@ module Ohai
125
125
  collector = self.class.data_collector
126
126
  platform = collect_os
127
127
 
128
- if collector.has_key?(platform)
128
+ if collector.key?(platform)
129
129
  instance_eval(&collector[platform])
130
- elsif collector.has_key?(:default)
130
+ elsif collector.key?(:default)
131
131
  instance_eval(&collector[:default])
132
132
  else
133
133
  logger.trace("Plugin #{name}: No data to collect. Skipping...")
@@ -21,8 +21,8 @@ module Ohai
21
21
  module Mixin
22
22
  module AzureMetadata
23
23
 
24
- AZURE_METADATA_ADDR = "169.254.169.254" unless defined?(AZURE_METADATA_ADDR)
25
- AZURE_METADATA_URL = "/metadata/instance?api-version=2017-08-01" unless defined?(AZURE_METADATA_URL)
24
+ AZURE_METADATA_ADDR = "169.254.169.254".freeze unless defined?(AZURE_METADATA_ADDR)
25
+ AZURE_METADATA_URL = "/metadata/instance?api-version=2017-08-01".freeze unless defined?(AZURE_METADATA_URL)
26
26
 
27
27
  # fetch the meta content with a timeout and the required header
28
28
  def http_get(uri)
@@ -20,15 +20,15 @@ module Ohai
20
20
  module Mixin
21
21
  module DOMetadata
22
22
 
23
- DO_METADATA_ADDR = "169.254.169.254" unless defined?(DO_METADATA_ADDR)
24
- DO_METADATA_URL = "/metadata/v1.json" unless defined?(DO_METADATA_URL)
23
+ DO_METADATA_ADDR = "169.254.169.254".freeze unless defined?(DO_METADATA_ADDR)
24
+ DO_METADATA_URL = "/metadata/v1.json".freeze unless defined?(DO_METADATA_URL)
25
25
 
26
26
  def http_client
27
27
  Net::HTTP.start(DO_METADATA_ADDR).tap { |h| h.read_timeout = 6 }
28
28
  end
29
29
 
30
30
  def fetch_metadata
31
- uri = "#{DO_METADATA_URL}"
31
+ uri = (DO_METADATA_URL).to_s
32
32
  response = http_client.get(uri)
33
33
  case response.code
34
34
  when "200"
@@ -39,13 +39,13 @@ module Ohai
39
39
  #
40
40
  module Ec2Metadata
41
41
 
42
- EC2_METADATA_ADDR = "169.254.169.254" unless defined?(EC2_METADATA_ADDR)
42
+ EC2_METADATA_ADDR = "169.254.169.254".freeze unless defined?(EC2_METADATA_ADDR)
43
43
  EC2_SUPPORTED_VERSIONS = %w{ 1.0 2007-01-19 2007-03-01 2007-08-29 2007-10-10 2007-12-15
44
44
  2008-02-01 2008-09-01 2009-04-04 2011-01-01 2011-05-01 2012-01-12
45
- 2014-02-25 2014-11-05 2015-10-20 2016-04-19 2016-06-30 2016-09-02 }
46
- EC2_ARRAY_VALUES = %w{security-groups local_ipv4s}
47
- EC2_ARRAY_DIR = %w{network/interfaces/macs}
48
- EC2_JSON_DIR = %w{iam}
45
+ 2014-02-25 2014-11-05 2015-10-20 2016-04-19 2016-06-30 2016-09-02 }.freeze
46
+ EC2_ARRAY_VALUES = %w{security-groups local_ipv4s}.freeze
47
+ EC2_ARRAY_DIR = %w{network/interfaces/macs}.freeze
48
+ EC2_JSON_DIR = %w{iam}.freeze
49
49
 
50
50
  def best_api_version
51
51
  @api_version ||= begin
@@ -193,9 +193,9 @@ module Ohai
193
193
  def expand_path(file_name)
194
194
  path = file_name.gsub(/\=.*$/, "/")
195
195
  # ignore "./" and "../"
196
- path.gsub(%r{/\.\.?(?:/|$)}, "/").
197
- sub(%r{^\.\.?(?:/|$)}, "").
198
- sub(%r{^$}, "/")
196
+ path.gsub(%r{/\.\.?(?:/|$)}, "/")
197
+ .sub(%r{^\.\.?(?:/|$)}, "")
198
+ .sub(%r{^$}, "/")
199
199
  end
200
200
 
201
201
  def metadata_key(key)
@@ -21,8 +21,8 @@ module Ohai
21
21
  module GCEMetadata
22
22
 
23
23
  # Trailing dot to host is added to avoid DNS search path
24
- GCE_METADATA_ADDR = "metadata.google.internal." unless defined?(GCE_METADATA_ADDR)
25
- GCE_METADATA_URL = "/computeMetadata/v1/?recursive=true" unless defined?(GCE_METADATA_URL)
24
+ GCE_METADATA_ADDR = "metadata.google.internal.".freeze unless defined?(GCE_METADATA_ADDR)
25
+ GCE_METADATA_URL = "/computeMetadata/v1/?recursive=true".freeze unless defined?(GCE_METADATA_URL)
26
26
 
27
27
  # fetch the meta content with a timeout and the required header
28
28
  def http_get(uri)
@@ -23,7 +23,7 @@ module Ohai
23
23
  FAMILIES = {
24
24
  "inet" => "default",
25
25
  "inet6" => "default_inet6",
26
- }
26
+ }.freeze
27
27
  end
28
28
  end
29
29
  end
@@ -20,8 +20,8 @@ module Ohai
20
20
  module Mixin
21
21
  module ScalewayMetadata
22
22
 
23
- SCALEWAY_METADATA_ADDR = "169.254.42.42" unless defined?(SCALEWAY_METADATA_ADDR)
24
- SCALEWAY_METADATA_URL = "/conf?format=json" unless defined?(SCALEWAY_METADATA_URL)
23
+ SCALEWAY_METADATA_ADDR = "169.254.42.42".freeze unless defined?(SCALEWAY_METADATA_ADDR)
24
+ SCALEWAY_METADATA_URL = "/conf?format=json".freeze unless defined?(SCALEWAY_METADATA_URL)
25
25
 
26
26
  # @return [Net::HTTP] net/http object without timeout set to 6
27
27
  def http_client
@@ -32,7 +32,7 @@ module Ohai
32
32
  #
33
33
  # @return [Hash]
34
34
  def fetch_metadata
35
- uri = "#{SCALEWAY_METADATA_URL}"
35
+ uri = (SCALEWAY_METADATA_URL).to_s
36
36
  response = http_client.get(uri)
37
37
  case response.code
38
38
  when "200"
@@ -22,7 +22,7 @@ require "uri"
22
22
 
23
23
  # https://softlayer.github.io/reference/services/SoftLayer_Resource_Metadata/
24
24
  module ::Ohai::Mixin::SoftlayerMetadata
25
- SOFTLAYER_API_QUERY_URL = "https://api.service.softlayer.com/rest/v3.1/SoftLayer_Resource_Metadata" unless defined?(SOFTLAYER_API_QUERY_URL)
25
+ SOFTLAYER_API_QUERY_URL = "https://api.service.softlayer.com/rest/v3.1/SoftLayer_Resource_Metadata".freeze unless defined?(SOFTLAYER_API_QUERY_URL)
26
26
 
27
27
  # fetch metadata items and build out hash of data
28
28
  #
@@ -24,7 +24,7 @@ class String
24
24
  # ActiveSupport::CoreExtensions::String::Inflections
25
25
  # @return [String]
26
26
  def wmi_underscore
27
- gsub(/::/, "/").gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2').
28
- gsub(/([a-z\d])([A-Z])/, '\1_\2').tr("-", "_").downcase
27
+ gsub(/::/, "/").gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
28
+ .gsub(/([a-z\d])([A-Z])/, '\1_\2').tr("-", "_").downcase
29
29
  end
30
30
  end
@@ -33,8 +33,8 @@ Ohai.plugin(:CPU) do
33
33
  cpu[:available] = 0
34
34
 
35
35
  cpudevs = shell_out("lsdev -Cc processor").stdout.lines
36
- #from http://www-01.ibm.com/software/passportadvantage/pvu_terminology_for_customers.html
37
- #on AIX number of cores and processors are considered same
36
+ # from http://www-01.ibm.com/software/passportadvantage/pvu_terminology_for_customers.html
37
+ # on AIX number of cores and processors are considered same
38
38
  cpu[:real] = cpu[:cores] = cpudevs.length
39
39
  cpudevs.each.with_index do |c, i|
40
40
  name, status, location = c.split
@@ -50,7 +50,7 @@ Ohai.plugin(:CPU) do
50
50
  if attrib == "type"
51
51
  cpu[index][:model_name] = value
52
52
  elsif attrib == "frequency"
53
- cpu[index][:mhz] = value.to_i / (1000 * 1000) #convert from hz to MHz
53
+ cpu[index][:mhz] = value.to_i / (1000 * 1000) # convert from hz to MHz
54
54
  else
55
55
  cpu[index][attrib] = value
56
56
  end
@@ -72,7 +72,7 @@ Ohai.plugin(:Filesystem) do
72
72
  df_hash = parse_df_or_mount shell_outs[:df_Pk]
73
73
 
74
74
  mount_hash.each do |key, hash|
75
- df_hash[key].merge!(hash) if df_hash.has_key?(key)
75
+ df_hash[key].merge!(hash) if df_hash.key?(key)
76
76
  end
77
77
 
78
78
  mount_hash.merge(df_hash)
@@ -38,7 +38,7 @@ Ohai.plugin(:Kernel) do
38
38
  # f1000000c0318000 20000 f1000000c0320000 17138 /usr/lib/drivers/random
39
39
  so.stdout.lines do |line|
40
40
  if line =~ /\s*([0-9a-f]+)\s+([0-9a-f]+)\s+([0-9a-f]+)\s+([0-9a-f]+)\s+([a-zA-Z0-9\/\._]+)/
41
- modules[$5] = { :text => { :address => $1, :size => $2 }, :data => { :address => $3, :size => $4 } }
41
+ modules[$5] = { text: { address: $1, size: $2 }, data: { address: $3, size: $4 } }
42
42
  end
43
43
  end
44
44
 
@@ -29,7 +29,7 @@ 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
32
+ swapinfo = shell_out("swap -s").stdout.split # returns swap info in 4K blocks
33
33
  memory[:swap]["total"] = "#{(swapinfo[2].to_i) * 4}kB"
34
34
  memory[:swap]["free"] = "#{(swapinfo[10].to_i) * 4}kB"
35
35
  end
@@ -120,7 +120,7 @@ Ohai.plugin(:Network) do
120
120
  macaddress $1.upcase unless shell_out("uname -W").stdout.to_i > 0
121
121
  end
122
122
  end
123
- end #ifconfig stdout
123
+ end # ifconfig stdout
124
124
 
125
125
  # Query routes information
126
126
  %w{inet inet6}.each do |family|
@@ -129,8 +129,8 @@ Ohai.plugin(:Network) do
129
129
  if line =~ /(\S+)\s+(\S+)\s+(\S+)\s+(\d+)\s+(\d+)\s+(\S+)/
130
130
  interface = $6
131
131
  iface[interface][:routes] = Array.new unless iface[interface][:routes]
132
- iface[interface][:routes] << Mash.new( :destination => $1, :family => family,
133
- :via => $2, :flags => $3)
132
+ iface[interface][:routes] << Mash.new( destination: $1, family: family,
133
+ via: $2, flags: $3)
134
134
  end
135
135
  end
136
136
  end
@@ -49,7 +49,7 @@ Ohai.plugin(:Virtualization) do
49
49
  end
50
50
 
51
51
  # detect from modules
52
- so = shell_out("#{Ohai.abs_path('/sbin/kldstat')}")
52
+ so = shell_out((Ohai.abs_path("/sbin/kldstat")).to_s)
53
53
  so.stdout.lines do |line|
54
54
  case line
55
55
  when /vboxdrv/
@@ -124,7 +124,7 @@ Ohai.plugin(:Cloud) do
124
124
 
125
125
  def get_gce_values
126
126
  public_ips = gce["instance"]["networkInterfaces"].collect do |interface|
127
- if interface.has_key?("accessConfigs")
127
+ if interface.key?("accessConfigs")
128
128
  interface["accessConfigs"].collect { |ac| ac["externalIp"] unless ac["externalIp"] == "" }
129
129
  end
130
130
  end.flatten.compact
@@ -71,7 +71,7 @@ Ohai.plugin(:Hardware) do
71
71
  drive[:name] = drive_entry["_name"]
72
72
  drive[:bsd_name] = drive_entry["bsd_name"]
73
73
  drive[:capacity] = drive_entry["size_in_bytes"]
74
- if drive_entry.has_key?("com.apple.corestorage.pv")
74
+ if drive_entry.key?("com.apple.corestorage.pv")
75
75
  drive[:drive_type] = drive_entry["com.apple.corestorage.pv"][0]["medium_type"]
76
76
  drive[:smart_status] = drive_entry["com.apple.corestorage.pv"][0]["smart_status"]
77
77
  drive[:partitions] = drive_entry["com.apple.corestorage.pv"].count
@@ -28,8 +28,8 @@ Ohai.plugin(:Network) do
28
28
  unless line_array[i].eql?("none")
29
29
 
30
30
  if line_array[i + 1] =~ /^\<([a-zA-Z\-\,]+)\>$/
31
- media[line_array[i]] = Hash.new unless media.has_key?(line_array[i])
32
- if media[line_array[i]].has_key?("options")
31
+ media[line_array[i]] = Hash.new unless media.key?(line_array[i])
32
+ if media[line_array[i]].key?("options")
33
33
  $1.split(",").each do |opt|
34
34
  media[line_array[i]]["options"] << opt unless media[line_array[i]]["options"].include?(opt)
35
35
  end
@@ -38,7 +38,7 @@ Ohai.plugin(:Network) do
38
38
  end
39
39
  else
40
40
  if line_array[i].eql?("autoselect")
41
- media["autoselect"] = Hash.new unless media.has_key?("autoselect")
41
+ media["autoselect"] = Hash.new unless media.key?("autoselect")
42
42
  media["autoselect"]["options"] = []
43
43
  end
44
44
  end
@@ -189,8 +189,8 @@ Ohai.plugin(:Network) do
189
189
  ifname = locate_interface(iface, $1, $2)
190
190
  next if iface[ifname].nil? # this shouldn't happen, but just in case
191
191
  net_counters[ifname] = Mash.new unless net_counters[ifname]
192
- net_counters[ifname] = { :rx => { :bytes => $5, :packets => $3, :errors => $4, :drop => 0, :overrun => 0, :frame => 0, :compressed => 0, :multicast => 0 },
193
- :tx => { :bytes => $8, :packets => $6, :errors => $7, :drop => 0, :overrun => 0, :collisions => $9, :carrier => 0, :compressed => 0 },
192
+ net_counters[ifname] = { rx: { bytes: $5, packets: $3, errors: $4, drop: 0, overrun: 0, frame: 0, compressed: 0, multicast: 0 },
193
+ tx: { bytes: $8, packets: $6, errors: $7, drop: 0, overrun: 0, collisions: $9, carrier: 0, compressed: 0 },
194
194
  }
195
195
  end
196
196
  end