ohai 13.12.6 → 14.0.28
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +3 -12
- data/README.md +7 -12
- data/Rakefile +16 -23
- data/docs/man/man1/ohai.1 +97 -0
- data/lib/ohai/application.rb +9 -4
- data/lib/ohai/common/dmi.rb +4 -16
- data/lib/ohai/config.rb +5 -1
- data/lib/ohai/dsl.rb +0 -1
- data/lib/ohai/dsl/plugin.rb +12 -16
- data/lib/ohai/dsl/plugin/versionvii.rb +17 -5
- data/lib/ohai/hints.rb +2 -2
- data/lib/ohai/loader.rb +21 -70
- data/lib/ohai/log.rb +1 -1
- data/lib/ohai/mixin/azure_metadata.rb +4 -4
- data/lib/ohai/mixin/command.rb +3 -3
- data/lib/ohai/mixin/dmi_decode.rb +0 -2
- data/lib/ohai/mixin/do_metadata.rb +1 -1
- data/lib/ohai/mixin/ec2_metadata.rb +8 -8
- data/lib/ohai/mixin/gce_metadata.rb +1 -5
- data/lib/ohai/mixin/http_helper.rb +3 -3
- data/lib/ohai/mixin/scaleway_metadata.rb +46 -0
- data/lib/ohai/mixin/softlayer_metadata.rb +3 -3
- data/lib/ohai/plugins/aix/filesystem.rb +1 -1
- data/lib/ohai/plugins/aix/memory.rb +1 -1
- data/lib/ohai/plugins/aix/network.rb +2 -2
- data/lib/ohai/plugins/aix/virtualization.rb +1 -1
- data/lib/ohai/plugins/azure.rb +5 -5
- data/lib/ohai/plugins/bsd/virtualization.rb +11 -11
- data/lib/ohai/plugins/c.rb +8 -8
- data/lib/ohai/plugins/chef.rb +2 -1
- data/lib/ohai/plugins/cloud.rb +0 -3
- data/lib/ohai/plugins/darwin/cpu.rb +2 -2
- data/lib/ohai/plugins/darwin/filesystem.rb +0 -2
- data/lib/ohai/plugins/darwin/hardware.rb +9 -3
- data/lib/ohai/plugins/darwin/network.rb +2 -2
- data/lib/ohai/plugins/darwin/system_profiler.rb +19 -19
- data/lib/ohai/plugins/darwin/virtualization.rb +10 -0
- data/lib/ohai/plugins/digital_ocean.rb +4 -4
- data/lib/ohai/plugins/dmi.rb +15 -14
- data/lib/ohai/plugins/docker.rb +57 -0
- data/lib/ohai/plugins/ec2.rb +11 -11
- data/lib/ohai/plugins/elixir.rb +1 -1
- data/lib/ohai/plugins/erlang.rb +2 -2
- data/lib/ohai/plugins/eucalyptus.rb +5 -5
- data/lib/ohai/plugins/gce.rb +2 -2
- data/lib/ohai/plugins/go.rb +1 -1
- data/lib/ohai/plugins/groovy.rb +1 -1
- data/lib/ohai/plugins/haskell.rb +4 -4
- data/lib/ohai/plugins/hostname.rb +6 -6
- data/lib/ohai/plugins/init_package.rb +1 -1
- data/lib/ohai/plugins/java.rb +1 -1
- data/lib/ohai/plugins/kernel.rb +109 -40
- data/lib/ohai/plugins/libvirt.rb +113 -0
- data/lib/ohai/plugins/linode.rb +4 -4
- data/lib/ohai/plugins/linux/block_device.rb +4 -4
- data/lib/ohai/plugins/linux/cpu.rb +3 -3
- data/lib/ohai/plugins/linux/filesystem.rb +4 -6
- data/lib/ohai/plugins/linux/lsb.rb +3 -3
- data/lib/ohai/plugins/linux/lspci.rb +2 -1
- data/lib/ohai/plugins/linux/machineid.rb +4 -4
- data/lib/ohai/plugins/linux/network.rb +16 -16
- data/lib/ohai/plugins/linux/platform.rb +4 -10
- data/lib/ohai/plugins/linux/sessions.rb +2 -1
- data/lib/ohai/plugins/linux/virtualization.rb +53 -31
- data/lib/ohai/plugins/lua.rb +1 -1
- data/lib/ohai/plugins/mono.rb +2 -2
- data/lib/ohai/plugins/network.rb +11 -11
- data/lib/ohai/plugins/nodejs.rb +1 -1
- data/lib/ohai/plugins/ohai.rb +0 -2
- data/lib/ohai/plugins/openstack.rb +7 -10
- data/lib/ohai/plugins/packages.rb +1 -1
- data/lib/ohai/plugins/passwd.rb +1 -0
- data/lib/ohai/plugins/perl.rb +1 -1
- data/lib/ohai/plugins/php.rb +1 -1
- data/lib/ohai/plugins/powershell.rb +1 -1
- data/lib/ohai/plugins/python.rb +1 -1
- data/lib/ohai/plugins/rackspace.rb +5 -5
- data/lib/ohai/plugins/root_group.rb +6 -9
- data/lib/ohai/plugins/ruby.rb +2 -2
- data/lib/ohai/plugins/rust.rb +1 -1
- data/lib/ohai/plugins/scala.rb +1 -1
- data/lib/ohai/plugins/scaleway.rb +56 -0
- data/lib/ohai/plugins/shard.rb +1 -0
- data/lib/ohai/plugins/softlayer.rb +2 -2
- data/lib/ohai/plugins/solaris2/cpu.rb +1 -1
- data/lib/ohai/plugins/solaris2/dmi.rb +13 -13
- data/lib/ohai/plugins/solaris2/network.rb +6 -6
- data/lib/ohai/plugins/solaris2/platform.rb +2 -2
- data/lib/ohai/plugins/ssh_host_key.rb +7 -7
- data/lib/ohai/plugins/uptime.rb +2 -7
- data/lib/ohai/plugins/virtualbox.rb +1 -1
- data/lib/ohai/plugins/vmware.rb +2 -2
- data/lib/ohai/plugins/windows/cpu.rb +2 -16
- data/lib/ohai/plugins/windows/network.rb +4 -2
- data/lib/ohai/plugins/zpools.rb +3 -3
- data/lib/ohai/provides_map.rb +1 -1
- data/lib/ohai/runner.rb +11 -14
- data/lib/ohai/system.rb +8 -71
- data/lib/ohai/util/file_helper.rb +2 -2
- data/lib/ohai/util/win32/group_helper.rb +0 -2
- data/lib/ohai/version.rb +1 -1
- data/ohai.gemspec +6 -5
- data/spec/functional/plugins/root_group_spec.rb +2 -2
- data/spec/functional/plugins/windows/uptime_spec.rb +0 -29
- data/spec/unit/dsl/plugin_spec.rb +14 -46
- data/spec/unit/loader_spec.rb +8 -70
- data/spec/unit/mixin/azure_metadata_spec.rb +9 -4
- data/spec/unit/mixin/command_spec.rb +11 -8
- data/spec/unit/mixin/ec2_metadata_spec.rb +5 -0
- data/spec/unit/mixin/softlayer_metadata_spec.rb +6 -1
- data/spec/unit/plugins/aix/filesystem_spec.rb +10 -10
- data/spec/unit/plugins/aix/network_spec.rb +1 -1
- data/spec/unit/plugins/aix/virtualization_spec.rb +3 -3
- data/spec/unit/plugins/cloud_spec.rb +0 -12
- data/spec/unit/plugins/darwin/cpu_spec.rb +2 -2
- data/spec/unit/plugins/darwin/filesystem_spec.rb +1 -6
- data/spec/unit/plugins/darwin/hardware_spec.rb +1 -1
- data/spec/unit/plugins/darwin/virtualization_spec.rb +8 -0
- data/spec/unit/plugins/dmi_spec.rb +17 -25
- data/spec/unit/plugins/docker_spec.rb +100 -0
- data/spec/unit/plugins/fail_spec.rb +3 -58
- data/spec/unit/plugins/haskell_spec.rb +1 -1
- data/spec/unit/plugins/init_package_spec.rb +1 -1
- data/spec/unit/plugins/kernel_spec.rb +0 -52
- data/spec/unit/plugins/linux/block_device_spec.rb +2 -2
- data/spec/unit/plugins/linux/filesystem_spec.rb +2 -7
- data/spec/unit/plugins/linux/lsb_spec.rb +5 -5
- data/spec/unit/plugins/linux/lspci_spec.rb +2 -2
- data/spec/unit/plugins/linux/machineid_spec.rb +5 -5
- data/spec/unit/plugins/linux/network_spec.rb +16 -16
- data/spec/unit/plugins/linux/platform_spec.rb +1 -17
- data/spec/unit/plugins/linux/virtualization_spec.rb +21 -1
- data/spec/unit/plugins/network_spec.rb +58 -58
- data/spec/unit/plugins/openstack_spec.rb +5 -24
- data/spec/unit/plugins/rackspace_spec.rb +6 -6
- data/spec/unit/plugins/root_group_spec.rb +1 -1
- 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/scaleway_spec.rb +91 -0
- data/spec/unit/plugins/solaris2/cpu_spec.rb +3 -3
- data/spec/unit/plugins/solaris2/platform_spec.rb +2 -2
- data/spec/unit/plugins/ssh_host_keys_spec.rb +8 -8
- data/spec/unit/plugins/sysconf_spec.rb +1 -0
- data/spec/unit/plugins/windows/kernel_spec.rb +79 -0
- data/spec/unit/plugins/windows/uptime_spec.rb +8 -58
- data/spec/unit/provides_map_spec.rb +4 -4
- data/spec/unit/runner_spec.rb +15 -54
- data/spec/unit/system_spec.rb +35 -348
- data/spec/unit/util/file_helper_spec.rb +2 -0
- metadata +28 -28
- data/lib/ohai/dsl/plugin/versionvi.rb +0 -61
- data/lib/ohai/plugins/bsd/filesystem2.rb +0 -121
- data/lib/ohai/plugins/ip_scopes.rb +0 -67
- data/lib/ohai/plugins/virtualization.rb +0 -83
- data/spec/data/plugins/messages.rb +0 -8
- data/spec/data/plugins/v6message.rb +0 -2
- data/spec/unit/plugins/bsd/filesystem2_spec.rb +0 -126
- data/spec/unit/plugins/ip_scopes_spec.rb +0 -139
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5a1f5745602a7d261d2346fe002fc0a4dc7fbd4416e762fe32f0bbf90023e3a8
|
4
|
+
data.tar.gz: 7b0c9a614a3317d7efb17e046d886057974b9af94805eaa41e38652abfee6786
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fecf7d1a694d21150317858122036b1b88c3914ee6c1ac6559b8cd2af99c68befbceb8ed823eb1baa732357582eb2eee050b183099d27b81872e4efb74ee8a8e
|
7
|
+
data.tar.gz: 2bf44d42fe0ddd207ac2fbaa9d054efc9d80087d6a32d90b4fba5befbfe30efa29267b415fd2585c6cea673e4fca45187dfe990c98288a28bf925f74f9923324
|
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"
|
8
8
|
gem "rake", ">= 10.1.0"
|
9
9
|
gem "rspec-core", "~> 3.0"
|
10
10
|
gem "rspec-expectations", "~> 3.0"
|
@@ -17,17 +17,8 @@ group :ci do
|
|
17
17
|
gem "rspec_junit_formatter"
|
18
18
|
end
|
19
19
|
|
20
|
-
group :
|
21
|
-
gem "
|
22
|
-
gem "redcarpet"
|
23
|
-
gem "github-markup"
|
24
|
-
end
|
25
|
-
|
26
|
-
group :debug do
|
27
|
-
gem "pry"
|
28
|
-
gem "pry-byebug"
|
29
|
-
gem "pry-stack_explorer"
|
30
|
-
gem "rb-readline"
|
20
|
+
group :changelog do
|
21
|
+
gem "github_changelog_generator", git: "https://github.com/chef/github-changelog-generator"
|
31
22
|
end
|
32
23
|
|
33
24
|
instance_eval(ENV["GEMFILE_MOD"]) if ENV["GEMFILE_MOD"]
|
data/README.md
CHANGED
@@ -11,7 +11,7 @@ Ohai will print out a JSON data blob for all the known data about your system. W
|
|
11
11
|
Chef distributes ohai as a RubyGem. This README is for developers who want to modify the Ohai source code. For users who want to write plugins for Ohai, see the docs:
|
12
12
|
|
13
13
|
- General documentation: <https://docs.chef.io/ohai.html>
|
14
|
-
-
|
14
|
+
- Custom plugin documentation: <https://docs.chef.io/ohai_custom.html>
|
15
15
|
|
16
16
|
## Development Environment:
|
17
17
|
|
@@ -37,16 +37,11 @@ Ohai has some Rake tasks for doing various things.
|
|
37
37
|
|
38
38
|
```
|
39
39
|
rake -T
|
40
|
-
rake build
|
41
|
-
rake
|
42
|
-
rake
|
43
|
-
rake
|
44
|
-
rake
|
45
|
-
rake install:local # Build and install ohai-$VERSION.gem into system gems without network access
|
46
|
-
rake release[remote] # Create tag $VERSION and build and push ohai-$VERSION.gem to rubygems.org
|
47
|
-
rake spec # Run RSpec code examples
|
48
|
-
rake style # Run Chefstyle tests
|
49
|
-
rake style:auto_correct # Auto-correct RuboCop offenses
|
40
|
+
rake build # Build the gem file ohai-$VERSION.gem
|
41
|
+
rake install # install the gem locally
|
42
|
+
rake install:local # install the gem locally without network access
|
43
|
+
rake release # Create tag $VERSION, build gem, and push to Rubygems
|
44
|
+
rake spec # Run RSpec tests
|
50
45
|
|
51
46
|
($VERSION is the current version, from the GemSpec in Rakefile)
|
52
47
|
```
|
@@ -70,7 +65,7 @@ For information on contributing to this project see <https://github.com/chef/che
|
|
70
65
|
Ohai - system information application
|
71
66
|
|
72
67
|
- Author:: Adam Jacob ([adam@chef.io](mailto:adam@chef.io))
|
73
|
-
- Copyright:: Copyright (c) 2008-
|
68
|
+
- Copyright:: Copyright (c) 2008-2016 Chef Software, Inc.
|
74
69
|
- License:: Apache License, Version 2.0
|
75
70
|
|
76
71
|
```text
|
data/Rakefile
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
|
+
require "date"
|
3
|
+
require "ohai/version"
|
2
4
|
|
3
5
|
begin
|
4
6
|
require "rspec/core/rake_task"
|
@@ -9,34 +11,25 @@ begin
|
|
9
11
|
rescue LoadError
|
10
12
|
desc "rspec is not installed, this task is disabled"
|
11
13
|
task :spec do
|
12
|
-
abort "rspec is not installed.
|
14
|
+
abort "rspec is not installed. `(sudo) gem install rspec` to run unit tests"
|
13
15
|
end
|
14
16
|
end
|
15
17
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
end
|
23
|
-
rescue LoadError
|
24
|
-
puts "chefstyle gem is not installed. bundle install first to make sure all dependencies are installed."
|
18
|
+
task :default => :spec
|
19
|
+
|
20
|
+
require "chefstyle"
|
21
|
+
require "rubocop/rake_task"
|
22
|
+
RuboCop::RakeTask.new(:style) do |task|
|
23
|
+
task.options += ["--display-cop-names", "--no-color"]
|
25
24
|
end
|
26
25
|
|
27
26
|
begin
|
28
|
-
require "
|
29
|
-
YARD::Rake::YardocTask.new(:docs)
|
30
|
-
rescue LoadError
|
31
|
-
puts "yard is not available. bundle install first to make sure all dependencies are installed."
|
32
|
-
end
|
27
|
+
require "github_changelog_generator/task"
|
33
28
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
29
|
+
GitHubChangelogGenerator::RakeTask.new :changelog do |config|
|
30
|
+
config.future_release = Ohai::VERSION
|
31
|
+
config.max_issues = 0
|
32
|
+
config.add_issues_wo_labels = false
|
33
|
+
end
|
34
|
+
rescue LoadError
|
40
35
|
end
|
41
|
-
|
42
|
-
task default: [:style, :spec]
|
@@ -0,0 +1,97 @@
|
|
1
|
+
.\" Man page generated from reStructuredText.
|
2
|
+
.
|
3
|
+
.TH "OHAI" "1" "Ohai 7.0.0" "" "ohai"
|
4
|
+
.SH NAME
|
5
|
+
ohai \- The man page for the ohai command line tool.
|
6
|
+
.
|
7
|
+
.nr rst2man-indent-level 0
|
8
|
+
.
|
9
|
+
.de1 rstReportMargin
|
10
|
+
\\$1 \\n[an-margin]
|
11
|
+
level \\n[rst2man-indent-level]
|
12
|
+
level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
|
13
|
+
-
|
14
|
+
\\n[rst2man-indent0]
|
15
|
+
\\n[rst2man-indent1]
|
16
|
+
\\n[rst2man-indent2]
|
17
|
+
..
|
18
|
+
.de1 INDENT
|
19
|
+
.\" .rstReportMargin pre:
|
20
|
+
. RS \\$1
|
21
|
+
. nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
|
22
|
+
. nr rst2man-indent-level +1
|
23
|
+
.\" .rstReportMargin post:
|
24
|
+
..
|
25
|
+
.de UNINDENT
|
26
|
+
. RE
|
27
|
+
.\" indent \\n[an-margin]
|
28
|
+
.\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
|
29
|
+
.nr rst2man-indent-level -1
|
30
|
+
.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
|
31
|
+
.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
|
32
|
+
..
|
33
|
+
.sp
|
34
|
+
Ohai is a tool that is used to detect attributes on a node, and then provide these attributes to the chef\-client at the start of every chef\-client run. Ohai is required by the chef\-client and must be present on a node. (Ohai is installed on a node as part of the chef\-client install process.)
|
35
|
+
.sp
|
36
|
+
The types of attributes Ohai collects include (but are not limited to):
|
37
|
+
.INDENT 0.0
|
38
|
+
.IP \(bu 2
|
39
|
+
Platform details
|
40
|
+
.IP \(bu 2
|
41
|
+
Network usage
|
42
|
+
.IP \(bu 2
|
43
|
+
Memory usage
|
44
|
+
.IP \(bu 2
|
45
|
+
Processor usage
|
46
|
+
.IP \(bu 2
|
47
|
+
Kernel data
|
48
|
+
.IP \(bu 2
|
49
|
+
Host names
|
50
|
+
.IP \(bu 2
|
51
|
+
Fully qualified domain names
|
52
|
+
.IP \(bu 2
|
53
|
+
Other configuration details
|
54
|
+
.UNINDENT
|
55
|
+
.sp
|
56
|
+
Attributes that are collected by Ohai are automatic attributes, in that these attributes are used by the chef\-client to ensure that these attributes remain unchanged after the chef\-client is done configuring the node.
|
57
|
+
.sp
|
58
|
+
ohai is the command\-line interface for Ohai, a tool that is used to detect attributes on a node, and then provide these attributes to the chef\-client at the start of every chef\-client run.
|
59
|
+
.SH OPTIONS
|
60
|
+
.sp
|
61
|
+
This command has the following syntax:
|
62
|
+
.INDENT 0.0
|
63
|
+
.INDENT 3.5
|
64
|
+
.sp
|
65
|
+
.nf
|
66
|
+
.ft C
|
67
|
+
ohai OPTION
|
68
|
+
.ft P
|
69
|
+
.fi
|
70
|
+
.UNINDENT
|
71
|
+
.UNINDENT
|
72
|
+
.sp
|
73
|
+
This tool has the following options:
|
74
|
+
.INDENT 0.0
|
75
|
+
.TP
|
76
|
+
.B \fBATTRIBUTE_NAME ATTRIBUTE NAME ...\fP
|
77
|
+
Use to have Ohai show only output for named attributes.
|
78
|
+
.TP
|
79
|
+
.B \fB\-d PATH\fP, \fB\-\-directory PATH\fP
|
80
|
+
The directory in which Ohai plugins are located. For example: \fB/etc/ohai/plugins\fP\&.
|
81
|
+
.TP
|
82
|
+
.B \fB\-h\fP, \fB\-\-help\fP
|
83
|
+
Shows help for the command.
|
84
|
+
.TP
|
85
|
+
.B \fB\-l LEVEL\fP, \fB\-\-log_level LEVEL\fP
|
86
|
+
The level of logging that will be stored in a log file.
|
87
|
+
.TP
|
88
|
+
.B \fB\-L LOGLOCATION\fP, \fB\-\-logfile c\fP
|
89
|
+
The location in which log file output files will be saved. If this location is set to something other than \fBSTDOUT\fP, standard output logging will still be performed (otherwise there would be no output other than to a file).
|
90
|
+
.TP
|
91
|
+
.B \fB\-v\fP, \fB\-\-version\fP
|
92
|
+
The version of Ohai\&.
|
93
|
+
.UNINDENT
|
94
|
+
.SH AUTHOR
|
95
|
+
Opscode
|
96
|
+
.\" Generated by docutils manpage writer.
|
97
|
+
.
|
data/lib/ohai/application.rb
CHANGED
@@ -66,6 +66,14 @@ class Ohai::Application
|
|
66
66
|
:proc => lambda { |v| puts "Ohai: #{::Ohai::VERSION}" },
|
67
67
|
:exit => 0
|
68
68
|
|
69
|
+
def initialize
|
70
|
+
super
|
71
|
+
|
72
|
+
# Always switch to a readable directory. Keeps subsequent Dir.chdir() {}
|
73
|
+
# from failing due to permissions when launched as a less privileged user.
|
74
|
+
Dir.chdir("/")
|
75
|
+
end
|
76
|
+
|
69
77
|
def run
|
70
78
|
elapsed = Benchmark.measure do
|
71
79
|
configure_ohai
|
@@ -84,11 +92,8 @@ class Ohai::Application
|
|
84
92
|
end
|
85
93
|
|
86
94
|
def run_application
|
87
|
-
# Always switch to a readable directory. Keeps subsequent Dir.chdir() {}
|
88
|
-
# from failing due to permissions when launched as a less privileged user.
|
89
|
-
Dir.chdir("/")
|
90
|
-
|
91
95
|
config[:invoked_from_cli] = true
|
96
|
+
config[:logger] = Ohai::Log.with_child
|
92
97
|
ohai = Ohai::System.new(config)
|
93
98
|
ohai.all_plugins(@attributes)
|
94
99
|
|
data/lib/ohai/common/dmi.rb
CHANGED
@@ -72,22 +72,10 @@ module Ohai
|
|
72
72
|
127 => "end_of_table_marker",
|
73
73
|
}
|
74
74
|
|
75
|
-
# list of IDs to collect
|
76
|
-
#
|
75
|
+
# list of IDs to collect, otherwise we generate pages of hashes about cache chip size and whatnot
|
76
|
+
# See OHAI-260. When we can give the user a choice, this will be a default.
|
77
77
|
ID_TO_CAPTURE = [ 0, 1, 2, 3, 4, 6, 11 ]
|
78
78
|
|
79
|
-
# return the list of DMI IDs to capture
|
80
|
-
def whitelisted_ids
|
81
|
-
if Ohai.config[:additional_dmi_ids]
|
82
|
-
if [ Integer, Array ].include?(Ohai.config[:additional_dmi_ids].class)
|
83
|
-
return ID_TO_CAPTURE + Array(Ohai.config[:additional_dmi_ids])
|
84
|
-
else
|
85
|
-
Ohai::Log.warn("The DMI plugin additional_dmi_ids config must be an array of IDs!")
|
86
|
-
end
|
87
|
-
end
|
88
|
-
ID_TO_CAPTURE
|
89
|
-
end
|
90
|
-
|
91
79
|
# look up DMI ID
|
92
80
|
def id_lookup(id)
|
93
81
|
id = id.to_i
|
@@ -97,7 +85,7 @@ module Ohai
|
|
97
85
|
id = DMI::ID_TO_DESCRIPTION[id]
|
98
86
|
else
|
99
87
|
Ohai::Log.debug("unrecognized header id; falling back to 'unknown'")
|
100
|
-
id = "
|
88
|
+
id = "unknown"
|
101
89
|
end
|
102
90
|
rescue
|
103
91
|
Ohai::Log.debug("failed to look up id #{id}, returning unchanged")
|
@@ -134,7 +122,7 @@ module Ohai
|
|
134
122
|
end
|
135
123
|
end
|
136
124
|
|
137
|
-
module_function :id_lookup, :convenience_keys
|
125
|
+
module_function :id_lookup, :convenience_keys
|
138
126
|
end
|
139
127
|
end
|
140
128
|
end
|
data/lib/ohai/config.rb
CHANGED
@@ -33,9 +33,13 @@ module Ohai
|
|
33
33
|
default :hints_path, [ ChefConfig::Config.platform_specific_path("/etc/chef/ohai/hints") ]
|
34
34
|
default :log_level, :auto
|
35
35
|
default :log_location, STDERR
|
36
|
-
default :plugin, Ohai::PluginConfig.new { |h, k| h[k] = Ohai::PluginConfig.new }
|
36
|
+
default :plugin, ( Ohai::PluginConfig.new { |h, k| h[k] = Ohai::PluginConfig.new } )
|
37
37
|
default :plugin_path, [ File.expand_path(File.join(File.dirname(__FILE__), "plugins")), ChefConfig::Config.platform_specific_path("/etc/chef/ohai/plugins") ]
|
38
38
|
default :critical_plugins, []
|
39
|
+
# causes all optional plugins to be run.
|
40
|
+
default :run_all_plugins, false
|
41
|
+
# optional plugins are the set of plugins that are marked optional but you wish to run.
|
42
|
+
default :optional_plugins, []
|
39
43
|
end
|
40
44
|
end
|
41
45
|
|
data/lib/ohai/dsl.rb
CHANGED
data/lib/ohai/dsl/plugin.rb
CHANGED
@@ -32,15 +32,8 @@ module Ohai
|
|
32
32
|
name.is_a?(Symbol) && name.to_s.match(/^[^A-Z]|_/).nil?
|
33
33
|
end
|
34
34
|
|
35
|
-
|
36
|
-
|
37
|
-
def self.strict_const_defined?(const)
|
38
|
-
const_defined?(const)
|
39
|
-
end
|
40
|
-
else
|
41
|
-
def self.strict_const_defined?(const)
|
42
|
-
const_defined?(const, false)
|
43
|
-
end
|
35
|
+
def self.strict_const_defined?(const)
|
36
|
+
const_defined?(const, false)
|
44
37
|
end
|
45
38
|
end
|
46
39
|
|
@@ -49,6 +42,7 @@ module Ohai
|
|
49
42
|
|
50
43
|
plugin = nil
|
51
44
|
|
45
|
+
# avoid already initialized constant warnings if already defined
|
52
46
|
if NamedPlugin.strict_const_defined?(name)
|
53
47
|
plugin = NamedPlugin.const_get(name)
|
54
48
|
plugin.class_eval(&block)
|
@@ -86,9 +80,11 @@ module Ohai
|
|
86
80
|
|
87
81
|
attr_reader :data
|
88
82
|
attr_reader :failed
|
83
|
+
attr_reader :logger
|
89
84
|
|
90
|
-
def initialize(data)
|
85
|
+
def initialize(data, logger)
|
91
86
|
@data = data
|
87
|
+
@logger = logger.with_child({ subsystem: "plugin", plugin: name })
|
92
88
|
@has_run = false
|
93
89
|
@failed = false
|
94
90
|
end
|
@@ -97,7 +93,7 @@ module Ohai
|
|
97
93
|
@has_run = true
|
98
94
|
|
99
95
|
if Ohai.config[:disabled_plugins].include?(name)
|
100
|
-
|
96
|
+
logger.trace("Skipping disabled plugin #{name}")
|
101
97
|
else
|
102
98
|
run_plugin
|
103
99
|
end
|
@@ -161,9 +157,9 @@ module Ohai
|
|
161
157
|
# Will raise a TypeError if we hit a subattribute that is not a
|
162
158
|
# Hash, Mash, or Array.
|
163
159
|
keys = [name] + attrs
|
164
|
-
attribute = keys[0..-2].inject(@data) do |
|
165
|
-
|
166
|
-
|
160
|
+
attribute = keys[0..-2].inject(@data) do |atts, key|
|
161
|
+
atts[key] ||= Mash.new
|
162
|
+
atts[key]
|
167
163
|
end
|
168
164
|
|
169
165
|
# Set the subattribute to the value.
|
@@ -188,8 +184,8 @@ module Ohai
|
|
188
184
|
raise e
|
189
185
|
rescue => e
|
190
186
|
@failed = true
|
191
|
-
|
192
|
-
e.backtrace.each { |line|
|
187
|
+
logger.trace("Plugin #{name} threw #{e.inspect}")
|
188
|
+
e.backtrace.each { |line| logger.trace( line ) }
|
193
189
|
end
|
194
190
|
|
195
191
|
def method_missing(name, *args)
|
@@ -24,8 +24,8 @@ module Ohai
|
|
24
24
|
attr_reader :version
|
25
25
|
attr_reader :source
|
26
26
|
|
27
|
-
def initialize(data)
|
28
|
-
super(data)
|
27
|
+
def initialize(data, logger)
|
28
|
+
super(data, logger)
|
29
29
|
@source = self.class.sources
|
30
30
|
@version = :version7
|
31
31
|
end
|
@@ -66,6 +66,14 @@ module Ohai
|
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
|
+
def self.optional(opt = true)
|
70
|
+
@optional = opt
|
71
|
+
end
|
72
|
+
|
73
|
+
def self.optional?
|
74
|
+
!!@optional
|
75
|
+
end
|
76
|
+
|
69
77
|
def self.collect_data(platform = :default, *other_platforms, &block)
|
70
78
|
[platform, other_platforms].flatten.each do |plat|
|
71
79
|
if data_collector.has_key?(plat)
|
@@ -89,16 +97,20 @@ module Ohai
|
|
89
97
|
elsif collector.has_key?(:default)
|
90
98
|
instance_eval(&collector[:default])
|
91
99
|
else
|
92
|
-
|
100
|
+
logger.trace("Plugin #{name}: No data to collect. Skipping...")
|
93
101
|
end
|
94
102
|
end
|
95
103
|
|
104
|
+
def optional?
|
105
|
+
self.class.optional?
|
106
|
+
end
|
107
|
+
|
96
108
|
def provides(*paths)
|
97
|
-
|
109
|
+
logger.warn("[UNSUPPORTED OPERATION] \'provides\' is no longer supported in a \'collect_data\' context. Please specify \'provides\' before collecting plugin data. Ignoring command \'provides #{paths.join(", ")}")
|
98
110
|
end
|
99
111
|
|
100
112
|
def require_plugin(*args)
|
101
|
-
|
113
|
+
logger.warn("[UNSUPPORTED OPERATION] \'require_plugin\' is no longer supported. Please use \'depends\' instead.\nIgnoring plugin(s) #{args.join(", ")}")
|
102
114
|
end
|
103
115
|
|
104
116
|
def configuration(option, *options)
|