ohai 14.15.0 → 15.0.35
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/lib/ohai/application.rb +0 -4
- data/lib/ohai/common/dmi.rb +43 -43
- data/lib/ohai/config.rb +1 -1
- data/lib/ohai/loader.rb +32 -47
- data/lib/ohai/mixin/dmi_decode.rb +29 -32
- data/lib/ohai/mixin/os.rb +0 -2
- data/lib/ohai/mixin/softlayer_metadata.rb +5 -5
- data/lib/ohai/plugins/aix/virtualization.rb +4 -4
- data/lib/ohai/plugins/bsd/virtualization.rb +10 -12
- data/lib/ohai/plugins/c.rb +0 -20
- data/lib/ohai/plugins/elixir.rb +13 -13
- data/lib/ohai/plugins/filesystem.rb +10 -10
- data/lib/ohai/plugins/gce.rb +42 -8
- data/lib/ohai/plugins/go.rb +11 -11
- data/lib/ohai/plugins/groovy.rb +12 -12
- data/lib/ohai/plugins/hostname.rb +9 -2
- data/lib/ohai/plugins/linux/fips.rb +2 -9
- data/lib/ohai/plugins/linux/memory.rb +5 -0
- data/lib/ohai/plugins/linux/network.rb +1 -1
- data/lib/ohai/plugins/linux/platform.rb +84 -83
- data/lib/ohai/plugins/linux/systemd_paths.rb +0 -3
- data/lib/ohai/plugins/linux/virtualization.rb +10 -20
- data/lib/ohai/plugins/lua.rb +13 -13
- data/lib/ohai/plugins/mono.rb +23 -23
- data/lib/ohai/plugins/nodejs.rb +13 -13
- data/lib/ohai/plugins/openstack.rb +1 -1
- data/lib/ohai/plugins/packages.rb +1 -28
- data/lib/ohai/plugins/perl.rb +17 -17
- data/lib/ohai/plugins/php.rb +22 -22
- data/lib/ohai/plugins/powershell.rb +30 -30
- data/lib/ohai/plugins/ps.rb +1 -1
- data/lib/ohai/plugins/python.rb +15 -15
- data/lib/ohai/plugins/rust.rb +11 -11
- data/lib/ohai/plugins/solaris2/dmi.rb +48 -48
- data/lib/ohai/plugins/solaris2/virtualization.rb +8 -10
- data/lib/ohai/plugins/virtualbox.rb +21 -21
- data/lib/ohai/plugins/windows/filesystem.rb +2 -2
- data/lib/ohai/plugins/windows/fips.rb +2 -21
- data/lib/ohai/plugins/windows/virtualization.rb +9 -35
- data/lib/ohai/runner.rb +2 -2
- data/lib/ohai/system.rb +0 -17
- data/lib/ohai/version.rb +1 -1
- data/ohai.gemspec +2 -2
- data/spec/data/plugins/rpmquery.output +0 -2
- data/spec/functional/application_spec.rb +1 -1
- data/spec/functional/loader_spec.rb +2 -2
- data/spec/functional/plugins/powershell_spec.rb +2 -2
- data/spec/functional/plugins/root_group_spec.rb +1 -1
- data/spec/functional/plugins/windows/uptime_spec.rb +2 -2
- data/spec/ohai_spec.rb +1 -1
- data/spec/unit/application_spec.rb +1 -1
- data/spec/unit/config_spec.rb +1 -1
- data/spec/unit/dsl/plugin_spec.rb +1 -1
- data/spec/unit/hints_spec.rb +2 -2
- data/spec/unit/loader_spec.rb +12 -12
- data/spec/unit/mixin/azure_metadata_spec.rb +1 -1
- data/spec/unit/mixin/command_spec.rb +1 -1
- data/spec/unit/mixin/dmi_decode.rb +68 -0
- data/spec/unit/mixin/ec2_metadata_spec.rb +1 -1
- data/spec/unit/mixin/softlayer_metadata_spec.rb +1 -1
- data/spec/unit/plugin_config_spec.rb +1 -1
- data/spec/unit/plugins/abort_spec.rb +9 -9
- data/spec/unit/plugins/aix/cpu_spec.rb +4 -4
- data/spec/unit/plugins/aix/filesystem_spec.rb +5 -5
- data/spec/unit/plugins/aix/hostname_spec.rb +1 -1
- data/spec/unit/plugins/aix/kernel_spec.rb +1 -1
- data/spec/unit/plugins/aix/memory_spec.rb +1 -1
- data/spec/unit/plugins/aix/network_spec.rb +6 -6
- data/spec/unit/plugins/aix/platform_spec.rb +1 -1
- data/spec/unit/plugins/aix/uptime_spec.rb +1 -1
- data/spec/unit/plugins/aix/virtualization_spec.rb +2 -2
- data/spec/unit/plugins/azure_spec.rb +1 -1
- data/spec/unit/plugins/bsd/filesystem_spec.rb +4 -4
- data/spec/unit/plugins/bsd/virtualization_spec.rb +3 -3
- data/spec/unit/plugins/c_spec.rb +1 -53
- data/spec/unit/plugins/chef_spec.rb +1 -1
- data/spec/unit/plugins/cloud_spec.rb +1 -1
- data/spec/unit/plugins/darwin/cpu_spec.rb +2 -2
- data/spec/unit/plugins/darwin/filesystem_spec.rb +5 -5
- data/spec/unit/plugins/darwin/hardware_spec.rb +2 -2
- data/spec/unit/plugins/darwin/hardware_system_profiler_output.rb +3 -3
- data/spec/unit/plugins/darwin/hostname_spec.rb +1 -1
- data/spec/unit/plugins/darwin/kernel_spec.rb +1 -1
- data/spec/unit/plugins/darwin/memory_spec.rb +1 -1
- data/spec/unit/plugins/darwin/network_spec.rb +1 -1
- data/spec/unit/plugins/darwin/platform_spec.rb +1 -1
- data/spec/unit/plugins/darwin/virtualization_spec.rb +1 -1
- data/spec/unit/plugins/dmi_spec.rb +1 -1
- data/spec/unit/plugins/docker_spec.rb +1 -1
- data/spec/unit/plugins/ec2_spec.rb +1 -1
- data/spec/unit/plugins/elixir_spec.rb +1 -1
- data/spec/unit/plugins/erlang_spec.rb +1 -1
- data/spec/unit/plugins/eucalyptus_spec.rb +1 -1
- data/spec/unit/plugins/fail_spec.rb +28 -28
- data/spec/unit/plugins/freebsd/cpu_spec.rb +1 -1
- data/spec/unit/plugins/freebsd/hostname_spec.rb +1 -1
- data/spec/unit/plugins/freebsd/kernel_spec.rb +1 -1
- data/spec/unit/plugins/freebsd/platform_spec.rb +1 -1
- data/spec/unit/plugins/gce_spec.rb +1 -1
- data/spec/unit/plugins/go_spec.rb +1 -1
- data/spec/unit/plugins/groovy_spec.rb +1 -1
- data/spec/unit/plugins/haskell_spec.rb +1 -1
- data/spec/unit/plugins/hostname_spec.rb +68 -1
- data/spec/unit/plugins/init_package_spec.rb +1 -1
- data/spec/unit/plugins/java_spec.rb +1 -1
- data/spec/unit/plugins/joyent_spec.rb +3 -3
- data/spec/unit/plugins/kernel_spec.rb +1 -1
- data/spec/unit/plugins/linode_spec.rb +1 -1
- data/spec/unit/plugins/linux/block_device_spec.rb +1 -1
- data/spec/unit/plugins/linux/cpu_spec.rb +6 -6
- data/spec/unit/plugins/linux/filesystem_spec.rb +21 -21
- data/spec/unit/plugins/linux/fips_spec.rb +13 -45
- data/spec/unit/plugins/linux/hostname_spec.rb +1 -1
- data/spec/unit/plugins/linux/hostnamectl_spec.rb +2 -2
- data/spec/unit/plugins/linux/kernel_spec.rb +8 -8
- data/spec/unit/plugins/linux/lsb_spec.rb +3 -3
- data/spec/unit/plugins/linux/lspci_spec.rb +2 -2
- data/spec/unit/plugins/linux/machineid_spec.rb +1 -1
- data/spec/unit/plugins/linux/mdadm_spec.rb +2 -2
- data/spec/unit/plugins/linux/memory_spec.rb +26 -1
- data/spec/unit/plugins/linux/network_spec.rb +37 -37
- data/spec/unit/plugins/linux/platform_spec.rb +580 -837
- data/spec/unit/plugins/linux/sessions_spec.rb +2 -2
- data/spec/unit/plugins/linux/systemd_paths_spec.rb +1 -1
- data/spec/unit/plugins/linux/uptime_spec.rb +1 -1
- data/spec/unit/plugins/linux/virtualization_spec.rb +28 -227
- data/spec/unit/plugins/lua_spec.rb +1 -1
- data/spec/unit/plugins/mono_spec.rb +2 -2
- data/spec/unit/plugins/netbsd/hostname_spec.rb +1 -1
- data/spec/unit/plugins/netbsd/kernel_spec.rb +1 -1
- data/spec/unit/plugins/netbsd/platform_spec.rb +1 -1
- data/spec/unit/plugins/network_spec.rb +11 -11
- data/spec/unit/plugins/nodejs_spec.rb +1 -1
- data/spec/unit/plugins/ohai_spec.rb +1 -1
- data/spec/unit/plugins/ohai_time_spec.rb +1 -1
- data/spec/unit/plugins/openbsd/hostname_spec.rb +1 -1
- data/spec/unit/plugins/openbsd/kernel_spec.rb +1 -1
- data/spec/unit/plugins/openbsd/platform_spec.rb +1 -1
- data/spec/unit/plugins/openstack_spec.rb +8 -4
- data/spec/unit/plugins/os_spec.rb +1 -1
- data/spec/unit/plugins/packages_spec.rb +1 -21
- data/spec/unit/plugins/passwd_spec.rb +1 -1
- data/spec/unit/plugins/perl_spec.rb +1 -1
- data/spec/unit/plugins/php_spec.rb +6 -6
- data/spec/unit/plugins/platform_spec.rb +1 -1
- data/spec/unit/plugins/powershell_spec.rb +3 -3
- data/spec/unit/plugins/python_spec.rb +1 -1
- data/spec/unit/plugins/rackspace_spec.rb +2 -2
- data/spec/unit/plugins/root_group_spec.rb +1 -11
- data/spec/unit/plugins/ruby_spec.rb +1 -1
- data/spec/unit/plugins/rust_spec.rb +1 -1
- data/spec/unit/plugins/scala_spec.rb +1 -1
- data/spec/unit/plugins/scsi_spec.rb +2 -2
- data/spec/unit/plugins/shard_spec.rb +1 -1
- data/spec/unit/plugins/shells_spec.rb +1 -1
- data/spec/unit/plugins/softlayer_spec.rb +1 -1
- data/spec/unit/plugins/solaris2/cpu_spec.rb +3 -3
- data/spec/unit/plugins/solaris2/dmi_spec.rb +1 -1
- data/spec/unit/plugins/solaris2/filesystem.rb +4 -4
- data/spec/unit/plugins/solaris2/hostname_spec.rb +1 -1
- data/spec/unit/plugins/solaris2/kernel_spec.rb +1 -1
- data/spec/unit/plugins/solaris2/memory_spec.rb +1 -1
- data/spec/unit/plugins/solaris2/network_spec.rb +6 -6
- data/spec/unit/plugins/solaris2/platform_spec.rb +3 -3
- data/spec/unit/plugins/solaris2/virtualization_spec.rb +41 -69
- data/spec/unit/plugins/ssh_host_keys_spec.rb +3 -3
- data/spec/unit/plugins/sysconf_spec.rb +2 -2
- data/spec/unit/plugins/timezone_spec.rb +1 -1
- data/spec/unit/plugins/virtualbox_spec.rb +1 -1
- data/spec/unit/plugins/vmware_spec.rb +1 -1
- data/spec/unit/plugins/windows/cpu_spec.rb +1 -2
- data/spec/unit/plugins/windows/filesystem_spec.rb +2 -2
- data/spec/unit/plugins/windows/fips_spec.rb +17 -77
- data/spec/unit/plugins/windows/kernel_spec.rb +1 -1
- data/spec/unit/plugins/windows/memory_spec.rb +2 -2
- data/spec/unit/plugins/windows/network_spec.rb +1 -1
- data/spec/unit/plugins/windows/system_enclosure_spec.rb +1 -1
- data/spec/unit/plugins/windows/uptime_spec.rb +1 -1
- data/spec/unit/plugins/windows/virtualization_spec.rb +20 -238
- data/spec/unit/plugins/zpools_spec.rb +7 -7
- data/spec/unit/provides_map_spec.rb +1 -1
- data/spec/unit/runner_spec.rb +1 -1
- data/spec/unit/system_spec.rb +10 -77
- data/spec/unit/util/file_helper_spec.rb +1 -1
- data/spec/unit/util/ip_helper_spec.rb +1 -1
- metadata +6 -9
- data/lib/ohai/plugins/darwin/system_profiler.rb +0 -72
- data/lib/ohai/util/win32/group_helper.rb +0 -76
- data/spec/unit/plugins/darwin/system_profiler_output.rb +0 -79524
- 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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b2b536c237b18f6b940c6a9082745d73d0c092e45f250129d4648e1b13834d0f
|
4
|
+
data.tar.gz: e2efa2a548dd3270584593fc5bc056043cae6a85902c6d0dfbc6a3b27cf78934
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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", "
|
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/lib/ohai/application.rb
CHANGED
@@ -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)
|
data/lib/ohai/common/dmi.rb
CHANGED
@@ -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 =>
|
29
|
-
1 =>
|
30
|
-
2 =>
|
31
|
-
3 =>
|
32
|
-
4 =>
|
33
|
-
5 =>
|
34
|
-
6 =>
|
35
|
-
7 =>
|
36
|
-
8 =>
|
37
|
-
9 =>
|
38
|
-
10 =>
|
39
|
-
11 =>
|
40
|
-
12 =>
|
41
|
-
13 =>
|
42
|
-
14 =>
|
43
|
-
15 =>
|
44
|
-
16 =>
|
45
|
-
17 =>
|
46
|
-
18 =>
|
47
|
-
19 =>
|
48
|
-
20 =>
|
49
|
-
21 =>
|
50
|
-
22 =>
|
51
|
-
23 =>
|
52
|
-
24 =>
|
53
|
-
25 =>
|
54
|
-
26 =>
|
55
|
-
27 =>
|
56
|
-
28 =>
|
57
|
-
29 =>
|
58
|
-
30 =>
|
59
|
-
31 =>
|
60
|
-
32 =>
|
61
|
-
33 =>
|
62
|
-
34 =>
|
63
|
-
35 =>
|
64
|
-
36 =>
|
65
|
-
37 =>
|
66
|
-
38 =>
|
67
|
-
39 =>
|
68
|
-
40 =>
|
69
|
-
41 =>
|
70
|
-
42 =>
|
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
|
data/lib/ohai/config.rb
CHANGED
@@ -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
|
42
|
+
default :optional_plugins, []
|
43
43
|
default :shellout_timeout, 30
|
44
44
|
end
|
45
45
|
end
|
data/lib/ohai/loader.rb
CHANGED
@@ -24,51 +24,34 @@ require "pathname"
|
|
24
24
|
|
25
25
|
module Ohai
|
26
26
|
|
27
|
-
# Ohai plugin loader. Finds all the plugins in
|
28
|
-
#
|
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
|
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<
|
68
|
-
def plugin_files_by_dir(
|
69
|
-
Array(
|
70
|
-
|
71
|
-
|
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
|
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
|
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
|
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
|
-
|
102
|
-
|
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
|
-
#
|
113
|
-
# the ohai plugin
|
94
|
+
# load an ohai plugin object class from file
|
95
|
+
# @param plugin_path String the path to the ohai plugin
|
114
96
|
#
|
115
|
-
#
|
116
|
-
|
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-
|
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
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
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
|
-
|
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
|
data/lib/ohai/mixin/os.rb
CHANGED
@@ -29,11 +29,11 @@ module ::Ohai::Mixin::SoftlayerMetadata
|
|
29
29
|
# @return [Hash]
|
30
30
|
def fetch_metadata
|
31
31
|
{
|
32
|
-
"public_fqdn"
|
33
|
-
"local_ipv4"
|
34
|
-
"public_ipv4"
|
35
|
-
"region"
|
36
|
-
"instance_id"
|
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"
|
65
|
-
"netmask"
|
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"
|
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"
|
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
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
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
|
data/lib/ohai/plugins/c.rb
CHANGED
@@ -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
|