ohai 8.26.1 → 13.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Gemfile +3 -4
- data/Rakefile +14 -0
- data/lib/ohai/application.rb +1 -0
- data/lib/ohai/config.rb +2 -88
- data/lib/ohai/dsl/plugin.rb +0 -4
- data/lib/ohai/exception.rb +0 -1
- data/lib/ohai/loader.rb +11 -2
- data/lib/ohai/log.rb +3 -1
- data/lib/ohai/mixin/command.rb +1 -318
- data/lib/ohai/mixin/do_metadata.rb +47 -0
- data/lib/ohai/mixin/ec2_metadata.rb +2 -29
- data/lib/ohai/mixin/gce_metadata.rb +0 -37
- data/lib/ohai/mixin/http_helper.rb +56 -0
- data/lib/ohai/mixin/network_constants.rb +0 -5
- data/lib/ohai/plugins/cloud.rb +144 -157
- data/lib/ohai/plugins/darwin/filesystem.rb +68 -22
- data/lib/ohai/plugins/digital_ocean.rb +24 -42
- data/lib/ohai/plugins/dmi.rb +81 -77
- data/lib/ohai/plugins/ec2.rb +33 -60
- data/lib/ohai/plugins/gce.rb +3 -1
- data/lib/ohai/plugins/hostname.rb +1 -16
- data/lib/ohai/plugins/linux/filesystem.rb +130 -81
- data/lib/ohai/plugins/linux/mdadm.rb +3 -45
- data/lib/ohai/plugins/linux/network.rb +1 -26
- data/lib/ohai/plugins/linux/platform.rb +4 -2
- data/lib/ohai/plugins/linux/virtualization.rb +1 -5
- data/lib/ohai/plugins/scala.rb +1 -13
- data/lib/ohai/plugins/solaris2/network.rb +1 -2
- data/lib/ohai/plugins/uptime.rb +0 -9
- data/lib/ohai/plugins/windows/cpu.rb +2 -1
- data/lib/ohai/plugins/windows/network.rb +1 -1
- data/lib/ohai/runner.rb +0 -5
- data/lib/ohai/system.rb +38 -8
- data/lib/ohai/version.rb +2 -2
- data/ohai.gemspec +1 -1
- data/spec/functional/application_spec.rb +0 -40
- data/spec/functional/plugins/powershell_spec.rb +1 -1
- data/spec/functional/plugins/root_group_spec.rb +1 -1
- data/spec/functional/plugins/windows/uptime_spec.rb +1 -1
- data/spec/ohai_spec.rb +1 -1
- data/spec/support/integration_helper.rb +17 -0
- data/spec/support/platform_helpers.rb +17 -0
- data/spec/unit/application_spec.rb +0 -1
- data/spec/unit/config_spec.rb +0 -111
- data/spec/unit/dsl/plugin_spec.rb +1 -1
- data/spec/unit/hints_spec.rb +1 -1
- data/spec/unit/loader_spec.rb +26 -1
- data/spec/unit/mixin/command_spec.rb +1 -69
- 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 +0 -1
- data/spec/unit/plugins/abort_spec.rb +1 -1
- data/spec/unit/plugins/aix/cpu_spec.rb +1 -1
- data/spec/unit/plugins/aix/filesystem_spec.rb +2 -1
- 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 +1 -1
- data/spec/unit/plugins/aix/os_spec.rb +1 -1
- 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 +1 -1
- data/spec/unit/plugins/azure_spec.rb +1 -1
- data/spec/unit/plugins/bsd/filesystem_spec.rb +1 -1
- data/spec/unit/plugins/bsd/virtualization_spec.rb +1 -1
- data/spec/unit/plugins/c_spec.rb +1 -1
- data/spec/unit/plugins/chef_spec.rb +1 -2
- data/spec/unit/plugins/cloud_spec.rb +210 -50
- data/spec/unit/plugins/darwin/cpu_spec.rb +1 -1
- data/spec/unit/plugins/darwin/filesystem_spec.rb +62 -13
- data/spec/unit/plugins/darwin/hardware_spec.rb +2 -2
- 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/system_profiler_spec.rb +2 -9
- data/spec/unit/plugins/darwin/virtualization_spec.rb +1 -1
- data/spec/unit/plugins/digital_ocean_spec.rb +39 -110
- data/spec/unit/plugins/dmi_spec.rb +1 -1
- data/spec/unit/plugins/ec2_spec.rb +10 -62
- 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 +1 -1
- 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/os_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 +16 -41
- data/spec/unit/plugins/init_package_spec.rb +1 -1
- data/spec/unit/plugins/ip_scopes_spec.rb +18 -6
- data/spec/unit/plugins/java_spec.rb +1 -1
- data/spec/unit/plugins/joyent_spec.rb +17 -1
- 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 +1 -2
- data/spec/unit/plugins/linux/filesystem_spec.rb +207 -201
- data/spec/unit/plugins/linux/fips_spec.rb +1 -1
- data/spec/unit/plugins/linux/hostname_spec.rb +1 -1
- data/spec/unit/plugins/linux/hostnamectl_spec.rb +1 -1
- data/spec/unit/plugins/linux/kernel_spec.rb +1 -1
- data/spec/unit/plugins/linux/lsb_spec.rb +1 -1
- data/spec/unit/plugins/linux/machineid_spec.rb +1 -1
- data/spec/unit/plugins/linux/mdadm_spec.rb +2 -68
- data/spec/unit/plugins/linux/memory_spec.rb +1 -1
- data/spec/unit/plugins/linux/network_spec.rb +3 -44
- data/spec/unit/plugins/linux/platform_spec.rb +4 -4
- data/spec/unit/plugins/linux/sessions_spec.rb +1 -1
- data/spec/unit/plugins/linux/uptime_spec.rb +1 -1
- data/spec/unit/plugins/linux/virtualization_spec.rb +1 -28
- data/spec/unit/plugins/lua_spec.rb +1 -1
- data/spec/unit/plugins/mono_spec.rb +1 -1
- 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 +1 -1
- 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 +2 -3
- data/spec/unit/plugins/os_spec.rb +1 -1
- data/spec/unit/plugins/packages_spec.rb +1 -1
- data/spec/unit/plugins/passwd_spec.rb +17 -1
- data/spec/unit/plugins/perl_spec.rb +1 -1
- data/spec/unit/plugins/php_spec.rb +1 -1
- data/spec/unit/plugins/platform_spec.rb +1 -1
- data/spec/unit/plugins/powershell_spec.rb +1 -1
- data/spec/unit/plugins/python_spec.rb +1 -1
- data/spec/unit/plugins/rackspace_spec.rb +1 -2
- data/spec/unit/plugins/root_group_spec.rb +2 -2
- 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 +3 -37
- 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 +1 -1
- data/spec/unit/plugins/solaris2/dmi_spec.rb +1 -1
- 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 +7 -4
- data/spec/unit/plugins/solaris2/platform_spec.rb +1 -1
- data/spec/unit/plugins/solaris2/virtualization_spec.rb +1 -1
- data/spec/unit/plugins/solaris2/zpools_spec.rb +1 -1
- data/spec/unit/plugins/ssh_host_keys_spec.rb +1 -1
- data/spec/unit/plugins/sysconf_spec.rb +1 -1
- 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 +2 -1
- data/spec/unit/plugins/windows/cpu_spec.rb +9 -2
- data/spec/unit/plugins/windows/fips_spec.rb +1 -1
- data/spec/unit/plugins/windows/memory_spec.rb +1 -1
- data/spec/unit/plugins/windows/uptime_spec.rb +1 -1
- data/spec/unit/plugins/windows/virtualization_spec.rb +1 -1
- data/spec/unit/provides_map_spec.rb +1 -1
- data/spec/unit/runner_spec.rb +1 -1
- data/spec/unit/system_spec.rb +68 -76
- data/spec/unit/util/file_helper_spec.rb +1 -1
- data/spec/unit/util/ip_helper_spec.rb +1 -1
- metadata +6 -20
- data/lib/ohai/plugins/cloud_v2.rb +0 -315
- data/lib/ohai/plugins/darwin/filesystem2.rb +0 -107
- data/lib/ohai/plugins/linux/filesystem2.rb +0 -223
- data/lib/ohai/plugins/linux/lspci.rb +0 -76
- data/lib/ohai/plugins/network_listeners.rb +0 -60
- data/lib/ohai/plugins/sigar/cpu.rb +0 -44
- data/lib/ohai/plugins/sigar/filesystem.rb +0 -50
- data/lib/ohai/plugins/sigar/memory.rb +0 -39
- data/lib/ohai/plugins/sigar/network.rb +0 -168
- data/lib/ohai/plugins/sigar/network_route.rb +0 -64
- data/lib/ohai/plugins/sigar/platform.rb +0 -30
- data/spec/unit/plugins/cloud_v2_spec.rb +0 -389
- data/spec/unit/plugins/darwin/filesystem2_spec.rb +0 -139
- data/spec/unit/plugins/linux/filesystem2_spec.rb +0 -437
- data/spec/unit/plugins/linux/lspci_spec.rb +0 -133
- data/spec/unit/plugins/sigar/network_route_spec.rb +0 -148
@@ -26,10 +26,6 @@ Ohai.plugin(:Virtualization) do
|
|
26
26
|
which("lxc-version")
|
27
27
|
end
|
28
28
|
|
29
|
-
def docker_exists?
|
30
|
-
which("docker")
|
31
|
-
end
|
32
|
-
|
33
29
|
def nova_exists?
|
34
30
|
which("nova")
|
35
31
|
end
|
@@ -185,7 +181,7 @@ Ohai.plugin(:Virtualization) do
|
|
185
181
|
if File.exist?("/proc/self/cgroup")
|
186
182
|
cgroup_content = File.read("/proc/self/cgroup")
|
187
183
|
if cgroup_content =~ %r{^\d+:[^:]+:/(lxc|docker)/.+$} ||
|
188
|
-
cgroup_content =~ %r{^\d+:[^:]+:/[^/]+/(lxc|docker)
|
184
|
+
cgroup_content =~ %r{^\d+:[^:]+:/[^/]+/(lxc|docker)-.+$}
|
189
185
|
Ohai::Log.debug("Plugin Virtualization: /proc/self/cgroup indicates #{$1} container. Detecting as #{$1} guest")
|
190
186
|
virtualization[:system] = $1
|
191
187
|
virtualization[:role] = "guest"
|
data/lib/ohai/plugins/scala.rb
CHANGED
@@ -15,7 +15,7 @@
|
|
15
15
|
# limitations under the License.
|
16
16
|
|
17
17
|
Ohai.plugin(:Scala) do
|
18
|
-
provides "languages/scala"
|
18
|
+
provides "languages/scala"
|
19
19
|
depends "languages"
|
20
20
|
|
21
21
|
collect_data(:default) do
|
@@ -32,18 +32,6 @@ Ohai.plugin(:Scala) do
|
|
32
32
|
Ohai::Log.debug('Plugin Scala: Could not shell_out "scala -version". Skipping data')
|
33
33
|
end
|
34
34
|
|
35
|
-
# Check for sbt
|
36
|
-
begin
|
37
|
-
# sbt launcher version 0.13.7
|
38
|
-
so = shell_out("sbt --version", timeout: 5)
|
39
|
-
if so.exitstatus == 0
|
40
|
-
scala[:sbt] = Mash.new
|
41
|
-
scala[:sbt][:version] = so.stdout.split[3]
|
42
|
-
end
|
43
|
-
rescue Ohai::Exceptions::Exec
|
44
|
-
Ohai::Log.debug('Plugin Scala: Could not shell_out "sbt --version". Skipping data')
|
45
|
-
end
|
46
|
-
|
47
35
|
languages[:scala] = scala unless scala.empty?
|
48
36
|
end
|
49
37
|
end
|
@@ -103,8 +103,7 @@ Ohai.plugin(:Network) do
|
|
103
103
|
cint = nil
|
104
104
|
|
105
105
|
so.stdout.lines do |line|
|
106
|
-
|
107
|
-
if line =~ /^([0-9a-zA-Z\.\:\-]+): \S+ mtu (\d+) index (\d+)/
|
106
|
+
if line =~ /^([0-9a-zA-Z\.\:\-]+)\S/
|
108
107
|
cint = $1
|
109
108
|
iface[cint] = Mash.new unless iface[cint]
|
110
109
|
iface[cint][:mtu] = $2
|
data/lib/ohai/plugins/uptime.rb
CHANGED
@@ -43,15 +43,6 @@ Ohai.plugin(:Uptime) do
|
|
43
43
|
return [nil, nil]
|
44
44
|
end
|
45
45
|
|
46
|
-
collect_data(:hpux, :default) do
|
47
|
-
require "sigar"
|
48
|
-
|
49
|
-
sigar = Sigar.new
|
50
|
-
uptime = sigar.uptime.uptime
|
51
|
-
uptime_seconds uptime.to_i * 1000
|
52
|
-
uptime seconds_to_human(uptime.to_i)
|
53
|
-
end
|
54
|
-
|
55
46
|
collect_data(:darwin) do
|
56
47
|
data = collect_uptime("/usr/sbin/sysctl")
|
57
48
|
uptime_seconds data.first
|
@@ -60,7 +60,8 @@ Ohai.plugin(:CPU) do
|
|
60
60
|
processor["stepping"]
|
61
61
|
end
|
62
62
|
cpu[current_cpu]["physical_id"] = processor["deviceid"]
|
63
|
-
cpu[current_cpu]["model_name"] = processor["
|
63
|
+
cpu[current_cpu]["model_name"] = processor["name"]
|
64
|
+
cpu[current_cpu]["description"] = processor["description"]
|
64
65
|
cpu[current_cpu]["mhz"] = processor["maxclockspeed"].to_s
|
65
66
|
cpu[current_cpu]["cache_size"] = "#{processor['l2cachesize']} KB"
|
66
67
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: James Gartrell (<jgartrel@gmail.com>)
|
3
|
-
# Copyright:: Copyright (c) 2008-
|
3
|
+
# Copyright:: Copyright (c) 2008-2017, 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");
|
data/lib/ohai/runner.rb
CHANGED
@@ -22,13 +22,11 @@ require "ohai/dsl"
|
|
22
22
|
module Ohai
|
23
23
|
class Runner
|
24
24
|
|
25
|
-
attr_reader :failed_plugins
|
26
25
|
# safe_run: set to true if this runner will run plugins in
|
27
26
|
# safe-mode. default false.
|
28
27
|
def initialize(controller, safe_run = false)
|
29
28
|
@provides_map = controller.provides_map
|
30
29
|
@safe_run = safe_run
|
31
|
-
@failed_plugins = []
|
32
30
|
end
|
33
31
|
|
34
32
|
# Runs plugins and any un-run dependencies.
|
@@ -84,9 +82,6 @@ module Ohai
|
|
84
82
|
|
85
83
|
if dependency_providers.empty?
|
86
84
|
@safe_run ? next_plugin.safe_run : next_plugin.run
|
87
|
-
if next_plugin.failed
|
88
|
-
@failed_plugins << next_plugin.name
|
89
|
-
end
|
90
85
|
else
|
91
86
|
visited << next_plugin << dependency_providers.first
|
92
87
|
end
|
data/lib/ohai/system.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Adam Jacob (<adam@chef.io>)
|
3
|
-
# Copyright:: Copyright (c) 2008-
|
3
|
+
# Copyright:: Copyright (c) 2008-2017, 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");
|
@@ -39,10 +39,14 @@ module Ohai
|
|
39
39
|
attr_reader :provides_map
|
40
40
|
attr_reader :v6_dependency_solver
|
41
41
|
|
42
|
+
# the cli flag is used to determine if we're being constructed by
|
43
|
+
# something like chef-client (which doesn't not set this flag) and
|
44
|
+
# which sets up its own loggers, or if we're coming from Ohai::Application
|
45
|
+
# and therefore need to configure Ohai's own logger.
|
42
46
|
def initialize(config = {})
|
47
|
+
@cli = config[:invoked_from_cli]
|
43
48
|
@plugin_path = ""
|
44
49
|
@config = config
|
45
|
-
@failed_plugins = []
|
46
50
|
reset_system
|
47
51
|
end
|
48
52
|
|
@@ -52,7 +56,7 @@ module Ohai
|
|
52
56
|
@v6_dependency_solver = Hash.new
|
53
57
|
|
54
58
|
configure_ohai
|
55
|
-
configure_logging
|
59
|
+
configure_logging if @cli
|
56
60
|
|
57
61
|
@loader = Ohai::Loader.new(self)
|
58
62
|
@runner = Ohai::Runner.new(self, true)
|
@@ -103,11 +107,18 @@ module Ohai
|
|
103
107
|
Ohai::Log.error("Encountered error while running plugins: #{e.inspect}")
|
104
108
|
raise
|
105
109
|
end
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
+
|
111
|
+
# Freeze all strings.
|
112
|
+
freeze_strings!
|
113
|
+
end
|
114
|
+
|
115
|
+
def run_additional_plugins(plugin_path)
|
116
|
+
@loader.load_additional(plugin_path).each do |plugin|
|
117
|
+
Ohai::Log.debug "Running plugin #{plugin}"
|
118
|
+
@runner.run_plugin(plugin)
|
110
119
|
end
|
120
|
+
|
121
|
+
freeze_strings!
|
111
122
|
end
|
112
123
|
|
113
124
|
def have_v6_plugin?(name)
|
@@ -215,7 +226,6 @@ module Ohai
|
|
215
226
|
private
|
216
227
|
|
217
228
|
def configure_ohai
|
218
|
-
Ohai::Config.merge_deprecated_config
|
219
229
|
Ohai.config.merge!(@config)
|
220
230
|
|
221
231
|
if Ohai.config[:directory] &&
|
@@ -233,5 +243,25 @@ module Ohai
|
|
233
243
|
Ohai::Log.level = Ohai.config[:log_level]
|
234
244
|
end
|
235
245
|
end
|
246
|
+
|
247
|
+
# Freeze all string values in @data. This makes them immutable and saves
|
248
|
+
# a bit of RAM.
|
249
|
+
#
|
250
|
+
# @api private
|
251
|
+
# @return [void]
|
252
|
+
def freeze_strings!
|
253
|
+
# Recursive visitor pattern helper.
|
254
|
+
visitor = lambda do |val|
|
255
|
+
case val
|
256
|
+
when Hash
|
257
|
+
val.each_value { |v| visitor.call(v) }
|
258
|
+
when Array
|
259
|
+
val.each { |v| visitor.call(v) }
|
260
|
+
when String
|
261
|
+
val.freeze
|
262
|
+
end
|
263
|
+
end
|
264
|
+
visitor.call(@data)
|
265
|
+
end
|
236
266
|
end
|
237
267
|
end
|
data/lib/ohai/version.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Adam Jacob (<adam@chef.io>)
|
3
|
-
# Copyright:: Copyright (c) 2008-
|
3
|
+
# Copyright:: Copyright (c) 2008-2017, 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");
|
@@ -18,5 +18,5 @@
|
|
18
18
|
|
19
19
|
module Ohai
|
20
20
|
OHAI_ROOT = File.expand_path(File.dirname(__FILE__))
|
21
|
-
VERSION = "
|
21
|
+
VERSION = "13.0.0"
|
22
22
|
end
|
data/ohai.gemspec
CHANGED
@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
|
|
13
13
|
s.email = "adam@chef.io"
|
14
14
|
s.homepage = "https://docs.chef.io/ohai.html"
|
15
15
|
|
16
|
-
s.required_ruby_version = ">= 2.
|
16
|
+
s.required_ruby_version = ">= 2.3"
|
17
17
|
|
18
18
|
s.add_dependency "systemu", "~> 2.6.4"
|
19
19
|
s.add_dependency "ffi-yajl", "~> 2.2"
|
@@ -17,7 +17,6 @@
|
|
17
17
|
#
|
18
18
|
|
19
19
|
require_relative "../spec_helper"
|
20
|
-
|
21
20
|
require "ohai/application"
|
22
21
|
|
23
22
|
RSpec.describe "Ohai::Application" do
|
@@ -86,45 +85,6 @@ RSpec.describe "Ohai::Application" do
|
|
86
85
|
end
|
87
86
|
end
|
88
87
|
|
89
|
-
context "when the configuration file contains deprecated config options" do
|
90
|
-
# For the purpose of these tests it doesn't matter if the configuration
|
91
|
-
# file was specified via command line or discovered on the local
|
92
|
-
# workstation. It's easier if we pass the configuration file as a cli
|
93
|
-
# argument (there's less to stub).
|
94
|
-
|
95
|
-
let(:argv) { [ "-c", config_location ] }
|
96
|
-
|
97
|
-
let(:config_content) do
|
98
|
-
<<-CONFIG
|
99
|
-
log_location "#{log_location}"
|
100
|
-
log_level :#{log_level}
|
101
|
-
Ohai::Config[:disabled_plugins] = #{disabled_plugins}
|
102
|
-
Ohai::Config[:plugin_path] << "#{plugin_path}"
|
103
|
-
CONFIG
|
104
|
-
end
|
105
|
-
|
106
|
-
# config settings
|
107
|
-
let(:disabled_plugins) { [ :Foo, :Baz ] }
|
108
|
-
|
109
|
-
let(:log_level) { :debug }
|
110
|
-
|
111
|
-
let(:log_location) { "path/to/log" }
|
112
|
-
|
113
|
-
let(:plugin_path) { "/path/to/plugins" }
|
114
|
-
|
115
|
-
it "logs warnings for deprecated top-level options" do
|
116
|
-
# deprecation warnings for options need to be stubbed in the order
|
117
|
-
# they are received, in this case it's the order they appear in the
|
118
|
-
# configuration file.
|
119
|
-
options = [ :log_location, :log_level, :disabled_plugins ]
|
120
|
-
options.each do |option|
|
121
|
-
expect(Ohai::Log).to receive(:warn).
|
122
|
-
with(/Ohai::Config\[:#{option}\] is deprecated/)
|
123
|
-
end
|
124
|
-
app.configure_ohai
|
125
|
-
end
|
126
|
-
end
|
127
|
-
|
128
88
|
context "when the configuration file has a syntax error" do
|
129
89
|
# For the purpose of these tests it doesn't matter if the configuration
|
130
90
|
# file was specified via command line or discovered on the local
|
@@ -16,7 +16,7 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
|
19
|
-
|
19
|
+
require_relative "../../spec_helper.rb"
|
20
20
|
|
21
21
|
describe Ohai::System, "languages plugin" do
|
22
22
|
VERSION_MATCHING_REGEX = /^(?:[\d]+\.)+[\d]+$/
|
@@ -18,7 +18,7 @@
|
|
18
18
|
# limitations under the License.
|
19
19
|
#
|
20
20
|
|
21
|
-
|
21
|
+
require_relative "../../spec_helper.rb"
|
22
22
|
|
23
23
|
describe Ohai::System, "root_group plugin" do
|
24
24
|
let(:plugin) { get_plugin("root_group") }
|
data/spec/ohai_spec.rb
CHANGED
@@ -1,3 +1,20 @@
|
|
1
|
+
#
|
2
|
+
# License:: Apache License, Version 2.0
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License"); you
|
5
|
+
# may not use this file except in compliance with the License. You may
|
6
|
+
# obtain a copy of the license at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either expressed or
|
13
|
+
# implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License
|
16
|
+
#
|
17
|
+
|
1
18
|
require "tmpdir"
|
2
19
|
|
3
20
|
module IntegrationSupport
|
@@ -1,3 +1,20 @@
|
|
1
|
+
#
|
2
|
+
# License:: Apache License, Version 2.0
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License"); you
|
5
|
+
# may not use this file except in compliance with the License. You may
|
6
|
+
# obtain a copy of the license at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either expressed or
|
13
|
+
# implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License
|
16
|
+
#
|
17
|
+
|
1
18
|
def windows?
|
2
19
|
!!(RUBY_PLATFORM =~ /mswin|mingw|windows/)
|
3
20
|
end
|
data/spec/unit/config_spec.rb
CHANGED
@@ -17,79 +17,10 @@
|
|
17
17
|
#
|
18
18
|
|
19
19
|
require_relative "../spec_helper"
|
20
|
-
|
21
20
|
require "ohai/config"
|
22
21
|
|
23
22
|
RSpec.describe Ohai::Config do
|
24
23
|
|
25
|
-
describe "top-level configuration options" do
|
26
|
-
shared_examples_for "option" do
|
27
|
-
it "logs a deprecation warning and sets the value" do
|
28
|
-
expect(Ohai::Log).to receive(:warn).
|
29
|
-
with(/Ohai::Config\[:#{option}\] is deprecated/)
|
30
|
-
Ohai::Config[option] = value
|
31
|
-
expect(Ohai::Config[option]).to eq(value)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
shared_examples_for "appendable option" do
|
36
|
-
it "sets the value" do
|
37
|
-
expect(Ohai::Log).to_not receive(:warn)
|
38
|
-
Ohai::Config[option] << value
|
39
|
-
expect(Ohai::Config[option]).to include(value)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
describe ":directory" do
|
44
|
-
include_examples "option" do
|
45
|
-
let(:option) { :directory }
|
46
|
-
let(:value) { "/some/fantastic/plugins" }
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
describe ":disabled_plugins" do
|
51
|
-
include_examples "option" do
|
52
|
-
let(:option) { :disabled_plugins }
|
53
|
-
let(:value) { [ :Foo, :Baz ] }
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
describe ":hints_path" do
|
58
|
-
include_examples "appendable option" do
|
59
|
-
let(:option) { :hints_path }
|
60
|
-
let(:value) { "/some/helpful/hints" }
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
describe ":log_level" do
|
65
|
-
include_examples "option" do
|
66
|
-
let(:option) { :log_level }
|
67
|
-
let(:value) { :cheese }
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
describe ":log_location" do
|
72
|
-
include_examples "option" do
|
73
|
-
let(:option) { :log_location }
|
74
|
-
let(:value) { "/etc/chef/cache/loooogs" }
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
describe ":plugin_path" do
|
79
|
-
include_examples "appendable option" do
|
80
|
-
let(:option) { :plugin_path }
|
81
|
-
let(:value) { "/some/fantastic/plugins" }
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
describe ":version" do
|
86
|
-
include_examples "option" do
|
87
|
-
let(:option) { :version }
|
88
|
-
let(:value) { "8.2.0" }
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
24
|
describe "config_context :ohai" do
|
94
25
|
describe "option :plugin" do
|
95
26
|
it "gets configured with a value" do
|
@@ -118,48 +49,6 @@ RSpec.describe Ohai::Config do
|
|
118
49
|
end
|
119
50
|
end
|
120
51
|
|
121
|
-
describe "::merge_deprecated_config" do
|
122
|
-
before(:each) do
|
123
|
-
allow(Ohai::Log).to receive(:warn)
|
124
|
-
configure_ohai
|
125
|
-
end
|
126
|
-
|
127
|
-
def configure_ohai
|
128
|
-
Ohai::Config[:directory] = "/some/fantastic/plugins"
|
129
|
-
Ohai::Config[:disabled_plugins] = [ :Foo, :Baz ]
|
130
|
-
Ohai::Config[:log_level] = :debug
|
131
|
-
end
|
132
|
-
|
133
|
-
it "merges top-level config values into the ohai config context" do
|
134
|
-
Ohai::Config.merge_deprecated_config
|
135
|
-
expect(Ohai::Config.ohai.configuration).to eq (Ohai::Config.configuration)
|
136
|
-
end
|
137
|
-
|
138
|
-
shared_examples_for "delayed warn" do
|
139
|
-
it "logs a deprecation warning and merges the value" do
|
140
|
-
expect(Ohai::Log).to receive(:warn).
|
141
|
-
with(/Ohai::Config\[:#{option}\] is deprecated/)
|
142
|
-
Ohai::Config[option] << value
|
143
|
-
Ohai::Config.merge_deprecated_config
|
144
|
-
expect(Ohai::Config.ohai[option]).to include(value)
|
145
|
-
end
|
146
|
-
end
|
147
|
-
|
148
|
-
context "when :hints_path is set" do
|
149
|
-
include_examples "delayed warn" do
|
150
|
-
let(:option) { :hints_path }
|
151
|
-
let(:value) { "/some/helpful/hints" }
|
152
|
-
end
|
153
|
-
end
|
154
|
-
|
155
|
-
context "when :plugin_path is set" do
|
156
|
-
include_examples "delayed warn" do
|
157
|
-
let(:option) { :plugin_path }
|
158
|
-
let(:value) { "/some/fantastic/plugins" }
|
159
|
-
end
|
160
|
-
end
|
161
|
-
end
|
162
|
-
|
163
52
|
describe "Ohai.config" do
|
164
53
|
it "returns the ohai config context" do
|
165
54
|
expect(Ohai.config).to eq(Ohai::Config.ohai)
|