ohai 8.23.0 → 8.24.0
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/common/dmi.rb +3 -0
- data/lib/ohai/config.rb +1 -1
- data/lib/ohai/loader.rb +1 -1
- data/lib/ohai/mixin/ec2_metadata.rb +2 -2
- data/lib/ohai/plugins/ec2.rb +2 -0
- data/lib/ohai/plugins/linux/mdadm.rb +10 -3
- data/lib/ohai/plugins/lua.rb +3 -1
- data/lib/ohai/plugins/scala.rb +4 -3
- data/lib/ohai/system.rb +1 -0
- data/lib/ohai/version.rb +1 -1
- data/ohai.gemspec +1 -5
- data/spec/unit/loader_spec.rb +1 -1
- data/spec/unit/plugins/ec2_spec.rb +43 -0
- data/spec/unit/plugins/linux/mdadm_spec.rb +6 -0
- data/spec/unit/plugins/lua_spec.rb +8 -2
- data/spec/unit/plugins/scala_spec.rb +2 -2
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 07d099fa68ce5783f29292000c8bb150e29b96a0
|
4
|
+
data.tar.gz: 5c7b6897d48af717c7371227a03c2897f3f30522
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e34a92fa1e6c2ca35a92ea1d3ef1be961a5b178dd788eddabc8b77ba57fd02e7b4ccbe25c80a3271ea4c91a165ab60372b60654933661bd5afbcf5db5c663594
|
7
|
+
data.tar.gz: 432e34cc2e643412f89db7d7919cd6fda6a5c332233c22b495919fda103824a88c28d5973b8980061b315d835bf72722d998615591838980564a1dbb5771c3ac
|
data/Gemfile
CHANGED
data/lib/ohai/common/dmi.rb
CHANGED
@@ -65,6 +65,9 @@ module Ohai
|
|
65
65
|
37 => "memory_channel",
|
66
66
|
38 => "ipmi_device",
|
67
67
|
39 => "power_supply",
|
68
|
+
40 => "additional_information",
|
69
|
+
41 => "onboard_devices_extended_information",
|
70
|
+
42 => "management_controller_host_interfaces",
|
68
71
|
126 => "disabled_entries",
|
69
72
|
127 => "end_of_table_marker",
|
70
73
|
}
|
data/lib/ohai/config.rb
CHANGED
@@ -47,7 +47,7 @@ module Ohai
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def default_plugin_path
|
50
|
-
[ File.expand_path(File.join(File.dirname(__FILE__), "plugins")) ]
|
50
|
+
[ File.expand_path(File.join(File.dirname(__FILE__), "plugins")), ChefConfig::Config.platform_specific_path("/etc/chef/ohai/plugins") ]
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
data/lib/ohai/loader.rb
CHANGED
@@ -40,7 +40,7 @@ module Ohai
|
|
40
40
|
# Finds all the *.rb files under the configured paths in :plugin_path
|
41
41
|
def self.find_all_in(plugin_dir)
|
42
42
|
unless Dir.exist?(plugin_dir)
|
43
|
-
Ohai::Log.
|
43
|
+
Ohai::Log.info("The plugin path #{plugin_dir} does not exist. Skipping...")
|
44
44
|
return []
|
45
45
|
end
|
46
46
|
|
@@ -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::
|
5
|
+
# Copyright:: 2009-2017 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");
|
@@ -43,7 +43,7 @@ module Ohai
|
|
43
43
|
EC2_METADATA_ADDR = "169.254.169.254" unless defined?(EC2_METADATA_ADDR)
|
44
44
|
EC2_SUPPORTED_VERSIONS = %w{ 1.0 2007-01-19 2007-03-01 2007-08-29 2007-10-10 2007-12-15
|
45
45
|
2008-02-01 2008-09-01 2009-04-04 2011-01-01 2011-05-01 2012-01-12
|
46
|
-
2014-11-05 2014-02-25 }
|
46
|
+
2014-11-05 2014-02-25 2016-04-19 2016-06-30 2016-09-02}
|
47
47
|
|
48
48
|
EC2_ARRAY_VALUES = %w{security-groups}
|
49
49
|
EC2_ARRAY_DIR = %w{network/interfaces/macs}
|
data/lib/ohai/plugins/ec2.rb
CHANGED
@@ -97,6 +97,8 @@ Ohai.plugin(:EC2) do
|
|
97
97
|
end
|
98
98
|
ec2[:userdata] = fetch_userdata
|
99
99
|
ec2[:account_id] = fetch_dynamic_data["accountId"]
|
100
|
+
ec2[:availability_zone] = fetch_dynamic_data["availabilityZone"]
|
101
|
+
ec2[:region] = fetch_dynamic_data["region"]
|
100
102
|
# ASCII-8BIT is equivalent to BINARY in this case
|
101
103
|
if ec2[:userdata] && ec2[:userdata].encoding.to_s == "ASCII-8BIT"
|
102
104
|
Ohai::Log.debug("Plugin EC2: Binary UserData Found. Storing in base64")
|
@@ -1,6 +1,8 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Tim Smith <tsmith@limelight.com>
|
3
|
+
# Author:: Phil Dibowitz <phild@ipomc.com>
|
3
4
|
# Copyright:: Copyright (c) 2013-2014, Limelight Networks, Inc.
|
5
|
+
# Copyright:: Copyright (c) 2017 Facebook, Inc.
|
4
6
|
# Plugin:: mdadm
|
5
7
|
#
|
6
8
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -52,15 +54,19 @@ Ohai.plugin(:Mdadm) do
|
|
52
54
|
collect_data(:linux) do
|
53
55
|
# gather a list of all raid arrays
|
54
56
|
if File.exist?("/proc/mdstat")
|
55
|
-
devices =
|
57
|
+
devices = {}
|
56
58
|
File.open("/proc/mdstat").each do |line|
|
57
|
-
|
59
|
+
if line =~ /(md[0-9]+)/
|
60
|
+
device = Regexp.last_match[1]
|
61
|
+
pieces = line.split(/\s+/)
|
62
|
+
devices[device] = pieces[4..-1].map { |s| s.match(/(.+)\[\d\]/)[1] }
|
63
|
+
end
|
58
64
|
end
|
59
65
|
|
60
66
|
# create the mdadm mash and gather individual information if devices are present
|
61
67
|
unless devices.empty?
|
62
68
|
mdadm Mash.new
|
63
|
-
devices.sort.each do |device|
|
69
|
+
devices.keys.sort.each do |device|
|
64
70
|
mdadm[device] = Mash.new
|
65
71
|
|
66
72
|
# gather detailed information on the array
|
@@ -68,6 +74,7 @@ Ohai.plugin(:Mdadm) do
|
|
68
74
|
|
69
75
|
# if the mdadm command was sucessful pass so.stdout to create_raid_device_mash to grab the tidbits we want
|
70
76
|
mdadm[device] = create_raid_device_mash(so.stdout) if so.stdout
|
77
|
+
mdadm[device]["members"] = devices[device]
|
71
78
|
end
|
72
79
|
end
|
73
80
|
end
|
data/lib/ohai/plugins/lua.rb
CHANGED
@@ -27,7 +27,9 @@ Ohai.plugin(:Lua) do
|
|
27
27
|
# Lua 5.2.4 Copyright (C) 1994-2015 Lua.org, PUC-Rio
|
28
28
|
if so.exitstatus == 0
|
29
29
|
lua = Mash.new
|
30
|
-
lua
|
30
|
+
# at some point in lua's history they went from outputting the version
|
31
|
+
# on stderr to doing it on stdout. This handles old / new versions
|
32
|
+
lua[:version] = so.stdout.empty? ? so.stderr.split[1] : so.stdout.split[1]
|
31
33
|
languages[:lua] = lua if lua[:version]
|
32
34
|
end
|
33
35
|
rescue Ohai::Exceptions::Exec
|
data/lib/ohai/plugins/scala.rb
CHANGED
@@ -23,9 +23,10 @@ Ohai.plugin(:Scala) do
|
|
23
23
|
begin
|
24
24
|
so = shell_out("scala -version")
|
25
25
|
# Sample output:
|
26
|
-
#
|
26
|
+
# cat: /release: No such file or directory
|
27
|
+
# Scala code runner version 2.12.1 -- Copyright 2002-2016, LAMP/EPFL and Lightbend, Inc.
|
27
28
|
if so.exitstatus == 0
|
28
|
-
scala[:version] = so.stderr.
|
29
|
+
scala[:version] = so.stderr.match(/.*version (\S*)/)[1]
|
29
30
|
end
|
30
31
|
rescue Ohai::Exceptions::Exec
|
31
32
|
Ohai::Log.debug('Plugin Scala: Could not shell_out "scala -version". Skipping data')
|
@@ -34,7 +35,7 @@ Ohai.plugin(:Scala) do
|
|
34
35
|
# Check for sbt
|
35
36
|
begin
|
36
37
|
# sbt launcher version 0.13.7
|
37
|
-
so = shell_out("sbt --version")
|
38
|
+
so = shell_out("sbt --version", timeout: 5)
|
38
39
|
if so.exitstatus == 0
|
39
40
|
scala[:sbt] = Mash.new
|
40
41
|
scala[:sbt][:version] = so.stdout.split[3]
|
data/lib/ohai/system.rb
CHANGED
data/lib/ohai/version.rb
CHANGED
data/ohai.gemspec
CHANGED
@@ -25,15 +25,11 @@ Gem::Specification.new do |s|
|
|
25
25
|
s.add_dependency "ipaddress"
|
26
26
|
s.add_dependency "wmi-lite", "~> 1.0"
|
27
27
|
s.add_dependency "ffi", "~> 1.9"
|
28
|
+
s.add_dependency "chef-config", ">= 12.5.0.alpha.1", "< 14"
|
28
29
|
# Note for ohai developers: If chef-config causes you grief, try:
|
29
30
|
# bundle install --with development
|
30
31
|
# this should work as long as chef is a development dependency in Gemfile.
|
31
32
|
#
|
32
|
-
# Chef depends on ohai and chef-config. Ohai depends on chef-config. The
|
33
|
-
# version of chef-config that chef depends on is whatver version chef
|
34
|
-
# happens to be on master. This will need to be updated again once work on
|
35
|
-
# Chef 13 starts, otherwise builds will break.
|
36
|
-
s.add_dependency "chef-config", ">= 12.5.0.alpha.1", "< 13"
|
37
33
|
|
38
34
|
s.bindir = "bin"
|
39
35
|
s.executables = %w{ohai}
|
data/spec/unit/loader_spec.rb
CHANGED
@@ -222,7 +222,7 @@ EOF
|
|
222
222
|
|
223
223
|
describe "when plugin directory does not exist" do
|
224
224
|
it "logs an invalid plugin path warning" do
|
225
|
-
expect(Ohai::Log).to receive(:
|
225
|
+
expect(Ohai::Log).to receive(:info).with(/The plugin path.*does not exist/)
|
226
226
|
allow(Dir).to receive(:exist?).with("/bogus/dir").and_return(false)
|
227
227
|
Ohai::Loader::PluginFile.find_all_in("/bogus/dir")
|
228
228
|
end
|
@@ -127,6 +127,49 @@ describe Ohai::System, "plugin ec2" do
|
|
127
127
|
expect(plugin[:ec2]["account_id"]).to eq("4815162342")
|
128
128
|
end
|
129
129
|
|
130
|
+
it "fetches AWS region" do
|
131
|
+
paths.each do |name, body|
|
132
|
+
expect(@http_client).to receive(:get).
|
133
|
+
with("/2012-01-12/#{name}").
|
134
|
+
and_return(double("Net::HTTP Response", :body => body, :code => "200"))
|
135
|
+
end
|
136
|
+
expect(@http_client).to receive(:get).
|
137
|
+
with("/2012-01-12/user-data/").
|
138
|
+
and_return(double("Net::HTTP Response", :body => "^_<8B>^H^H<C7>U^@^Csomething^@KT<C8><C9>,)<C9>IU(I-.I<CB><CC>I<E5>^B^@^Qz<BF><B0>^R^@^@^@", :code => "200"))
|
139
|
+
expect(@http_client).to receive(:get).
|
140
|
+
with("/2012-01-12/dynamic/instance-identity/document/").
|
141
|
+
and_return(double("Net::HTTP Response", :body => "{\"region\":\"us-east-1\"}", :code => "200"))
|
142
|
+
|
143
|
+
plugin.run
|
144
|
+
|
145
|
+
expect(plugin[:ec2]).not_to be_nil
|
146
|
+
expect(plugin[:ec2]["instance_type"]).to eq("c1.medium")
|
147
|
+
expect(plugin[:ec2]["ami_id"]).to eq("ami-5d2dc934")
|
148
|
+
expect(plugin[:ec2]["security_groups"]).to eql %w{group1 group2}
|
149
|
+
expect(plugin[:ec2]["region"]).to eq("us-east-1")
|
150
|
+
end
|
151
|
+
|
152
|
+
it "fetches AWS availability zone" do
|
153
|
+
paths.each do |name, body|
|
154
|
+
expect(@http_client).to receive(:get).
|
155
|
+
with("/2012-01-12/#{name}").
|
156
|
+
and_return(double("Net::HTTP Response", :body => body, :code => "200"))
|
157
|
+
end
|
158
|
+
expect(@http_client).to receive(:get).
|
159
|
+
with("/2012-01-12/user-data/").
|
160
|
+
and_return(double("Net::HTTP Response", :body => "^_<8B>^H^H<C7>U^@^Csomething^@KT<C8><C9>,)<C9>IU(I-.I<CB><CC>I<E5>^B^@^Qz<BF><B0>^R^@^@^@", :code => "200"))
|
161
|
+
expect(@http_client).to receive(:get).
|
162
|
+
with("/2012-01-12/dynamic/instance-identity/document/").
|
163
|
+
and_return(double("Net::HTTP Response", :body => "{\"availabilityZone\":\"us-east-1d\"}", :code => "200"))
|
164
|
+
|
165
|
+
plugin.run
|
166
|
+
|
167
|
+
expect(plugin[:ec2]).not_to be_nil
|
168
|
+
expect(plugin[:ec2]["instance_type"]).to eq("c1.medium")
|
169
|
+
expect(plugin[:ec2]["ami_id"]).to eq("ami-5d2dc934")
|
170
|
+
expect(plugin[:ec2]["security_groups"]).to eql %w{group1 group2}
|
171
|
+
expect(plugin[:ec2]["availability_zone"]).to eq("us-east-1d")
|
172
|
+
end
|
130
173
|
end
|
131
174
|
|
132
175
|
it "parses ec2 network/ directory as a multi-level hash" do
|
@@ -26,8 +26,8 @@ describe Ohai::System, "plugin lua" do
|
|
26
26
|
|
27
27
|
before(:each) do
|
28
28
|
plugin[:languages] = Mash.new
|
29
|
-
@
|
30
|
-
allow(plugin).to receive(:shell_out).with("lua -v").and_return(mock_shell_out(0, "", @
|
29
|
+
@message = "Lua 5.1.2 Copyright (C) 1994-2008 Lua.org, PUC-Rio\n"
|
30
|
+
allow(plugin).to receive(:shell_out).with("lua -v").and_return(mock_shell_out(0, "", @message))
|
31
31
|
end
|
32
32
|
|
33
33
|
it "gets the lua version from running lua -v" do
|
@@ -51,4 +51,10 @@ describe Ohai::System, "plugin lua" do
|
|
51
51
|
plugin.run
|
52
52
|
expect(plugin.languages).not_to have_key(:lua)
|
53
53
|
end
|
54
|
+
|
55
|
+
it "sets languages[:lua][:version] when 'lua -v' returns output on stdout not stderr" do
|
56
|
+
allow(plugin).to receive(:shell_out).with("lua -v").and_return(mock_shell_out(0, @message, ""))
|
57
|
+
plugin.run
|
58
|
+
expect(plugin.languages[:lua][:version]).to eql("5.1.2")
|
59
|
+
end
|
54
60
|
end
|
@@ -33,7 +33,7 @@ describe Ohai::System, "plugin scala" do
|
|
33
33
|
.with("scala -version")
|
34
34
|
.and_return(mock_shell_out(0, "", scala_out))
|
35
35
|
allow(plugin).to receive(:shell_out)
|
36
|
-
.with("sbt --version")
|
36
|
+
.with("sbt --version", { :timeout => 5 })
|
37
37
|
.and_return(mock_shell_out(0, sbt_out, ""))
|
38
38
|
end
|
39
39
|
|
@@ -80,7 +80,7 @@ describe Ohai::System, "plugin scala" do
|
|
80
80
|
.and_return(mock_shell_out(0, "", scala_out))
|
81
81
|
|
82
82
|
allow(plugin).to receive(:shell_out)
|
83
|
-
.with("sbt --version")
|
83
|
+
.with("sbt --version", { :timeout => 5 })
|
84
84
|
.and_raise( Ohai::Exceptions::Exec )
|
85
85
|
plugin.run
|
86
86
|
end
|
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: 8.
|
4
|
+
version: 8.24.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: 2017-
|
11
|
+
date: 2017-05-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: systemu
|
@@ -165,7 +165,7 @@ dependencies:
|
|
165
165
|
version: 12.5.0.alpha.1
|
166
166
|
- - "<"
|
167
167
|
- !ruby/object:Gem::Version
|
168
|
-
version: '
|
168
|
+
version: '14'
|
169
169
|
type: :runtime
|
170
170
|
prerelease: false
|
171
171
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -175,7 +175,7 @@ dependencies:
|
|
175
175
|
version: 12.5.0.alpha.1
|
176
176
|
- - "<"
|
177
177
|
- !ruby/object:Gem::Version
|
178
|
-
version: '
|
178
|
+
version: '14'
|
179
179
|
description: Ohai profiles your system and emits JSON
|
180
180
|
email: adam@chef.io
|
181
181
|
executables:
|
@@ -546,7 +546,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
546
546
|
version: '0'
|
547
547
|
requirements: []
|
548
548
|
rubyforge_project:
|
549
|
-
rubygems_version: 2.
|
549
|
+
rubygems_version: 2.6.11
|
550
550
|
signing_key:
|
551
551
|
specification_version: 4
|
552
552
|
summary: Ohai profiles your system and emits JSON
|