ohai 14.15.0 → 15.0.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (192) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -1
  3. data/lib/ohai/application.rb +0 -4
  4. data/lib/ohai/common/dmi.rb +43 -43
  5. data/lib/ohai/config.rb +1 -1
  6. data/lib/ohai/loader.rb +32 -47
  7. data/lib/ohai/mixin/dmi_decode.rb +29 -32
  8. data/lib/ohai/mixin/os.rb +0 -2
  9. data/lib/ohai/mixin/softlayer_metadata.rb +5 -5
  10. data/lib/ohai/plugins/aix/virtualization.rb +4 -4
  11. data/lib/ohai/plugins/bsd/virtualization.rb +10 -12
  12. data/lib/ohai/plugins/c.rb +0 -20
  13. data/lib/ohai/plugins/elixir.rb +13 -13
  14. data/lib/ohai/plugins/filesystem.rb +10 -10
  15. data/lib/ohai/plugins/gce.rb +42 -8
  16. data/lib/ohai/plugins/go.rb +11 -11
  17. data/lib/ohai/plugins/groovy.rb +12 -12
  18. data/lib/ohai/plugins/hostname.rb +9 -2
  19. data/lib/ohai/plugins/linux/fips.rb +2 -9
  20. data/lib/ohai/plugins/linux/memory.rb +5 -0
  21. data/lib/ohai/plugins/linux/network.rb +1 -1
  22. data/lib/ohai/plugins/linux/platform.rb +84 -83
  23. data/lib/ohai/plugins/linux/systemd_paths.rb +0 -3
  24. data/lib/ohai/plugins/linux/virtualization.rb +10 -20
  25. data/lib/ohai/plugins/lua.rb +13 -13
  26. data/lib/ohai/plugins/mono.rb +23 -23
  27. data/lib/ohai/plugins/nodejs.rb +13 -13
  28. data/lib/ohai/plugins/openstack.rb +1 -1
  29. data/lib/ohai/plugins/packages.rb +1 -28
  30. data/lib/ohai/plugins/perl.rb +17 -17
  31. data/lib/ohai/plugins/php.rb +22 -22
  32. data/lib/ohai/plugins/powershell.rb +30 -30
  33. data/lib/ohai/plugins/ps.rb +1 -1
  34. data/lib/ohai/plugins/python.rb +15 -15
  35. data/lib/ohai/plugins/rust.rb +11 -11
  36. data/lib/ohai/plugins/solaris2/dmi.rb +48 -48
  37. data/lib/ohai/plugins/solaris2/virtualization.rb +8 -10
  38. data/lib/ohai/plugins/virtualbox.rb +21 -21
  39. data/lib/ohai/plugins/windows/filesystem.rb +2 -2
  40. data/lib/ohai/plugins/windows/fips.rb +2 -21
  41. data/lib/ohai/plugins/windows/virtualization.rb +9 -35
  42. data/lib/ohai/runner.rb +2 -2
  43. data/lib/ohai/system.rb +0 -17
  44. data/lib/ohai/version.rb +1 -1
  45. data/ohai.gemspec +2 -2
  46. data/spec/data/plugins/rpmquery.output +0 -2
  47. data/spec/functional/application_spec.rb +1 -1
  48. data/spec/functional/loader_spec.rb +2 -2
  49. data/spec/functional/plugins/powershell_spec.rb +2 -2
  50. data/spec/functional/plugins/root_group_spec.rb +1 -1
  51. data/spec/functional/plugins/windows/uptime_spec.rb +2 -2
  52. data/spec/ohai_spec.rb +1 -1
  53. data/spec/unit/application_spec.rb +1 -1
  54. data/spec/unit/config_spec.rb +1 -1
  55. data/spec/unit/dsl/plugin_spec.rb +1 -1
  56. data/spec/unit/hints_spec.rb +2 -2
  57. data/spec/unit/loader_spec.rb +12 -12
  58. data/spec/unit/mixin/azure_metadata_spec.rb +1 -1
  59. data/spec/unit/mixin/command_spec.rb +1 -1
  60. data/spec/unit/mixin/dmi_decode.rb +68 -0
  61. data/spec/unit/mixin/ec2_metadata_spec.rb +1 -1
  62. data/spec/unit/mixin/softlayer_metadata_spec.rb +1 -1
  63. data/spec/unit/plugin_config_spec.rb +1 -1
  64. data/spec/unit/plugins/abort_spec.rb +9 -9
  65. data/spec/unit/plugins/aix/cpu_spec.rb +4 -4
  66. data/spec/unit/plugins/aix/filesystem_spec.rb +5 -5
  67. data/spec/unit/plugins/aix/hostname_spec.rb +1 -1
  68. data/spec/unit/plugins/aix/kernel_spec.rb +1 -1
  69. data/spec/unit/plugins/aix/memory_spec.rb +1 -1
  70. data/spec/unit/plugins/aix/network_spec.rb +6 -6
  71. data/spec/unit/plugins/aix/platform_spec.rb +1 -1
  72. data/spec/unit/plugins/aix/uptime_spec.rb +1 -1
  73. data/spec/unit/plugins/aix/virtualization_spec.rb +2 -2
  74. data/spec/unit/plugins/azure_spec.rb +1 -1
  75. data/spec/unit/plugins/bsd/filesystem_spec.rb +4 -4
  76. data/spec/unit/plugins/bsd/virtualization_spec.rb +3 -3
  77. data/spec/unit/plugins/c_spec.rb +1 -53
  78. data/spec/unit/plugins/chef_spec.rb +1 -1
  79. data/spec/unit/plugins/cloud_spec.rb +1 -1
  80. data/spec/unit/plugins/darwin/cpu_spec.rb +2 -2
  81. data/spec/unit/plugins/darwin/filesystem_spec.rb +5 -5
  82. data/spec/unit/plugins/darwin/hardware_spec.rb +2 -2
  83. data/spec/unit/plugins/darwin/hardware_system_profiler_output.rb +3 -3
  84. data/spec/unit/plugins/darwin/hostname_spec.rb +1 -1
  85. data/spec/unit/plugins/darwin/kernel_spec.rb +1 -1
  86. data/spec/unit/plugins/darwin/memory_spec.rb +1 -1
  87. data/spec/unit/plugins/darwin/network_spec.rb +1 -1
  88. data/spec/unit/plugins/darwin/platform_spec.rb +1 -1
  89. data/spec/unit/plugins/darwin/virtualization_spec.rb +1 -1
  90. data/spec/unit/plugins/dmi_spec.rb +1 -1
  91. data/spec/unit/plugins/docker_spec.rb +1 -1
  92. data/spec/unit/plugins/ec2_spec.rb +1 -1
  93. data/spec/unit/plugins/elixir_spec.rb +1 -1
  94. data/spec/unit/plugins/erlang_spec.rb +1 -1
  95. data/spec/unit/plugins/eucalyptus_spec.rb +1 -1
  96. data/spec/unit/plugins/fail_spec.rb +28 -28
  97. data/spec/unit/plugins/freebsd/cpu_spec.rb +1 -1
  98. data/spec/unit/plugins/freebsd/hostname_spec.rb +1 -1
  99. data/spec/unit/plugins/freebsd/kernel_spec.rb +1 -1
  100. data/spec/unit/plugins/freebsd/platform_spec.rb +1 -1
  101. data/spec/unit/plugins/gce_spec.rb +1 -1
  102. data/spec/unit/plugins/go_spec.rb +1 -1
  103. data/spec/unit/plugins/groovy_spec.rb +1 -1
  104. data/spec/unit/plugins/haskell_spec.rb +1 -1
  105. data/spec/unit/plugins/hostname_spec.rb +68 -1
  106. data/spec/unit/plugins/init_package_spec.rb +1 -1
  107. data/spec/unit/plugins/java_spec.rb +1 -1
  108. data/spec/unit/plugins/joyent_spec.rb +3 -3
  109. data/spec/unit/plugins/kernel_spec.rb +1 -1
  110. data/spec/unit/plugins/linode_spec.rb +1 -1
  111. data/spec/unit/plugins/linux/block_device_spec.rb +1 -1
  112. data/spec/unit/plugins/linux/cpu_spec.rb +6 -6
  113. data/spec/unit/plugins/linux/filesystem_spec.rb +21 -21
  114. data/spec/unit/plugins/linux/fips_spec.rb +13 -45
  115. data/spec/unit/plugins/linux/hostname_spec.rb +1 -1
  116. data/spec/unit/plugins/linux/hostnamectl_spec.rb +2 -2
  117. data/spec/unit/plugins/linux/kernel_spec.rb +8 -8
  118. data/spec/unit/plugins/linux/lsb_spec.rb +3 -3
  119. data/spec/unit/plugins/linux/lspci_spec.rb +2 -2
  120. data/spec/unit/plugins/linux/machineid_spec.rb +1 -1
  121. data/spec/unit/plugins/linux/mdadm_spec.rb +2 -2
  122. data/spec/unit/plugins/linux/memory_spec.rb +26 -1
  123. data/spec/unit/plugins/linux/network_spec.rb +37 -37
  124. data/spec/unit/plugins/linux/platform_spec.rb +580 -837
  125. data/spec/unit/plugins/linux/sessions_spec.rb +2 -2
  126. data/spec/unit/plugins/linux/systemd_paths_spec.rb +1 -1
  127. data/spec/unit/plugins/linux/uptime_spec.rb +1 -1
  128. data/spec/unit/plugins/linux/virtualization_spec.rb +28 -227
  129. data/spec/unit/plugins/lua_spec.rb +1 -1
  130. data/spec/unit/plugins/mono_spec.rb +2 -2
  131. data/spec/unit/plugins/netbsd/hostname_spec.rb +1 -1
  132. data/spec/unit/plugins/netbsd/kernel_spec.rb +1 -1
  133. data/spec/unit/plugins/netbsd/platform_spec.rb +1 -1
  134. data/spec/unit/plugins/network_spec.rb +11 -11
  135. data/spec/unit/plugins/nodejs_spec.rb +1 -1
  136. data/spec/unit/plugins/ohai_spec.rb +1 -1
  137. data/spec/unit/plugins/ohai_time_spec.rb +1 -1
  138. data/spec/unit/plugins/openbsd/hostname_spec.rb +1 -1
  139. data/spec/unit/plugins/openbsd/kernel_spec.rb +1 -1
  140. data/spec/unit/plugins/openbsd/platform_spec.rb +1 -1
  141. data/spec/unit/plugins/openstack_spec.rb +8 -4
  142. data/spec/unit/plugins/os_spec.rb +1 -1
  143. data/spec/unit/plugins/packages_spec.rb +1 -21
  144. data/spec/unit/plugins/passwd_spec.rb +1 -1
  145. data/spec/unit/plugins/perl_spec.rb +1 -1
  146. data/spec/unit/plugins/php_spec.rb +6 -6
  147. data/spec/unit/plugins/platform_spec.rb +1 -1
  148. data/spec/unit/plugins/powershell_spec.rb +3 -3
  149. data/spec/unit/plugins/python_spec.rb +1 -1
  150. data/spec/unit/plugins/rackspace_spec.rb +2 -2
  151. data/spec/unit/plugins/root_group_spec.rb +1 -11
  152. data/spec/unit/plugins/ruby_spec.rb +1 -1
  153. data/spec/unit/plugins/rust_spec.rb +1 -1
  154. data/spec/unit/plugins/scala_spec.rb +1 -1
  155. data/spec/unit/plugins/scsi_spec.rb +2 -2
  156. data/spec/unit/plugins/shard_spec.rb +1 -1
  157. data/spec/unit/plugins/shells_spec.rb +1 -1
  158. data/spec/unit/plugins/softlayer_spec.rb +1 -1
  159. data/spec/unit/plugins/solaris2/cpu_spec.rb +3 -3
  160. data/spec/unit/plugins/solaris2/dmi_spec.rb +1 -1
  161. data/spec/unit/plugins/solaris2/filesystem.rb +4 -4
  162. data/spec/unit/plugins/solaris2/hostname_spec.rb +1 -1
  163. data/spec/unit/plugins/solaris2/kernel_spec.rb +1 -1
  164. data/spec/unit/plugins/solaris2/memory_spec.rb +1 -1
  165. data/spec/unit/plugins/solaris2/network_spec.rb +6 -6
  166. data/spec/unit/plugins/solaris2/platform_spec.rb +3 -3
  167. data/spec/unit/plugins/solaris2/virtualization_spec.rb +41 -69
  168. data/spec/unit/plugins/ssh_host_keys_spec.rb +3 -3
  169. data/spec/unit/plugins/sysconf_spec.rb +2 -2
  170. data/spec/unit/plugins/timezone_spec.rb +1 -1
  171. data/spec/unit/plugins/virtualbox_spec.rb +1 -1
  172. data/spec/unit/plugins/vmware_spec.rb +1 -1
  173. data/spec/unit/plugins/windows/cpu_spec.rb +1 -2
  174. data/spec/unit/plugins/windows/filesystem_spec.rb +2 -2
  175. data/spec/unit/plugins/windows/fips_spec.rb +17 -77
  176. data/spec/unit/plugins/windows/kernel_spec.rb +1 -1
  177. data/spec/unit/plugins/windows/memory_spec.rb +2 -2
  178. data/spec/unit/plugins/windows/network_spec.rb +1 -1
  179. data/spec/unit/plugins/windows/system_enclosure_spec.rb +1 -1
  180. data/spec/unit/plugins/windows/uptime_spec.rb +1 -1
  181. data/spec/unit/plugins/windows/virtualization_spec.rb +20 -238
  182. data/spec/unit/plugins/zpools_spec.rb +7 -7
  183. data/spec/unit/provides_map_spec.rb +1 -1
  184. data/spec/unit/runner_spec.rb +1 -1
  185. data/spec/unit/system_spec.rb +10 -77
  186. data/spec/unit/util/file_helper_spec.rb +1 -1
  187. data/spec/unit/util/ip_helper_spec.rb +1 -1
  188. metadata +6 -9
  189. data/lib/ohai/plugins/darwin/system_profiler.rb +0 -72
  190. data/lib/ohai/util/win32/group_helper.rb +0 -76
  191. data/spec/unit/plugins/darwin/system_profiler_output.rb +0 -79524
  192. data/spec/unit/plugins/darwin/system_profiler_spec.rb +0 -40
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 716bc9f09520397d1a9c23d454c87e3cd73282068c7511a48fdce153a5568b49
4
- data.tar.gz: 1a270f33e5d872b1a276bacfdf293bdf1680ae1d06f955d790dc45393b1a17e6
3
+ metadata.gz: b2b536c237b18f6b940c6a9082745d73d0c092e45f250129d4648e1b13834d0f
4
+ data.tar.gz: e2efa2a548dd3270584593fc5bc056043cae6a85902c6d0dfbc6a3b27cf78934
5
5
  SHA512:
6
- metadata.gz: 2c2953d87edfba4e8deb71a78a434df9fcbee133107e2b03e4f98469f973aebc43be38d316615fce69b2eeb5bce37667661643d163b0741a1499ad2cf6390689
7
- data.tar.gz: 4f4723b3380734ff87fa6d03e735b7be9a215f0cb8f2fe9ab70dc127b24a20c1bb4c1212c7ce07a4c06323e6d37659df3073da155d0583bccf44338d9c373889
6
+ metadata.gz: '0038af185c2ba323b41cef83792e77072efb95b02ef3e506814712504ed7e90b518e576a515ace49455b604f602f9ebdf54746899ebd233a0b485d604b63d941'
7
+ data.tar.gz: 2f507deee0668f4f9aa0eb06b1616535e3abf1a9101097d89fb485763e804b8a61470249bc905aa95c2dd706fc7b11f0e4dbd7cf2760bb49aae3b9e3bf2c90b5
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", "=0.11.2"
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"
@@ -101,10 +101,6 @@ class Ohai::Application
101
101
  #
102
102
  # @return void
103
103
  def run_application
104
- # Always switch to a readable directory. Keeps subsequent Dir.chdir() {}
105
- # from failing due to permissions when launched as a less privileged user.
106
- Dir.chdir("/")
107
-
108
104
  config[:invoked_from_cli] = true
109
105
  config[:logger] = Ohai::Log.with_child
110
106
  ohai = Ohai::System.new(config)
@@ -25,49 +25,49 @@ module Ohai
25
25
  # 128-255 are 'oem_data_[id]'
26
26
  # Everything else is 'unknown'
27
27
  ID_TO_DESCRIPTION = {
28
- 0 => "bios",
29
- 1 => "system",
30
- 2 => "base_board",
31
- 3 => "chassis",
32
- 4 => "processor",
33
- 5 => "memory_controller",
34
- 6 => "memory_module",
35
- 7 => "cache",
36
- 8 => "port_connector",
37
- 9 => "system_slots",
38
- 10 => "on_board_devices",
39
- 11 => "oem_strings",
40
- 12 => "system_configuration_options",
41
- 13 => "bios_language",
42
- 14 => "group_associations",
43
- 15 => "system_event_log",
44
- 16 => "physical_memory_array",
45
- 17 => "memory_device",
46
- 18 => "32_bit_memory_error",
47
- 19 => "memory_array_mapped_address",
48
- 20 => "memory_device_mapped_address",
49
- 21 => "built_in_pointing_device",
50
- 22 => "portable_battery",
51
- 23 => "system_reset",
52
- 24 => "hardware_security",
53
- 25 => "system_power_controls",
54
- 26 => "voltage_probe",
55
- 27 => "cooling_device",
56
- 28 => "temperature_probe",
57
- 29 => "electrical_current_probe",
58
- 30 => "out_of_band_remote_access",
59
- 31 => "boot_integrity_services",
60
- 32 => "system_boot",
61
- 33 => "64_bit_memory_error",
62
- 34 => "management_device",
63
- 35 => "management_device_component",
64
- 36 => "management_device_threshold_data",
65
- 37 => "memory_channel",
66
- 38 => "ipmi_device",
67
- 39 => "power_supply",
68
- 40 => "additional_information",
69
- 41 => "onboard_devices_extended_information",
70
- 42 => "management_controller_host_interfaces",
28
+ 0 => "bios",
29
+ 1 => "system",
30
+ 2 => "base_board",
31
+ 3 => "chassis",
32
+ 4 => "processor",
33
+ 5 => "memory_controller",
34
+ 6 => "memory_module",
35
+ 7 => "cache",
36
+ 8 => "port_connector",
37
+ 9 => "system_slots",
38
+ 10 => "on_board_devices",
39
+ 11 => "oem_strings",
40
+ 12 => "system_configuration_options",
41
+ 13 => "bios_language",
42
+ 14 => "group_associations",
43
+ 15 => "system_event_log",
44
+ 16 => "physical_memory_array",
45
+ 17 => "memory_device",
46
+ 18 => "32_bit_memory_error",
47
+ 19 => "memory_array_mapped_address",
48
+ 20 => "memory_device_mapped_address",
49
+ 21 => "built_in_pointing_device",
50
+ 22 => "portable_battery",
51
+ 23 => "system_reset",
52
+ 24 => "hardware_security",
53
+ 25 => "system_power_controls",
54
+ 26 => "voltage_probe",
55
+ 27 => "cooling_device",
56
+ 28 => "temperature_probe",
57
+ 29 => "electrical_current_probe",
58
+ 30 => "out_of_band_remote_access",
59
+ 31 => "boot_integrity_services",
60
+ 32 => "system_boot",
61
+ 33 => "64_bit_memory_error",
62
+ 34 => "management_device",
63
+ 35 => "management_device_component",
64
+ 36 => "management_device_threshold_data",
65
+ 37 => "memory_channel",
66
+ 38 => "ipmi_device",
67
+ 39 => "power_supply",
68
+ 40 => "additional_information",
69
+ 41 => "onboard_devices_extended_information",
70
+ 42 => "management_controller_host_interfaces",
71
71
  126 => "disabled_entries",
72
72
  127 => "end_of_table_marker",
73
73
  }.freeze
@@ -39,7 +39,7 @@ module Ohai
39
39
  # causes all optional plugins to be run.
40
40
  default :run_all_plugins, false
41
41
  # optional plugins are the set of plugins that are marked optional but you wish to run.
42
- default(:optional_plugins, []).writes_value { |arr| arr.map(&:to_sym) }
42
+ default :optional_plugins, []
43
43
  default :shellout_timeout, 30
44
44
  end
45
45
  end
@@ -24,51 +24,34 @@ require "pathname"
24
24
 
25
25
  module Ohai
26
26
 
27
- # Ohai plugin loader. Finds all the plugins in your
28
- # `Ohai.config[:plugin_path]` (supports a single or multiple path setting
27
+ # Ohai plugin loader. Finds all the plugins specified in the
28
+ # Ohai.config :plugin_path (supports a single or multiple path setting
29
29
  # here), evaluates them and returns plugin objects.
30
30
  class Loader
31
-
32
- # Simple struct like objects to track the path of a plugin and the root
33
- # directory of plugins in which we found it. We don't care about the
34
- # relative paths of v7 plugins, but in v6 plugins, dependencies are
35
- # specified by calling `require_plugin` with a relative path. To manage
36
- # this, we track the path and root of each file as we discover them so we
37
- # can feed this into the v6 "dependency solver" as we load them.
38
- PluginFile = Struct.new(:path, :plugin_root) do
39
-
40
- # Finds all the *.rb files under the configured paths in :plugin_path
41
- def self.find_all_in(plugin_dir)
42
- unless Dir.exist?(plugin_dir)
43
- Ohai::Log.info("The plugin path #{plugin_dir} does not exist. Skipping...")
44
- return []
45
- end
46
-
47
- Ohai::Log.trace("Searching for Ohai plugins in #{plugin_dir}")
48
-
49
- escaped = ChefConfig::PathHelper.escape_glob_dir(plugin_dir)
50
- Dir[File.join(escaped, "**", "*.rb")].map do |file|
51
- new(file, plugin_dir)
52
- end
53
- end
54
- end
55
-
56
31
  attr_reader :logger
32
+
57
33
  def initialize(controller)
58
34
  @controller = controller
59
35
  @logger = controller.logger.with_child(subsystem: "loader")
60
36
  @v7_plugin_classes = []
61
37
  end
62
38
 
63
- # Searches all plugin paths and returns an Array of PluginFile objects
64
- # representing each plugin file.
39
+ # Searches all plugin paths and returns an Array of file paths to plugins
65
40
  #
66
41
  # @param dir [Array, String] directory/directories to load plugins from
67
- # @return [Array<Ohai::Loader::PluginFile>]
68
- def plugin_files_by_dir(dir = Ohai.config[:plugin_path])
69
- Array(dir).inject([]) do |plugin_files, plugin_path|
70
- plugin_files + PluginFile.find_all_in(plugin_path)
71
- end
42
+ # @return [Array<String>]
43
+ def plugin_files_by_dir(plugin_dir = Ohai.config[:plugin_path])
44
+ Array(plugin_dir).map do |path|
45
+ if Dir.exist?(path)
46
+ Ohai::Log.trace("Searching for Ohai plugins in #{path}")
47
+
48
+ escaped = ChefConfig::PathHelper.escape_glob_dir(path)
49
+ Dir[File.join(escaped, "**", "*.rb")]
50
+ else
51
+ Ohai::Log.debug("The plugin path #{path} does not exist. Skipping...")
52
+ []
53
+ end
54
+ end.flatten
72
55
  end
73
56
 
74
57
  # loads all plugin classes
@@ -76,7 +59,7 @@ module Ohai
76
59
  # @return [Array<String>]
77
60
  def load_all
78
61
  plugin_files_by_dir.each do |plugin_file|
79
- load_plugin_class(plugin_file.path, plugin_file.plugin_root)
62
+ load_plugin_class(plugin_file)
80
63
  end
81
64
 
82
65
  collect_v7_plugins
@@ -88,19 +71,18 @@ module Ohai
88
71
  from = [ Ohai.config[:plugin_path], from].flatten
89
72
  plugin_files_by_dir(from).collect do |plugin_file|
90
73
  logger.trace "Loading additional plugin: #{plugin_file}"
91
- plugin = load_plugin_class(plugin_file.path, plugin_file.plugin_root)
74
+ plugin = load_plugin_class(plugin_file)
92
75
  load_v7_plugin(plugin)
93
76
  end
94
77
  end
95
78
 
96
79
  # Load a specified file as an ohai plugin and creates an instance of it.
97
- # Not used by ohai itself, but can be used to load a plugin for testing
98
- # purposes.
80
+ # Not used by ohai itself, but is used in the specs to load plugins for testing
99
81
  #
82
+ # @private
100
83
  # @param plugin_path [String]
101
- # @param plugin_dir_path [String]
102
- def load_plugin(plugin_path, plugin_dir_path = nil)
103
- plugin_class = load_plugin_class(plugin_path, plugin_dir_path)
84
+ def load_plugin(plugin_path)
85
+ plugin_class = load_plugin_class(plugin_path)
104
86
  return nil unless plugin_class.kind_of?(Class)
105
87
  if plugin_class < Ohai::DSL::Plugin::VersionVII
106
88
  load_v7_plugin(plugin_class)
@@ -109,13 +91,11 @@ module Ohai
109
91
  end
110
92
  end
111
93
 
112
- # Reads the file specified by `plugin_path` and returns a class object for
113
- # the ohai plugin defined therein.
94
+ # load an ohai plugin object class from file
95
+ # @param plugin_path String the path to the ohai plugin
114
96
  #
115
- # If `plugin_dir_path` is given, and the file at `plugin_path` is a v6
116
- # plugin, the 'relative path' of the plugin (used by `require_plugin()`) is
117
- # computed by finding the relative path from `plugin_dir_path` to `plugin_path`
118
- def load_plugin_class(plugin_path, plugin_dir_path = nil)
97
+ # @return [Object] class object for the ohai plugin defined in the file
98
+ def load_plugin_class(plugin_path)
119
99
  # Read the contents of the plugin to understand if it's a V6 or V7 plugin.
120
100
  contents = ""
121
101
  begin
@@ -150,6 +130,11 @@ module Ohai
150
130
  end
151
131
  end
152
132
 
133
+ # load an Ohai v7 plugin class from a string of the object
134
+ # @param contents [String] text of the plugin object
135
+ # @param plugin_path [String] the path to the plugin file where the contents came from
136
+ #
137
+ # @return [Ohai::DSL::Plugin::VersionVII] Ohai plugin object
153
138
  def load_v7_plugin_class(contents, plugin_path)
154
139
  plugin_class = eval(contents, TOPLEVEL_BINDING, plugin_path) # rubocop: disable Security/Eval
155
140
  unless plugin_class.kind_of?(Class) && plugin_class < Ohai::DSL::Plugin
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Tim Smith <tsmith@chef.io>
3
- # Copyright:: Copyright (c) 2015-2016 Chef Software, Inc.
3
+ # Copyright:: Copyright (c) 2015-2018 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,37 +17,34 @@
17
17
 
18
18
  # http://www.dmo.ca/blog/detecting-virtualization-on-linux
19
19
  module ::Ohai::Mixin::DmiDecode
20
- def guest_from_dmi(dmi_data)
21
- dmi_data.each_line do |line|
22
- case line
23
- when /Manufacturer: Microsoft/
24
- if dmi_data =~ /Product.*: Virtual Machine/
25
- if dmi_data =~ /Version: (7.0|Hyper-V)/
26
- return "hyperv"
27
- elsif dmi_data =~ /Version: (VS2005R2|6.0)/
28
- return "virtualpc"
29
- elsif dmi_data =~ /Version: 5.0/
30
- return "virtualserver"
31
- end
32
- end
33
- when /Manufacturer: VMware/
34
- return "vmware"
35
- when /Manufacturer: Xen/
36
- return "xen"
37
- when /Product.*: VirtualBox/
38
- return "vbox"
39
- when /Product.*: OpenStack/
40
- return "openstack"
41
- when /Manufacturer: QEMU|Product Name: (KVM|RHEV)/
42
- return "kvm"
43
- when /Product.*: BHYVE/
44
- return "bhyve"
45
- when /Manufacturer: Veertu/
46
- return "veertu"
47
- when /Manufacturer: Amazon EC2/
48
- return "amazonec2"
49
- end
20
+ def guest_from_dmi_data(manufacturer, product, version)
21
+ case manufacturer
22
+ when /Xen/
23
+ return "xen"
24
+ when /VMware/
25
+ return "vmware"
26
+ when /Microsoft/
27
+ return "hyperv" if product =~ /Virtual Machine/
28
+ when /Amazon EC2/
29
+ return "amazonec2"
30
+ when /QEMU/
31
+ return "kvm"
32
+ when /Veertu/
33
+ return "veertu"
34
+ when /Parallels/
35
+ return "parallels"
50
36
  end
51
- nil
37
+
38
+ case product
39
+ when /VirtualBox/
40
+ return "vbox"
41
+ when /OpenStack/
42
+ return "openstack"
43
+ when /(KVM|RHEV)/
44
+ return "kvm"
45
+ when /BHYVE/
46
+ return "bhyve"
47
+ end
48
+ nil # doesn't look like a virt
52
49
  end
53
50
  end
@@ -32,8 +32,6 @@ module Ohai
32
32
  "aix"
33
33
  when /darwin(.+)$/
34
34
  "darwin"
35
- when /hpux(.+)$/
36
- "hpux"
37
35
  when /linux/
38
36
  "linux"
39
37
  when /freebsd(.+)$/
@@ -29,11 +29,11 @@ module ::Ohai::Mixin::SoftlayerMetadata
29
29
  # @return [Hash]
30
30
  def fetch_metadata
31
31
  {
32
- "public_fqdn" => fetch_metadata_item("getFullyQualifiedDomainName.txt"),
33
- "local_ipv4" => fetch_metadata_item("getPrimaryBackendIpAddress.txt"),
34
- "public_ipv4" => fetch_metadata_item("getPrimaryIpAddress.txt"),
35
- "region" => fetch_metadata_item("getDatacenter.txt"),
36
- "instance_id" => fetch_metadata_item("getId.txt"),
32
+ "public_fqdn" => fetch_metadata_item("getFullyQualifiedDomainName.txt"),
33
+ "local_ipv4" => fetch_metadata_item("getPrimaryBackendIpAddress.txt"),
34
+ "public_ipv4" => fetch_metadata_item("getPrimaryIpAddress.txt"),
35
+ "region" => fetch_metadata_item("getDatacenter.txt"),
36
+ "instance_id" => fetch_metadata_item("getId.txt"),
37
37
  }
38
38
  end
39
39
 
@@ -61,8 +61,8 @@ Ohai.plugin(:Virtualization) do
61
61
  splat = line.strip.split
62
62
  key = splat[0].downcase
63
63
  value = {
64
- "address" => splat[1],
65
- "netmask" => splat[2],
64
+ "address" => splat[1],
65
+ "netmask" => splat[2],
66
66
  "broadcast" => splat[3],
67
67
  }
68
68
  wpars[wpar_name][title][key] = value
@@ -72,7 +72,7 @@ Ohai.plugin(:Virtualization) do
72
72
  key = splat[2].downcase
73
73
  value = {
74
74
  "destination" => splat[0],
75
- "gateway" => splat[1],
75
+ "gateway" => splat[1],
76
76
  }
77
77
  wpars[wpar_name][title][key] = value
78
78
  when "file systems"
@@ -81,7 +81,7 @@ Ohai.plugin(:Virtualization) do
81
81
  key = splat[1].downcase
82
82
  value = {
83
83
  "mountpoint" => splat[0],
84
- "device" => splat[1],
84
+ "device" => splat[1],
85
85
  "vfs" => splat[2],
86
86
  "options" => splat[3].split(","),
87
87
  }
@@ -17,11 +17,11 @@
17
17
  # limitations under the License.
18
18
  #
19
19
 
20
- require "ohai/mixin/dmi_decode"
21
-
22
20
  Ohai.plugin(:Virtualization) do
23
- include Ohai::Mixin::DmiDecode
24
21
  provides "virtualization"
22
+ depends "dmi"
23
+ require "ohai/mixin/dmi_decode"
24
+ include Ohai::Mixin::DmiDecode
25
25
 
26
26
  collect_data(:freebsd, :openbsd, :netbsd, :dragonflybsd) do
27
27
 
@@ -108,15 +108,13 @@ Ohai.plugin(:Virtualization) do
108
108
  logger.trace("Plugin Virtualization: Guest running on #{hypervisor} detected")
109
109
  end
110
110
 
111
- # parse dmidecode to discover various virtualization guests
112
- if File.exist?("/usr/local/sbin/dmidecode") || File.exist?("/usr/pkg/sbin/dmidecode")
113
- guest = guest_from_dmi(shell_out("dmidecode").stdout)
114
- if guest
115
- virtualization[:system] = guest
116
- virtualization[:role] = "guest"
117
- virtualization[:systems][guest.to_sym] = "guest"
118
- logger.trace("Plugin Virtualization: Guest running on #{guest} detected")
119
- end
111
+ # parse dmi to discover various virtualization guests
112
+ guest = guest_from_dmi_data(get_attribute(:dmi, :system, :manufacturer), get_attribute(:dmi, :system, :product), get_attribute(:dmi, :system, :version))
113
+ if guest
114
+ logger.trace("Plugin Virtualization: DMI data indicates #{guest} guest")
115
+ virtualization[:system] = guest
116
+ virtualization[:role] = "guest"
117
+ virtualization[:systems][guest.to_sym] = "guest"
120
118
  end
121
119
  end
122
120
  end
@@ -149,19 +149,6 @@ Ohai.plugin(:C) do
149
149
  end
150
150
  end
151
151
 
152
- def collect_hpux_cc
153
- # hpux cc
154
- collect("what /opt/ansic/bin/cc") do |so|
155
- description = so.stdout.split($/).select { |line| line =~ /HP C Compiler/ }.first
156
- if description
157
- output = description.split
158
- @c[:hpcc] = Mash.new
159
- @c[:hpcc][:version] = output[1] if output.size >= 1
160
- @c[:hpcc][:description] = description.strip
161
- end
162
- end
163
- end
164
-
165
152
  collect_data(:aix) do
166
153
  @c = Mash.new
167
154
  collect_xlc
@@ -182,13 +169,6 @@ Ohai.plugin(:C) do
182
169
  languages[:c] = @c unless @c.empty?
183
170
  end
184
171
 
185
- collect_data(:hpux) do
186
- @c = Mash.new
187
- collect_gcc
188
- collect_hpux_cc
189
- languages[:c] = @c unless @c.empty?
190
- end
191
-
192
172
  collect_data(:default) do
193
173
  @c = Mash.new
194
174
  collect_gcc