ohai 16.3.2 → 16.5.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (120) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +6 -4
  3. data/bin/ohai +1 -1
  4. data/lib/ohai.rb +1 -1
  5. data/lib/ohai/application.rb +2 -2
  6. data/lib/ohai/config.rb +2 -3
  7. data/lib/ohai/dsl.rb +1 -1
  8. data/lib/ohai/dsl/plugin.rb +5 -5
  9. data/lib/ohai/dsl/plugin/versionvii.rb +1 -1
  10. data/lib/ohai/exception.rb +1 -1
  11. data/lib/ohai/hints.rb +1 -1
  12. data/lib/ohai/loader.rb +2 -3
  13. data/lib/ohai/log.rb +2 -2
  14. data/lib/ohai/mixin/azure_metadata.rb +1 -1
  15. data/lib/ohai/mixin/chef_utils_wiring.rb +39 -0
  16. data/lib/ohai/mixin/command.rb +3 -54
  17. data/lib/ohai/mixin/constant_helper.rb +1 -1
  18. data/lib/ohai/mixin/dmi_decode.rb +1 -1
  19. data/lib/ohai/mixin/do_metadata.rb +1 -1
  20. data/lib/ohai/mixin/ec2_metadata.rb +3 -3
  21. data/lib/ohai/mixin/http_helper.rb +1 -1
  22. data/lib/ohai/mixin/network_helper.rb +1 -1
  23. data/lib/ohai/mixin/os.rb +2 -2
  24. data/lib/ohai/mixin/scaleway_metadata.rb +1 -1
  25. data/lib/ohai/mixin/seconds_to_human.rb +1 -1
  26. data/lib/ohai/mixin/shell_out.rb +50 -0
  27. data/lib/ohai/mixin/softlayer_metadata.rb +1 -1
  28. data/lib/ohai/mixin/string.rb +1 -1
  29. data/lib/ohai/mixin/which.rb +38 -0
  30. data/lib/ohai/plugin_config.rb +1 -1
  31. data/lib/ohai/plugins/aix/kernel.rb +1 -1
  32. data/lib/ohai/plugins/aix/memory.rb +3 -3
  33. data/lib/ohai/plugins/aix/network.rb +3 -2
  34. data/lib/ohai/plugins/aix/platform.rb +1 -1
  35. data/lib/ohai/plugins/aix/uptime.rb +2 -2
  36. data/lib/ohai/plugins/aix/virtualization.rb +1 -1
  37. data/lib/ohai/plugins/azure.rb +1 -1
  38. data/lib/ohai/plugins/bsd/virtualization.rb +2 -2
  39. data/lib/ohai/plugins/cloud.rb +2 -2
  40. data/lib/ohai/plugins/command.rb +1 -1
  41. data/lib/ohai/plugins/cpu.rb +3 -3
  42. data/lib/ohai/plugins/darwin/memory.rb +1 -1
  43. data/lib/ohai/plugins/darwin/network.rb +1 -1
  44. data/lib/ohai/plugins/darwin/platform.rb +2 -2
  45. data/lib/ohai/plugins/darwin/virtualization.rb +1 -1
  46. data/lib/ohai/plugins/docker.rb +3 -3
  47. data/lib/ohai/plugins/dragonflybsd/platform.rb +2 -4
  48. data/lib/ohai/plugins/ec2.rb +4 -3
  49. data/lib/ohai/plugins/erlang.rb +1 -1
  50. data/lib/ohai/plugins/eucalyptus.rb +1 -1
  51. data/lib/ohai/plugins/filesystem.rb +8 -14
  52. data/lib/ohai/plugins/fips.rb +2 -6
  53. data/lib/ohai/plugins/freebsd/platform.rb +2 -4
  54. data/lib/ohai/plugins/gce.rb +1 -1
  55. data/lib/ohai/plugins/hostname.rb +5 -5
  56. data/lib/ohai/plugins/init_package.rb +1 -1
  57. data/lib/ohai/plugins/java.rb +1 -1
  58. data/lib/ohai/plugins/kernel.rb +3 -3
  59. data/lib/ohai/plugins/keys.rb +1 -1
  60. data/lib/ohai/plugins/languages.rb +1 -1
  61. data/lib/ohai/plugins/libvirt.rb +1 -1
  62. data/lib/ohai/plugins/linode.rb +1 -1
  63. data/lib/ohai/plugins/linux/block_device.rb +1 -1
  64. data/lib/ohai/plugins/linux/hostnamectl.rb +1 -2
  65. data/lib/ohai/plugins/linux/ipc.rb +1 -1
  66. data/lib/ohai/plugins/linux/lsb.rb +2 -3
  67. data/lib/ohai/plugins/linux/lspci.rb +1 -2
  68. data/lib/ohai/plugins/linux/machineid.rb +2 -2
  69. data/lib/ohai/plugins/linux/memory.rb +1 -1
  70. data/lib/ohai/plugins/linux/network.rb +21 -13
  71. data/lib/ohai/plugins/linux/platform.rb +15 -18
  72. data/lib/ohai/plugins/linux/virtualization.rb +1 -1
  73. data/lib/ohai/plugins/netbsd/network.rb +4 -8
  74. data/lib/ohai/plugins/netbsd/platform.rb +2 -4
  75. data/lib/ohai/plugins/network.rb +5 -4
  76. data/lib/ohai/plugins/ohai_time.rb +1 -1
  77. data/lib/ohai/plugins/openbsd/network.rb +4 -8
  78. data/lib/ohai/plugins/openbsd/platform.rb +2 -4
  79. data/lib/ohai/plugins/openstack.rb +3 -2
  80. data/lib/ohai/plugins/os.rb +1 -1
  81. data/lib/ohai/plugins/packages.rb +21 -1
  82. data/lib/ohai/plugins/passwd.rb +2 -1
  83. data/lib/ohai/plugins/perl.rb +1 -1
  84. data/lib/ohai/plugins/platform.rb +1 -1
  85. data/lib/ohai/plugins/powershell.rb +1 -1
  86. data/lib/ohai/plugins/ps.rb +1 -1
  87. data/lib/ohai/plugins/python.rb +1 -1
  88. data/lib/ohai/plugins/rackspace.rb +5 -4
  89. data/lib/ohai/plugins/root_group.rb +1 -1
  90. data/lib/ohai/plugins/ruby.rb +4 -15
  91. data/lib/ohai/plugins/scaleway.rb +1 -1
  92. data/lib/ohai/plugins/shard.rb +2 -2
  93. data/lib/ohai/plugins/shells.rb +1 -1
  94. data/lib/ohai/plugins/softlayer.rb +1 -1
  95. data/lib/ohai/plugins/solaris2/dmi.rb +2 -3
  96. data/lib/ohai/plugins/solaris2/memory.rb +1 -2
  97. data/lib/ohai/plugins/solaris2/network.rb +8 -14
  98. data/lib/ohai/plugins/solaris2/platform.rb +2 -3
  99. data/lib/ohai/plugins/solaris2/virtualization.rb +3 -6
  100. data/lib/ohai/plugins/ssh_host_key.rb +1 -1
  101. data/lib/ohai/plugins/uptime.rb +2 -2
  102. data/lib/ohai/plugins/virtualbox.rb +1 -1
  103. data/lib/ohai/plugins/vmware.rb +1 -1
  104. data/lib/ohai/plugins/windows/dmi.rb +2 -2
  105. data/lib/ohai/plugins/windows/drivers.rb +2 -2
  106. data/lib/ohai/plugins/windows/memory.rb +1 -1
  107. data/lib/ohai/plugins/windows/network.rb +3 -3
  108. data/lib/ohai/plugins/windows/platform.rb +1 -1
  109. data/lib/ohai/plugins/windows/system_enclosure.rb +1 -1
  110. data/lib/ohai/plugins/windows/virtualization.rb +2 -2
  111. data/lib/ohai/plugins/zpools.rb +1 -1
  112. data/lib/ohai/provides_map.rb +1 -1
  113. data/lib/ohai/runner.rb +2 -2
  114. data/lib/ohai/system.rb +2 -3
  115. data/lib/ohai/util/file_helper.rb +4 -37
  116. data/lib/ohai/util/ip_helper.rb +2 -2
  117. data/lib/ohai/util/win32.rb +1 -1
  118. data/lib/ohai/version.rb +3 -3
  119. data/ohai.gemspec +5 -7
  120. metadata +62 -73
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7be1477adf0e463ac6149e5e3bb02ea983b8ea39197a84baf414472071b9f829
4
- data.tar.gz: a928b3b5b11a6230bed0a235cd06210c1d98c1c08f347d85390270d02123cdd5
3
+ metadata.gz: bdf73dcd0e2c5c510ea32c222ba7d1af4518248bd7da383e830950fc6abae14f
4
+ data.tar.gz: 670279df5019b42e10a62ccfef09a1c14ad23037ec419da228c5dc15ec9f3a9e
5
5
  SHA512:
6
- metadata.gz: 4033840091985804ad19aab09e79c516e2811149f4165d3b904cb497743e552757bf32b0d32f574c2451866f8267bf451c12f8f993677b509c7ab71d0446c9dd
7
- data.tar.gz: 4b889129b7d4838410f936182615ef4b071ca4edd53fbfd8a374a349f39d6a2e6e842499167fd39aa5ae38b5bd7ebf2d64d25b6564c5fbf8dbbc4b16b40d91c3
6
+ metadata.gz: 573ca2d973a564ca588904e7230f5db4c3aa5a97bdbbcafc8a833830a5530348b9c824a172b0e72bfe672393213e19dd276cabbbe054968a41dabe905a84f523
7
+ data.tar.gz: ee0d263f7213fae70cb7d6a9230103cc5112d54b48669b1b17276dd873117e420222c418646ec5283c93be268083ad09103df0d62f3ffac9215173eb33979ca3
data/Gemfile CHANGED
@@ -5,18 +5,20 @@ 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 "ipaddr_extensions"
8
9
  gem "rake", ">= 10.1.0"
10
+ gem "rspec-collection_matchers", "~> 1.0"
9
11
  gem "rspec-core", "~> 3.0"
10
12
  gem "rspec-expectations", "~> 3.0"
11
13
  gem "rspec-mocks", "~> 3.0"
12
- gem "rspec-collection_matchers", "~> 1.0"
13
- gem "ipaddr_extensions"
14
+ gem "rubocop-performance", "1.8.1"
15
+ gem "rubocop-rspec"
14
16
  end
15
17
 
16
18
  group :docs do
17
- gem "yard"
18
- gem "redcarpet"
19
19
  gem "github-markup"
20
+ gem "redcarpet"
21
+ gem "yard"
20
22
  end
21
23
 
22
24
  group :debug do
data/bin/ohai CHANGED
@@ -18,7 +18,7 @@
18
18
  #
19
19
 
20
20
  # if we're in a source code checkout, we want to run the code from that.
21
- $:.unshift File.expand_path("../../lib", __FILE__)
21
+ $:.unshift File.expand_path("../lib", __dir__)
22
22
  require "ohai/application"
23
23
 
24
24
  Ohai::Application.new.run
@@ -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");
@@ -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
@@ -1,7 +1,7 @@
1
1
  #
2
2
  # Author:: Adam Jacob (<adam@chef.io>)
3
3
  # Author:: Claire McQuin (<claire@chef.io>)
4
- # Copyright:: Copyright (c) 2008-2016 Chef Software, Inc.
4
+ # Copyright:: Copyright (c) Chef Software Inc.
5
5
  # License:: Apache License, Version 2.0
6
6
  #
7
7
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -27,14 +27,13 @@ module Ohai
27
27
  # Reopens ChefConfig::Config to add Ohai configuration settings.
28
28
  # see: https://github.com/chef/chef/blob/master/lib/chef/config.rb
29
29
  class Config
30
-
31
30
  config_context :ohai do
32
31
  default :disabled_plugins, []
33
32
  default :hints_path, [ ChefConfig::Config.platform_specific_path("/etc/chef/ohai/hints") ]
34
33
  default :log_level, :auto
35
34
  default :log_location, STDERR
36
35
  default :plugin, ( Ohai::PluginConfig.new { |h, k| h[k] = Ohai::PluginConfig.new } )
37
- default :plugin_path, [ File.expand_path(File.join(File.dirname(__FILE__), "plugins")), ChefConfig::Config.platform_specific_path("/etc/chef/ohai/plugins") ]
36
+ default :plugin_path, [ File.expand_path(File.join(__dir__, "plugins")), ChefConfig::Config.platform_specific_path("/etc/chef/ohai/plugins") ]
38
37
  default :critical_plugins, []
39
38
  # causes all optional plugins to be run.
40
39
  default :run_all_plugins, false
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Serdar Sutay (<serdar@chef.io>)
3
- # Copyright:: Copyright (c) 2013-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");
@@ -1,7 +1,7 @@
1
1
  #
2
2
  # Author:: Adam Jacob (<adam@chef.io>)
3
3
  # Author:: Claire McQuin (<claire@chef.io>)
4
- # Copyright:: Copyright (c) 2008-2016 Chef Software, Inc.
4
+ # Copyright:: Copyright (c) Chef Software Inc.
5
5
  # License:: Apache License, Version 2.0
6
6
  #
7
7
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -19,10 +19,10 @@
19
19
  #
20
20
 
21
21
  require_relative "../mixin/os"
22
- require_relative "../mixin/command"
22
+ require_relative "../mixin/shell_out"
23
23
  require_relative "../mixin/seconds_to_human"
24
+ require_relative "../mixin/which"
24
25
  require_relative "../hints"
25
- require_relative "../util/file_helper"
26
26
 
27
27
  module Ohai
28
28
 
@@ -83,9 +83,9 @@ module Ohai
83
83
  class Plugin
84
84
 
85
85
  include Ohai::Mixin::OS
86
- include Ohai::Mixin::Command
86
+ include Ohai::Mixin::ShellOut
87
87
  include Ohai::Mixin::SecondsToHuman
88
- include Ohai::Util::FileHelper
88
+ include Ohai::Mixin::Which
89
89
 
90
90
  attr_reader :data
91
91
  attr_reader :failed
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Serdar Sutay (<serdar@chef.io>)
3
- # Copyright:: Copyright (c) 2013-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");
@@ -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");
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Serdar Sutay (<serdar@chef.io>)
3
- # Copyright:: Copyright (c) 2013-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");
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Claire McQuin (<claire@chef.io>)
3
- # Copyright:: Copyright (c) 2013-2019, 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");
@@ -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
 
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Adam Jacob (<adam@chef.io>)
3
- # Copyright:: Copyright (c) 2008-2017, 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");
@@ -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
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Tim Smith (<tsmith@chef.io>)
3
- # Copyright:: 2017-2020 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");
@@ -0,0 +1,39 @@
1
+ #
2
+ # Copyright:: Copyright (c) Chef Software Inc.
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ require_relative "../config"
19
+
20
+ module Ohai
21
+ module Mixin
22
+ # Common Dependency Injection wiring for ChefUtils-related modules
23
+ module ChefUtilsWiring
24
+ private
25
+
26
+ def __config
27
+ Ohai::Config
28
+ end
29
+
30
+ def __log
31
+ logger
32
+ end
33
+
34
+ def __transport_connection
35
+ # Chef.run_context&.transport_connection
36
+ end
37
+ end
38
+ end
39
+ end
@@ -1,54 +1,3 @@
1
- #
2
- # Author:: Adam Jacob (<adam@chef.io>)
3
- # Author:: Tim Smith (<tsmith@chef.io>)
4
- # Copyright:: Copyright (c) 2008-2016 Chef Software, Inc.
5
- # License:: Apache License, Version 2.0
6
- #
7
- # Licensed under the Apache License, Version 2.0 (the "License");
8
- # you may not use this file except in compliance with the License.
9
- # You may obtain a copy of the License at
10
- #
11
- # http://www.apache.org/licenses/LICENSE-2.0
12
- #
13
- # Unless required by applicable law or agreed to in writing, software
14
- # distributed under the License is distributed on an "AS IS" BASIS,
15
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- # See the License for the specific language governing permissions and
17
- # limitations under the License.
18
- #
19
-
20
- require_relative "../exception"
21
- require_relative "../log"
22
- require "mixlib/shellout" unless defined?(Mixlib::ShellOut::DEFAULT_READ_TIMEOUT)
23
-
24
- module Ohai
25
- module Mixin
26
- module Command
27
- # DISCLAIMER: Logging only works in the context of a plugin!!
28
- # accept a command and any of the mixlib-shellout options
29
- def shell_out(cmd, **options)
30
- options = options.dup
31
- # unless specified by the caller timeout after configured timeout (default 30 seconds)
32
- options[:timeout] ||= Ohai::Config.ohai[:shellout_timeout]
33
- unless RUBY_PLATFORM.match?(/mswin|mingw32|windows/)
34
- options[:env] = options.key?(:env) ? options[:env].dup : {}
35
- options[:env]["PATH"] ||= ((ENV["PATH"] || "").split(":") + %w{/usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin}).join(":")
36
- end
37
- so = Mixlib::ShellOut.new(cmd, options)
38
- begin
39
- so.run_command
40
- logger.trace("Plugin #{name}: ran '#{cmd}' and returned #{so.exitstatus}")
41
- so
42
- rescue Errno::ENOENT => e
43
- logger.trace("Plugin #{name}: ran '#{cmd}' and failed #{e.inspect}")
44
- raise Ohai::Exceptions::Exec, e
45
- rescue Mixlib::ShellOut::CommandTimeout => e
46
- logger.trace("Plugin #{name}: ran '#{cmd}' and timed out after #{options[:timeout]} seconds")
47
- raise Ohai::Exceptions::Exec, e
48
- end
49
- end
50
-
51
- module_function :shell_out
52
- end
53
- end
54
- end
1
+ $stderr.puts "WARN: Ohai::Mixin::Command is deprecated, please use Ohai::Mixin::ShellOut or remove if the reference is unnecessary"
2
+ require_relative "shell_out"
3
+ Ohai::Mixin::Command = Ohai::Mixin::ShellOut unless defined?(Ohai::Mixin::Command)
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Serdar Sutay (<serdar@chef.io>)
3
- # Copyright:: Copyright (c) 2014-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");
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Tim Smith <tsmith@chef.io>
3
- # Copyright:: Copyright (c) 2015-2018 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");
@@ -28,7 +28,7 @@ module Ohai
28
28
  end
29
29
 
30
30
  def fetch_metadata
31
- uri = (DO_METADATA_URL).to_s
31
+ uri = DO_METADATA_URL.to_s
32
32
  response = http_client.get(uri)
33
33
  case response.code
34
34
  when "200"
@@ -2,7 +2,7 @@
2
2
  # Author:: Tim Dysinger (<tim@dysinger.net>)
3
3
  # Author:: Benjamin Black (<bb@chef.io>)
4
4
  # Author:: Christopher Brown (<cb@chef.io>)
5
- # Copyright:: 2009-2017 Chef Software, Inc.
5
+ # Copyright:: Copyright (c) Chef Software Inc.
6
6
  # License:: Apache License, Version 2.0
7
7
  #
8
8
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -142,7 +142,7 @@ module Ohai
142
142
  key = expand_path(o)
143
143
  if key[-1..-1] != "/"
144
144
  retr_meta = metadata_get("#{id}#{key}", api_version)
145
- metadata[metadata_key(key)] = retr_meta ? retr_meta : ""
145
+ metadata[metadata_key(key)] = retr_meta || ""
146
146
  elsif not key.eql?("/")
147
147
  metadata[key[0..-2]] = fetch_dir_metadata("#{id}#{key}", api_version)
148
148
  end
@@ -159,7 +159,7 @@ module Ohai
159
159
  key = expand_path(o)
160
160
  if key[-1..-1] != "/"
161
161
  retr_meta = metadata_get("#{id}#{key}", api_version)
162
- data = retr_meta ? retr_meta : ""
162
+ data = retr_meta || ""
163
163
  json = String(data)
164
164
  parser = FFI_Yajl::Parser.new
165
165
  metadata[metadata_key(key)] = parser.parse(json)
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright:: 2017, Chef Software, Inc.
2
+ # Copyright:: Copyright (c) Chef Software Inc.
3
3
  # License:: Apache License, Version 2.0
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Serdar Sutay (<serdar@chef.io>)
3
- # Copyright:: Copyright (c) 2014-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");
@@ -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");
@@ -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
@@ -32,7 +32,7 @@ module Ohai
32
32
  #
33
33
  # @return [Hash]
34
34
  def fetch_metadata
35
- uri = (SCALEWAY_METADATA_URL).to_s
35
+ uri = SCALEWAY_METADATA_URL.to_s
36
36
  response = http_client.get(uri)
37
37
  case response.code
38
38
  when "200"
@@ -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");
@@ -0,0 +1,50 @@
1
+ #
2
+ # Author:: Adam Jacob (<adam@chef.io>)
3
+ # Author:: Tim Smith (<tsmith@chef.io>)
4
+ # Copyright:: Copyright (c) Chef Software Inc.
5
+ # License:: Apache License, Version 2.0
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+ #
19
+
20
+ require_relative "../exception"
21
+ require_relative "../log"
22
+
23
+ require "mixlib/shellout/helper" unless defined?(Mixlib::ShellOut::Helper)
24
+ require_relative "chef_utils_wiring" unless defined?(Ohai::Mixin::ChefUtilsWiring)
25
+
26
+ module Ohai
27
+ module Mixin
28
+ module ShellOut
29
+ include Mixlib::ShellOut::Helper
30
+ include Ohai::Mixin::ChefUtilsWiring
31
+
32
+ def shell_out(cmd, **options)
33
+ options = options.dup
34
+ # unless specified by the caller timeout after configured timeout (default 30 seconds)
35
+ options[:timeout] ||= Ohai::Config.ohai[:shellout_timeout]
36
+ begin
37
+ so = super(cmd, **options)
38
+ logger.trace("Plugin #{name}: ran '#{cmd}' and returned #{so.exitstatus}")
39
+ so
40
+ rescue Errno::ENOENT => e
41
+ logger.trace("Plugin #{name}: ran '#{cmd}' and failed #{e.inspect}")
42
+ raise Ohai::Exceptions::Exec, e
43
+ rescue Mixlib::ShellOut::CommandTimeout => e
44
+ logger.trace("Plugin #{name}: ran '#{cmd}' and timed out after #{options[:timeout]} seconds")
45
+ raise Ohai::Exceptions::Exec, e
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end