ohai 14.3.0 → 14.4.0
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.
- checksums.yaml +4 -4
- data/Rakefile +0 -11
- data/lib/ohai/application.rb +5 -2
- data/lib/ohai/config.rb +1 -0
- data/lib/ohai/dsl/plugin/versionvii.rb +2 -5
- data/lib/ohai/mixin/command.rb +2 -2
- data/lib/ohai/plugins/windows/system_enclosure.rb +30 -0
- data/lib/ohai/system.rb +7 -3
- data/lib/ohai/version.rb +1 -1
- data/ohai.gemspec +1 -1
- data/spec/unit/dsl/plugin_spec.rb +10 -11
- data/spec/unit/loader_spec.rb +1 -1
- data/spec/unit/plugins/windows/system_enclosure_spec.rb +45 -0
- data/spec/unit/system_spec.rb +14 -3
- metadata +7 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1a0ff48c97fc8f901992098c99017a30e676368e4e7fb2ad1aa997bdcb88b49c
|
4
|
+
data.tar.gz: 0a5ba9acc9bc9dd07c4720fd295cde3738f35af3b3209b8427da966040bd0e23
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d646c6259b0d415ae8c30370e40e27f87ea3f3ebc10c730e98457f2020fe8c3222a2c611be3a46fa16a108070f6d0ecf761e30c002b6c2b4f39b10e5f32db976
|
7
|
+
data.tar.gz: 9475c71f49b3fadb9d9e1b5da81d2ae18ac984e37005b25d283a0bf093f22bba48cbeb574c22d3e11256751813391d2ce8e9ead474a6943eb39b968731e8255e
|
data/Rakefile
CHANGED
@@ -22,14 +22,3 @@ require "rubocop/rake_task"
|
|
22
22
|
RuboCop::RakeTask.new(:style) do |task|
|
23
23
|
task.options += ["--display-cop-names", "--no-color"]
|
24
24
|
end
|
25
|
-
|
26
|
-
begin
|
27
|
-
require "github_changelog_generator/task"
|
28
|
-
|
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
|
35
|
-
end
|
data/lib/ohai/application.rb
CHANGED
@@ -34,8 +34,11 @@ class Ohai::Application
|
|
34
34
|
option :directory,
|
35
35
|
short: "-d DIRECTORY",
|
36
36
|
long: "--directory DIRECTORY",
|
37
|
-
description: "A directory to add to the Ohai plugin search path",
|
38
|
-
proc: lambda { |path|
|
37
|
+
description: "A directory to add to the Ohai plugin search path. If passing multiple directories use this option more than once.",
|
38
|
+
proc: lambda { |path, path_array|
|
39
|
+
(path_array ||= []) << Ohai::Config.platform_specific_path(path)
|
40
|
+
path_array
|
41
|
+
}
|
39
42
|
|
40
43
|
option :log_level,
|
41
44
|
short: "-l LEVEL",
|
data/lib/ohai/config.rb
CHANGED
@@ -108,11 +108,8 @@ module Ohai
|
|
108
108
|
# @param block [block] the actual code to collect data for the specified platforms
|
109
109
|
def self.collect_data(platform = :default, *other_platforms, &block)
|
110
110
|
[platform, other_platforms].flatten.each do |plat|
|
111
|
-
if data_collector.key?(plat)
|
112
|
-
|
113
|
-
else
|
114
|
-
data_collector[plat] = block
|
115
|
-
end
|
111
|
+
Ohai::Log.warn("collect_data already defined on platform '#{plat}' for #{self}, last plugin seen will be used") if data_collector.key?(plat)
|
112
|
+
data_collector[plat] = block
|
116
113
|
end
|
117
114
|
end
|
118
115
|
|
data/lib/ohai/mixin/command.rb
CHANGED
@@ -28,8 +28,8 @@ module Ohai
|
|
28
28
|
# accept a command and any of the mixlib-shellout options
|
29
29
|
def shell_out(cmd, **options)
|
30
30
|
options = options.dup
|
31
|
-
# unless specified by the caller timeout after 30 seconds
|
32
|
-
options[:timeout] ||=
|
31
|
+
# unless specified by the caller timeout after configured timeout (default 30 seconds)
|
32
|
+
options[:timeout] ||= Ohai::Config.ohai[:shellout_timeout]
|
33
33
|
unless RUBY_PLATFORM =~ /mswin|mingw32|windows/
|
34
34
|
options[:env] = options.key?(:env) ? options[:env].dup : {}
|
35
35
|
options[:env]["PATH"] ||= ((ENV["PATH"] || "").split(":") + %w{/usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin}).join(":")
|
@@ -0,0 +1,30 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Stuart Preston (<stuart@chef.io>)
|
3
|
+
# Copyright:: Copyright (c) 2018, Chef Software Inc.
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
Ohai.plugin :SystemEnclosure do
|
20
|
+
provides "system_enclosure"
|
21
|
+
|
22
|
+
collect_data(:windows) do
|
23
|
+
require "wmi-lite/wmi"
|
24
|
+
system_enclosure Mash.new
|
25
|
+
wmi = WmiLite::Wmi.new
|
26
|
+
wmi_object = wmi.first_of("Win32_SystemEnclosure").wmi_ole_object
|
27
|
+
system_enclosure[:manufacturer] = wmi_object.invoke("manufacturer")
|
28
|
+
system_enclosure[:serialnumber] = wmi_object.invoke("serialnumber")
|
29
|
+
end
|
30
|
+
end
|
data/lib/ohai/system.rb
CHANGED
@@ -176,9 +176,13 @@ module Ohai
|
|
176
176
|
def configure_ohai
|
177
177
|
Ohai.config.merge!(@config)
|
178
178
|
|
179
|
-
|
180
|
-
|
181
|
-
|
179
|
+
# add any additional CLI passed directories to the plugin path excluding duplicates
|
180
|
+
unless Ohai.config[:directory].nil?
|
181
|
+
# make sure the directory config is an array since it could be a string set in client.rb
|
182
|
+
Array(Ohai.config[:directory]).each do |dir|
|
183
|
+
next if Ohai.config[:plugin_path].include?(dir)
|
184
|
+
Ohai.config[:plugin_path] << dir
|
185
|
+
end
|
182
186
|
end
|
183
187
|
|
184
188
|
logger.debug("Running Ohai with the following configuration: #{Ohai.config.configuration}")
|
data/lib/ohai/version.rb
CHANGED
data/ohai.gemspec
CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |s|
|
|
17
17
|
|
18
18
|
s.add_dependency "systemu", "~> 2.6.4"
|
19
19
|
s.add_dependency "ffi-yajl", "~> 2.2"
|
20
|
-
s.add_dependency "mixlib-cli"
|
20
|
+
s.add_dependency "mixlib-cli", ">= 1.7.0" # 1.7+ needed to support passing multiple options
|
21
21
|
s.add_dependency "mixlib-config", "~> 2.0"
|
22
22
|
s.add_dependency "mixlib-log", "~> 2.0", ">= 2.0.1"
|
23
23
|
s.add_dependency "mixlib-shellout", "~> 2.0"
|
@@ -519,21 +519,20 @@ describe Ohai::DSL::Plugin::VersionVII do
|
|
519
519
|
end
|
520
520
|
|
521
521
|
it "fails a platform has already been defined in the same plugin" do
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
end
|
522
|
+
Ohai.plugin(:Test) { collect_data {} }
|
523
|
+
expect(Ohai::Log).to receive(:warn).with(/collect_data already defined on platform/).twice
|
524
|
+
Ohai.plugin(:Test) do
|
525
|
+
collect_data {}
|
526
|
+
collect_data {}
|
527
|
+
end
|
528
528
|
end
|
529
529
|
|
530
530
|
it "fails if a platform has already been defined in another plugin file" do
|
531
531
|
Ohai.plugin(:Test) { collect_data {} }
|
532
|
-
expect
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
end.to raise_error(Ohai::Exceptions::IllegalPluginDefinition, /collect_data already defined/)
|
532
|
+
expect(Ohai::Log).to receive(:warn).with(/collect_data already defined on platform/)
|
533
|
+
Ohai.plugin(:Test) do
|
534
|
+
collect_data {}
|
535
|
+
end
|
537
536
|
end
|
538
537
|
end
|
539
538
|
|
data/spec/unit/loader_spec.rb
CHANGED
@@ -130,7 +130,7 @@ EOF
|
|
130
130
|
|
131
131
|
describe "when the plugin defines collect_data on the same platform more than once" do
|
132
132
|
it "shoud log an illegal plugin definition warning" do
|
133
|
-
expect(
|
133
|
+
expect(Ohai::Log).to receive(:warn).with(/collect_data already defined on platform/)
|
134
134
|
loader.load_plugin(path_to("illegal_def.rb"))
|
135
135
|
end
|
136
136
|
|
@@ -0,0 +1,45 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Stuart Preston (<stuart@chef.io>)
|
3
|
+
# Copyright:: Copyright (c) 2018, Chef Software Inc.
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
require_relative "../../../spec_helper.rb"
|
20
|
+
|
21
|
+
describe Ohai::System, "System Enclosure", :windows_only do
|
22
|
+
before do
|
23
|
+
require "wmi-lite/wmi"
|
24
|
+
@plugin = get_plugin("windows/system_enclosure")
|
25
|
+
manufacturer = double("WIN32OLE", name: "manufacturer", value: "My Fake Manufacturer")
|
26
|
+
serialnumber = double("WIN32OLE", name: "serialnumber", value: "1234123412341234")
|
27
|
+
property_map = [ manufacturer, serialnumber ]
|
28
|
+
|
29
|
+
wmi_ole_object = double( "WIN32OLE", properties_: property_map)
|
30
|
+
allow(wmi_ole_object).to receive(:invoke).with(manufacturer.name).and_return(manufacturer.value)
|
31
|
+
allow(wmi_ole_object).to receive(:invoke).with(serialnumber.name).and_return(serialnumber.value)
|
32
|
+
wmi_object = WmiLite::Wmi::Instance.new(wmi_ole_object)
|
33
|
+
expect_any_instance_of(WmiLite::Wmi).to receive(:first_of).with(("Win32_SystemEnclosure")).and_return(wmi_object)
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should return the manufacturer" do
|
37
|
+
@plugin.run
|
38
|
+
expect(@plugin["system_enclosure"]["manufacturer"]).to eql("My Fake Manufacturer")
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should return a serial number" do
|
42
|
+
@plugin.run
|
43
|
+
expect(@plugin["system_enclosure"]["serialnumber"]).to eql("1234123412341234")
|
44
|
+
end
|
45
|
+
end
|
data/spec/unit/system_spec.rb
CHANGED
@@ -38,7 +38,7 @@ describe "Ohai::System" do
|
|
38
38
|
it "merges provided configuration options into the ohai config context" do
|
39
39
|
config = {
|
40
40
|
disabled_plugins: [ :Foo, :Baz ],
|
41
|
-
directory: "/some/extra/plugins",
|
41
|
+
directory: ["/some/extra/plugins"],
|
42
42
|
critical_plugins: [ :Foo, :Bar ],
|
43
43
|
}
|
44
44
|
Ohai::System.new(config)
|
@@ -47,13 +47,24 @@ describe "Ohai::System" do
|
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
|
-
context "when directory is configured" do
|
50
|
+
context "when a single directory is configured as a string" do
|
51
51
|
let(:directory) { "/some/fantastic/plugins" }
|
52
52
|
|
53
53
|
it "adds directory to plugin_path" do
|
54
54
|
Ohai.config[:directory] = directory
|
55
55
|
Ohai::System.new({ invoked_from_cli: true })
|
56
|
-
expect(Ohai.config[:plugin_path]).to include(
|
56
|
+
expect(Ohai.config[:plugin_path]).to include("/some/fantastic/plugins")
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
context "when multiple directories are configured" do
|
61
|
+
let(:directory) { ["/some/fantastic/plugins", "/some/other/plugins"] }
|
62
|
+
|
63
|
+
it "adds directories to plugin_path" do
|
64
|
+
Ohai.config[:directory] = directory
|
65
|
+
Ohai::System.new({ invoked_from_cli: true })
|
66
|
+
expect(Ohai.config[:plugin_path]).to include("/some/fantastic/plugins")
|
67
|
+
expect(Ohai.config[:plugin_path]).to include("/some/other/plugins")
|
57
68
|
end
|
58
69
|
end
|
59
70
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ohai
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 14.
|
4
|
+
version: 14.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Jacob
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-08-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: systemu
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 1.7.0
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 1.7.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: mixlib-config
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -336,6 +336,7 @@ files:
|
|
336
336
|
- lib/ohai/plugins/windows/memory.rb
|
337
337
|
- lib/ohai/plugins/windows/network.rb
|
338
338
|
- lib/ohai/plugins/windows/platform.rb
|
339
|
+
- lib/ohai/plugins/windows/system_enclosure.rb
|
339
340
|
- lib/ohai/plugins/windows/virtualization.rb
|
340
341
|
- lib/ohai/plugins/zpools.rb
|
341
342
|
- lib/ohai/provides_map.rb
|
@@ -513,6 +514,7 @@ files:
|
|
513
514
|
- spec/unit/plugins/windows/fips_spec.rb
|
514
515
|
- spec/unit/plugins/windows/kernel_spec.rb
|
515
516
|
- spec/unit/plugins/windows/memory_spec.rb
|
517
|
+
- spec/unit/plugins/windows/system_enclosure_spec.rb
|
516
518
|
- spec/unit/plugins/windows/uptime_spec.rb
|
517
519
|
- spec/unit/plugins/windows/virtualization_spec.rb
|
518
520
|
- spec/unit/plugins/zpools_spec.rb
|
@@ -541,7 +543,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
541
543
|
version: '0'
|
542
544
|
requirements: []
|
543
545
|
rubyforge_project:
|
544
|
-
rubygems_version: 2.7.
|
546
|
+
rubygems_version: 2.7.6
|
545
547
|
signing_key:
|
546
548
|
specification_version: 4
|
547
549
|
summary: Ohai profiles your system and emits JSON
|