ohai 14.2.0 → 14.3.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/Rakefile +1 -1
- data/lib/ohai/application.rb +29 -29
- data/lib/ohai/common/dmi.rb +5 -5
- data/lib/ohai/dsl/plugin.rb +3 -3
- data/lib/ohai/dsl/plugin/versionvii.rb +3 -3
- data/lib/ohai/mixin/azure_metadata.rb +2 -2
- data/lib/ohai/mixin/do_metadata.rb +3 -3
- data/lib/ohai/mixin/ec2_metadata.rb +8 -8
- data/lib/ohai/mixin/gce_metadata.rb +2 -2
- data/lib/ohai/mixin/network_constants.rb +1 -1
- data/lib/ohai/mixin/scaleway_metadata.rb +3 -3
- data/lib/ohai/mixin/softlayer_metadata.rb +1 -1
- data/lib/ohai/mixin/string.rb +2 -2
- data/lib/ohai/plugins/aix/cpu.rb +3 -3
- data/lib/ohai/plugins/aix/filesystem.rb +1 -1
- data/lib/ohai/plugins/aix/kernel.rb +1 -1
- data/lib/ohai/plugins/aix/memory.rb +1 -1
- data/lib/ohai/plugins/aix/network.rb +3 -3
- data/lib/ohai/plugins/bsd/virtualization.rb +1 -1
- data/lib/ohai/plugins/cloud.rb +1 -1
- data/lib/ohai/plugins/darwin/hardware.rb +1 -1
- data/lib/ohai/plugins/darwin/network.rb +5 -5
- data/lib/ohai/plugins/darwin/platform.rb +1 -1
- data/lib/ohai/plugins/dmi.rb +6 -6
- data/lib/ohai/plugins/filesystem.rb +5 -5
- data/lib/ohai/plugins/hostname.rb +5 -5
- data/lib/ohai/plugins/kernel.rb +8 -8
- data/lib/ohai/plugins/linux/lspci.rb +4 -4
- data/lib/ohai/plugins/linux/memory.rb +4 -4
- data/lib/ohai/plugins/linux/network.rb +16 -16
- data/lib/ohai/plugins/linux/platform.rb +7 -1
- data/lib/ohai/plugins/netbsd/network.rb +1 -1
- data/lib/ohai/plugins/network.rb +5 -5
- data/lib/ohai/plugins/openbsd/network.rb +1 -1
- data/lib/ohai/plugins/packages.rb +1 -1
- data/lib/ohai/plugins/passwd.rb +4 -4
- data/lib/ohai/plugins/ruby.rb +13 -13
- data/lib/ohai/plugins/solaris2/dmi.rb +3 -3
- data/lib/ohai/plugins/solaris2/filesystem.rb +6 -6
- data/lib/ohai/plugins/solaris2/memory.rb +2 -2
- data/lib/ohai/plugins/solaris2/network.rb +36 -36
- data/lib/ohai/plugins/windows/network.rb +2 -2
- data/lib/ohai/util/win32/group_helper.rb +1 -1
- data/lib/ohai/version.rb +1 -1
- data/spec/functional/application_spec.rb +6 -6
- data/spec/functional/loader_spec.rb +4 -4
- data/spec/functional/plugins/windows/uptime_spec.rb +1 -2
- data/spec/spec_helper.rb +5 -5
- data/spec/unit/application_spec.rb +11 -11
- data/spec/unit/config_spec.rb +5 -5
- data/spec/unit/dsl/plugin_spec.rb +5 -5
- data/spec/unit/hints_spec.rb +2 -2
- data/spec/unit/loader_spec.rb +41 -41
- data/spec/unit/mixin/azure_metadata_spec.rb +3 -3
- data/spec/unit/mixin/command_spec.rb +64 -64
- data/spec/unit/mixin/ec2_metadata_spec.rb +6 -6
- data/spec/unit/mixin/softlayer_metadata_spec.rb +1 -1
- data/spec/unit/plugin_config_spec.rb +9 -9
- data/spec/unit/plugins/abort_spec.rb +6 -6
- data/spec/unit/plugins/aix/cpu_spec.rb +16 -16
- data/spec/unit/plugins/aix/filesystem_spec.rb +57 -57
- data/spec/unit/plugins/aix/network_spec.rb +35 -35
- data/spec/unit/plugins/aix/virtualization_spec.rb +210 -210
- data/spec/unit/plugins/azure_spec.rb +49 -49
- data/spec/unit/plugins/bsd/filesystem_spec.rb +13 -13
- data/spec/unit/plugins/bsd/virtualization_spec.rb +10 -10
- data/spec/unit/plugins/c_spec.rb +54 -54
- data/spec/unit/plugins/chef_spec.rb +3 -3
- data/spec/unit/plugins/darwin/cpu_spec.rb +54 -54
- data/spec/unit/plugins/darwin/filesystem_spec.rb +34 -34
- data/spec/unit/plugins/darwin/hardware_system_profiler_output.rb +1070 -1070
- data/spec/unit/plugins/darwin/memory_spec.rb +16 -16
- data/spec/unit/plugins/darwin/network_spec.rb +382 -382
- data/spec/unit/plugins/digital_ocean_spec.rb +7 -7
- data/spec/unit/plugins/dmi_spec.rb +83 -83
- data/spec/unit/plugins/docker_spec.rb +2 -2
- data/spec/unit/plugins/ec2_spec.rb +156 -156
- data/spec/unit/plugins/eucalyptus_spec.rb +19 -19
- data/spec/unit/plugins/fail_spec.rb +14 -14
- data/spec/unit/plugins/freebsd/cpu_spec.rb +18 -18
- data/spec/unit/plugins/freebsd/kernel_spec.rb +1 -1
- data/spec/unit/plugins/gce_spec.rb +1 -1
- data/spec/unit/plugins/init_package_spec.rb +1 -1
- data/spec/unit/plugins/java_spec.rb +4 -4
- data/spec/unit/plugins/joyent_spec.rb +9 -9
- data/spec/unit/plugins/linux/block_device_spec.rb +1 -1
- data/spec/unit/plugins/linux/cpu_spec.rb +155 -155
- data/spec/unit/plugins/linux/filesystem_spec.rb +229 -229
- data/spec/unit/plugins/linux/kernel_spec.rb +9 -9
- data/spec/unit/plugins/linux/lsb_spec.rb +18 -18
- data/spec/unit/plugins/linux/lspci_spec.rb +58 -58
- data/spec/unit/plugins/linux/mdadm_spec.rb +54 -54
- data/spec/unit/plugins/linux/memory_spec.rb +35 -35
- data/spec/unit/plugins/linux/network_spec.rb +464 -464
- data/spec/unit/plugins/linux/platform_spec.rb +84 -68
- data/spec/unit/plugins/linux/systemd_paths_spec.rb +40 -40
- data/spec/unit/plugins/linux/uptime_spec.rb +1 -1
- data/spec/unit/plugins/linux/virtualization_spec.rb +197 -197
- data/spec/unit/plugins/mono_spec.rb +11 -11
- data/spec/unit/plugins/netbsd/kernel_spec.rb +1 -1
- data/spec/unit/plugins/network_spec.rb +2 -2
- data/spec/unit/plugins/openstack_spec.rb +43 -43
- data/spec/unit/plugins/os_spec.rb +1 -1
- data/spec/unit/plugins/passwd_spec.rb +9 -9
- data/spec/unit/plugins/php_spec.rb +22 -22
- data/spec/unit/plugins/powershell_spec.rb +13 -13
- data/spec/unit/plugins/rackspace_spec.rb +38 -38
- data/spec/unit/plugins/ruby_spec.rb +14 -14
- data/spec/unit/plugins/scaleway_spec.rb +6 -6
- data/spec/unit/plugins/scsi_spec.rb +7 -7
- data/spec/unit/plugins/solaris2/cpu_spec.rb +2594 -2594
- data/spec/unit/plugins/solaris2/dmi_spec.rb +91 -91
- data/spec/unit/plugins/solaris2/filesystem.rb +8 -8
- data/spec/unit/plugins/solaris2/kernel_spec.rb +1 -1
- data/spec/unit/plugins/solaris2/network_spec.rb +92 -93
- data/spec/unit/plugins/solaris2/platform_spec.rb +24 -24
- data/spec/unit/plugins/solaris2/virtualization_spec.rb +22 -22
- data/spec/unit/plugins/ssh_host_keys_spec.rb +12 -12
- data/spec/unit/plugins/sysconf_spec.rb +321 -321
- data/spec/unit/plugins/virtualbox_spec.rb +27 -27
- data/spec/unit/plugins/windows/cpu_spec.rb +9 -9
- data/spec/unit/plugins/windows/kernel_spec.rb +12 -12
- data/spec/unit/plugins/windows/uptime_spec.rb +1 -1
- data/spec/unit/plugins/zpools_spec.rb +41 -41
- data/spec/unit/runner_spec.rb +2 -2
- data/spec/unit/system_spec.rb +55 -55
- metadata +3 -4
- data/docs/man/man1/ohai.1 +0 -97
@@ -24,8 +24,8 @@ Ohai.plugin(:Memory) do
|
|
24
24
|
memory[:total] = "#{meminfo.split[2].to_i * 1024}kB"
|
25
25
|
|
26
26
|
tokens = shell_out("swap -s").stdout.strip.split
|
27
|
-
used_swap = tokens[8][0..-1].to_i #strip k from end
|
28
|
-
free_swap = tokens[10][0..-1].to_i #strip k from end
|
27
|
+
used_swap = tokens[8][0..-1].to_i # strip k from end
|
28
|
+
free_swap = tokens[10][0..-1].to_i # strip k from end
|
29
29
|
memory[:swap][:total] = "#{used_swap + free_swap}kB"
|
30
30
|
memory[:swap][:free] = "#{free_swap}kB"
|
31
31
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Benjamin Black (<nostromo@gmail.com>)
|
3
|
-
# Copyright:: Copyright (c) 2008-
|
3
|
+
# Copyright:: Copyright (c) 2008-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");
|
@@ -18,40 +18,40 @@
|
|
18
18
|
|
19
19
|
# EXAMPLE SOLARIS IFCONFIG OUTPUT; CURRENTLY, ONLY SIMPLE STUFF IS SUPPORTED (E.G., NO TUNNELS)
|
20
20
|
# DEAR SUN: YOU GET AN F FOR YOUR IFCONFIG
|
21
|
-
#lo0:3: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1
|
22
|
-
#
|
23
|
-
#e1000g0:3: flags=201000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4,CoS> mtu 1500 index 3
|
24
|
-
#
|
25
|
-
#e1000g2:1: flags=201000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4,CoS> mtu 1500 index 4
|
26
|
-
#
|
27
|
-
#
|
28
|
-
#ip.tun0: flags=2200851<UP,POINTOPOINT,RUNNING,MULTICAST,NONUD,IPv6> mtu 1480 index 3
|
29
|
-
#
|
30
|
-
#
|
31
|
-
#
|
32
|
-
#
|
33
|
-
#ip.tun0:1: flags=2200851<UP,POINTOPOINT,RUNNING,MULTICAST,NONUD,IPv6> mtu 1480 index 3
|
34
|
-
#
|
35
|
-
#lo0: flags=1000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4> mtu 8232 index 1
|
36
|
-
#
|
37
|
-
#eri0: flags=1004843<UP,BROADCAST,RUNNING,MULTICAST,DHCP,IPv4> mtu 1500 \
|
38
|
-
#index 2
|
39
|
-
#
|
40
|
-
#ip6.tun0: flags=10008d1<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST,IPv4> \
|
41
|
-
#mtu 1460
|
42
|
-
#
|
43
|
-
#
|
44
|
-
#
|
45
|
-
#
|
46
|
-
#
|
47
|
-
#qfe1: flags=2000841<UP,RUNNING,MULTICAST,IPv6> mtu 1500 index 3
|
48
|
-
#
|
49
|
-
#
|
50
|
-
#
|
51
|
-
#vni0: flags=2002210041<UP,RUNNING,NOXMIT,NONUD,IPv6,VIRTUAL> mtu 0
|
52
|
-
#
|
53
|
-
#
|
54
|
-
#
|
21
|
+
# lo0:3: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1
|
22
|
+
# inet 127.0.0.1 netmask ff000000
|
23
|
+
# e1000g0:3: flags=201000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4,CoS> mtu 1500 index 3
|
24
|
+
# inet 72.2.115.28 netmask ffffff80 broadcast 72.2.115.127
|
25
|
+
# e1000g2:1: flags=201000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4,CoS> mtu 1500 index 4
|
26
|
+
# inet 10.2.115.28 netmask ffffff80 broadcast 10.2.115.127
|
27
|
+
# inet6 2001:0db8:3c4d:55:a00:20ff:fe8e:f3ad/64
|
28
|
+
# ip.tun0: flags=2200851<UP,POINTOPOINT,RUNNING,MULTICAST,NONUD,IPv6> mtu 1480 index 3
|
29
|
+
# inet tunnel src 109.146.85.57 tunnel dst 109.146.85.212
|
30
|
+
# tunnel security settings --> use 'ipsecconf -ln -i ip.tun1'
|
31
|
+
# tunnel hop limit 60
|
32
|
+
# inet6 fe80::6d92:5539/10 --> fe80::6d92:55d4
|
33
|
+
# ip.tun0:1: flags=2200851<UP,POINTOPOINT,RUNNING,MULTICAST,NONUD,IPv6> mtu 1480 index 3
|
34
|
+
# inet6 2::45/128 --> 2::46
|
35
|
+
# lo0: flags=1000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4> mtu 8232 index 1
|
36
|
+
# inet 127.0.0.1 netmask ff000000
|
37
|
+
# eri0: flags=1004843<UP,BROADCAST,RUNNING,MULTICAST,DHCP,IPv4> mtu 1500 \
|
38
|
+
# index 2
|
39
|
+
# inet 172.17.128.208 netmask ffffff00 broadcast 172.17.128.255
|
40
|
+
# ip6.tun0: flags=10008d1<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST,IPv4> \
|
41
|
+
# mtu 1460
|
42
|
+
# index 3
|
43
|
+
# inet6 tunnel src fe80::1 tunnel dst fe80::2
|
44
|
+
# tunnel security settings --> use 'ipsecconf -ln -i ip.tun1'
|
45
|
+
# tunnel hop limit 60 tunnel encapsulation limit 4
|
46
|
+
# inet 10.0.0.208 --> 10.0.0.210 netmask ff000000
|
47
|
+
# qfe1: flags=2000841<UP,RUNNING,MULTICAST,IPv6> mtu 1500 index 3
|
48
|
+
# usesrc vni0
|
49
|
+
# inet6 fe80::203:baff:fe17:4be0/10
|
50
|
+
# ether 0:3:ba:17:4b:e0
|
51
|
+
# vni0: flags=2002210041<UP,RUNNING,NOXMIT,NONUD,IPv6,VIRTUAL> mtu 0
|
52
|
+
# index 5
|
53
|
+
# srcof qfe1
|
54
|
+
# inet6 fe80::203:baff:fe17:4444/128
|
55
55
|
|
56
56
|
# Extracted from http://illumos.org/hcl/
|
57
57
|
unless defined?(ETHERNET_ENCAPS)
|
@@ -59,7 +59,7 @@ unless defined?(ETHERNET_ENCAPS)
|
|
59
59
|
dmfe e1000g efe elxl emlxs eri hermon hme hxge igb
|
60
60
|
iprb ipw iwh iwi iwk iwp ixgb ixgbe mwl mxfe myri10ge
|
61
61
|
nge ntxn nxge pcn platform qfe qlc ral rge rtls rtw rwd
|
62
|
-
rwn sfe tavor vr wpi xge yge aggr}
|
62
|
+
rwn sfe tavor vr wpi xge yge aggr}.freeze
|
63
63
|
end
|
64
64
|
|
65
65
|
Ohai.plugin(:Network) do
|
@@ -102,7 +102,7 @@ Ohai.plugin(:Network) do
|
|
102
102
|
ip_and_subnet = ip.dup
|
103
103
|
ip_and_subnet << "/#{iface[cint][:configuration][:ip_subnet][ip_index]}" if iface[cint][:configuration][:ip_subnet]
|
104
104
|
ip2 = IPAddress(ip_and_subnet)
|
105
|
-
iface[cint][:addresses][ip] = Mash.new(:
|
105
|
+
iface[cint][:addresses][ip] = Mash.new(prefixlen: ip2.prefix)
|
106
106
|
if ip2.ipv6?
|
107
107
|
iface[cint][:addresses][ip][:family] = "inet6"
|
108
108
|
iface[cint][:addresses][ip][:scope] = "Link" if ip =~ /^fe80/i
|
@@ -123,7 +123,7 @@ Ohai.plugin(:Network) do
|
|
123
123
|
"family" => "lladdr",
|
124
124
|
}
|
125
125
|
end
|
126
|
-
iface[cint][:mtu] = iface[cint][:configuration][:mtu] if iface[cint][:configuration].
|
126
|
+
iface[cint][:mtu] = iface[cint][:configuration][:mtu] if iface[cint][:configuration].key?(:mtu)
|
127
127
|
iface[cint][:type] = iface[cint][:instance][:adapter_type] if iface[cint][:instance][:adapter_type]
|
128
128
|
iface[cint][:arp] = {}
|
129
129
|
iface[cint][:encapsulation] = windows_encaps_lookup(iface[cint][:instance][:adapter_type]) if iface[cint][:instance][:adapter_type]
|
@@ -26,7 +26,7 @@ module Ohai
|
|
26
26
|
# internal name for the Administrators group, which lets us work
|
27
27
|
# properly in environments with a renamed or localized name for the
|
28
28
|
# Administrators group
|
29
|
-
BUILTIN_ADMINISTRATORS_SID = "S-1-5-32-544"
|
29
|
+
BUILTIN_ADMINISTRATORS_SID = "S-1-5-32-544".freeze
|
30
30
|
|
31
31
|
def self.windows_root_group_name
|
32
32
|
administrators_sid_result = FFI::MemoryPointer.new(:pointer)
|
data/lib/ohai/version.rb
CHANGED
@@ -58,8 +58,8 @@ RSpec.describe "Ohai::Application" do
|
|
58
58
|
|
59
59
|
it "logs an error and terminates the application" do
|
60
60
|
expect(STDERR).to receive(:puts).with(/FATAL:/)
|
61
|
-
expect(Ohai::Log).to receive(:fatal)
|
62
|
-
with(/Specified config file #{argv[1]} does not exist/)
|
61
|
+
expect(Ohai::Log).to receive(:fatal)
|
62
|
+
.with(/Specified config file #{argv[1]} does not exist/)
|
63
63
|
expect { app.configure_ohai }.to raise_error(SystemExit)
|
64
64
|
end
|
65
65
|
end
|
@@ -75,8 +75,8 @@ RSpec.describe "Ohai::Application" do
|
|
75
75
|
let(:env) { { "KNIFE_HOME" => config_dir } }
|
76
76
|
|
77
77
|
before(:each) do
|
78
|
-
allow_any_instance_of(ChefConfig::WorkstationConfigLoader)
|
79
|
-
to receive(:env).and_return(env)
|
78
|
+
allow_any_instance_of(ChefConfig::WorkstationConfigLoader)
|
79
|
+
.to receive(:env).and_return(env)
|
80
80
|
end
|
81
81
|
|
82
82
|
it "loads the workstation configuration file" do
|
@@ -97,8 +97,8 @@ RSpec.describe "Ohai::Application" do
|
|
97
97
|
|
98
98
|
it "logs an error and terminates the application" do
|
99
99
|
expect(STDERR).to receive(:puts).with(/FATAL:/)
|
100
|
-
expect(Ohai::Log).to receive(:fatal)
|
101
|
-
with(/You have invalid ruby syntax in your config file/)
|
100
|
+
expect(Ohai::Log).to receive(:fatal)
|
101
|
+
.with(/You have invalid ruby syntax in your config file/)
|
102
102
|
expect { app.configure_ohai }.to raise_error(SystemExit)
|
103
103
|
end
|
104
104
|
end
|
@@ -28,10 +28,10 @@ RSpec.describe "Ohai::Loader" do
|
|
28
28
|
before(:each) do
|
29
29
|
Ohai.config[:plugin_path] = plugin_path
|
30
30
|
|
31
|
-
plugin_content =
|
32
|
-
Ohai.plugin(:Foo) do
|
33
|
-
|
34
|
-
end
|
31
|
+
plugin_content = <<~EOF
|
32
|
+
Ohai.plugin(:Foo) do
|
33
|
+
provides 'foo'
|
34
|
+
end
|
35
35
|
EOF
|
36
36
|
File.open(File.join(plugin_directory, "foo.rb"), "w+") do |f|
|
37
37
|
f.write(plugin_content)
|
@@ -28,8 +28,7 @@ describe Ohai::System, "Windows plugin uptime" do
|
|
28
28
|
end
|
29
29
|
|
30
30
|
let(:wmi) do
|
31
|
-
double("wmi", { :
|
32
|
-
{ "lastbootuptime" => "20160912103128.597219+0000" },
|
31
|
+
double("wmi", { first_of: { "lastbootuptime" => "20160912103128.597219+0000" },
|
33
32
|
})
|
34
33
|
end
|
35
34
|
|
data/spec/spec_helper.rb
CHANGED
@@ -105,12 +105,12 @@ RSpec.configure do |config|
|
|
105
105
|
c.syntax = :expect
|
106
106
|
end
|
107
107
|
|
108
|
-
config.filter_run :
|
108
|
+
config.filter_run focus: true
|
109
109
|
|
110
|
-
config.filter_run_excluding :
|
111
|
-
config.filter_run_excluding :
|
112
|
-
config.filter_run_excluding :
|
113
|
-
config.filter_run_excluding :
|
110
|
+
config.filter_run_excluding windows_only: true unless windows?
|
111
|
+
config.filter_run_excluding unix_only: true unless unix?
|
112
|
+
config.filter_run_excluding requires_root: true unless ENV["USER"] == "root"
|
113
|
+
config.filter_run_excluding requires_unprivileged_user: true if ENV["USER"] == "root"
|
114
114
|
|
115
115
|
config.run_all_when_everything_filtered = true
|
116
116
|
|
@@ -43,13 +43,13 @@ RSpec.describe "Ohai::Application" do
|
|
43
43
|
|
44
44
|
before(:each) do
|
45
45
|
if windows?
|
46
|
-
expect(ChefConfig::WorkstationConfigLoader).to receive(:new)
|
47
|
-
with("C:#{config_file}", Ohai::Log)
|
48
|
-
and_return(config_loader)
|
46
|
+
expect(ChefConfig::WorkstationConfigLoader).to receive(:new)
|
47
|
+
.with("C:#{config_file}", Ohai::Log)
|
48
|
+
.and_return(config_loader)
|
49
49
|
else
|
50
|
-
expect(ChefConfig::WorkstationConfigLoader).to receive(:new)
|
51
|
-
with(config_file, Ohai::Log)
|
52
|
-
and_return(config_loader)
|
50
|
+
expect(ChefConfig::WorkstationConfigLoader).to receive(:new)
|
51
|
+
.with(config_file, Ohai::Log)
|
52
|
+
.and_return(config_loader)
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
@@ -69,9 +69,9 @@ RSpec.describe "Ohai::Application" do
|
|
69
69
|
|
70
70
|
context "when a local workstation config exists" do
|
71
71
|
before(:each) do
|
72
|
-
expect(ChefConfig::WorkstationConfigLoader).to receive(:new)
|
73
|
-
with(nil, Ohai::Log)
|
74
|
-
and_return(config_loader)
|
72
|
+
expect(ChefConfig::WorkstationConfigLoader).to receive(:new)
|
73
|
+
.with(nil, Ohai::Log)
|
74
|
+
.and_return(config_loader)
|
75
75
|
end
|
76
76
|
|
77
77
|
it "loads the configuration file" do
|
@@ -86,8 +86,8 @@ RSpec.describe "Ohai::Application" do
|
|
86
86
|
let(:directory) { "/some/fantastic/plugins" }
|
87
87
|
|
88
88
|
it "does not generate deprecated config warnings for cli options" do
|
89
|
-
expect(Ohai::Log).to_not receive(:warn)
|
90
|
-
with(/Ohai::Config\[:directory\] is deprecated/)
|
89
|
+
expect(Ohai::Log).to_not receive(:warn)
|
90
|
+
.with(/Ohai::Config\[:directory\] is deprecated/)
|
91
91
|
app.configure_ohai
|
92
92
|
end
|
93
93
|
end
|
data/spec/unit/config_spec.rb
CHANGED
@@ -30,21 +30,21 @@ RSpec.describe Ohai::Config do
|
|
30
30
|
end
|
31
31
|
|
32
32
|
it "gets configured with a Hash" do
|
33
|
-
value = { :
|
33
|
+
value = { bar: true, baz: true }
|
34
34
|
Ohai::Config.ohai[:plugin][:foo] = value
|
35
35
|
expect(Ohai::Config.ohai[:plugin]).to have_key(:foo)
|
36
36
|
expect(Ohai::Config.ohai[:plugin][:foo]).to eq(value)
|
37
37
|
end
|
38
38
|
|
39
39
|
it "raises an error if the plugin name is not a symbol" do
|
40
|
-
expect { Ohai::Config.ohai[:plugin]["foo"] = false }
|
41
|
-
to raise_error(Ohai::Exceptions::PluginConfigError, /Expected Symbol/)
|
40
|
+
expect { Ohai::Config.ohai[:plugin]["foo"] = false }
|
41
|
+
.to raise_error(Ohai::Exceptions::PluginConfigError, /Expected Symbol/)
|
42
42
|
end
|
43
43
|
|
44
44
|
it "raises an error if the value Hash has non-Symbol key" do
|
45
45
|
value = { :bar => true, "baz" => true }
|
46
|
-
expect { Ohai::Config.ohai[:plugin][:foo] = value }
|
47
|
-
to raise_error(Ohai::Exceptions::PluginConfigError, /Expected Symbol/)
|
46
|
+
expect { Ohai::Config.ohai[:plugin][:foo] = value }
|
47
|
+
.to raise_error(Ohai::Exceptions::PluginConfigError, /Expected Symbol/)
|
48
48
|
end
|
49
49
|
end
|
50
50
|
end
|
@@ -203,8 +203,8 @@ shared_examples "Ohai::DSL::Plugin" do
|
|
203
203
|
describe "as a list" do
|
204
204
|
describe "of strings" do
|
205
205
|
it "returns true when the attribute exists" do
|
206
|
-
expect(plugin.get_attribute("the_monarch", "arch_rival"))
|
207
|
-
to eql("dr_venture")
|
206
|
+
expect(plugin.get_attribute("the_monarch", "arch_rival"))
|
207
|
+
.to eql("dr_venture")
|
208
208
|
end
|
209
209
|
|
210
210
|
describe "when the attribute does not exist" do
|
@@ -239,8 +239,8 @@ shared_examples "Ohai::DSL::Plugin" do
|
|
239
239
|
|
240
240
|
describe "of symbols" do
|
241
241
|
it "returns true when the attribute exists" do
|
242
|
-
expect(plugin.get_attribute(:the_monarch, :arch_rival))
|
243
|
-
to eql("dr_venture")
|
242
|
+
expect(plugin.get_attribute(:the_monarch, :arch_rival))
|
243
|
+
.to eql("dr_venture")
|
244
244
|
end
|
245
245
|
|
246
246
|
describe "when the attribute does not exist" do
|
@@ -592,7 +592,7 @@ describe Ohai::DSL::Plugin::VersionVII do
|
|
592
592
|
include_examples "plugin config lookup"
|
593
593
|
|
594
594
|
it "returns the configuration sub-option value" do
|
595
|
-
Ohai.config[:plugin][snake_name][:foo] = { :
|
595
|
+
Ohai.config[:plugin][snake_name][:foo] = { bar: true }
|
596
596
|
expect(plugin.configuration(:foo, :bar)).to eq(true)
|
597
597
|
end
|
598
598
|
end
|
data/spec/unit/hints_spec.rb
CHANGED
@@ -42,8 +42,8 @@ describe "Ohai::Hints" do
|
|
42
42
|
end
|
43
43
|
|
44
44
|
when_plugins_directory "contains empty and full hints" do
|
45
|
-
with_plugin("cloud.json",
|
46
|
-
{"name":"circus"}
|
45
|
+
with_plugin("cloud.json", <<~EOF)
|
46
|
+
{"name":"circus"}
|
47
47
|
EOF
|
48
48
|
|
49
49
|
with_plugin("cloud_empty.json", <<EOF)
|
data/spec/unit/loader_spec.rb
CHANGED
@@ -23,7 +23,7 @@ describe Ohai::Loader do
|
|
23
23
|
extend IntegrationSupport
|
24
24
|
|
25
25
|
let(:loader) { Ohai::Loader.new(ohai) }
|
26
|
-
let(:ohai) { double("Ohai::System", :
|
26
|
+
let(:ohai) { double("Ohai::System", data: Mash.new, provides_map: provides_map, logger: Ohai::Log) }
|
27
27
|
let(:provides_map) { Ohai::ProvidesMap.new }
|
28
28
|
|
29
29
|
describe "#initialize" do
|
@@ -34,16 +34,16 @@ describe Ohai::Loader do
|
|
34
34
|
end
|
35
35
|
|
36
36
|
when_plugins_directory "is an additional plugin path" do
|
37
|
-
with_plugin("cookbook_a/alpha.rb",
|
38
|
-
Ohai.plugin(:Alpha) do
|
39
|
-
|
40
|
-
end
|
37
|
+
with_plugin("cookbook_a/alpha.rb", <<~EOF)
|
38
|
+
Ohai.plugin(:Alpha) do
|
39
|
+
provides "alpha"
|
40
|
+
end
|
41
41
|
EOF
|
42
42
|
|
43
|
-
with_plugin("cookbook_b/beta.rb",
|
44
|
-
Ohai.plugin(:Beta) do
|
45
|
-
|
46
|
-
end
|
43
|
+
with_plugin("cookbook_b/beta.rb", <<~EOF)
|
44
|
+
Ohai.plugin(:Beta) do
|
45
|
+
provides "beta"
|
46
|
+
end
|
47
47
|
EOF
|
48
48
|
|
49
49
|
describe "#load_additional" do
|
@@ -59,50 +59,50 @@ EOF
|
|
59
59
|
end
|
60
60
|
|
61
61
|
when_plugins_directory "contains invalid plugins" do
|
62
|
-
with_plugin("extra_s.rb",
|
63
|
-
Ohai.plugins(:ExtraS) do
|
64
|
-
|
65
|
-
end
|
62
|
+
with_plugin("extra_s.rb", <<~EOF)
|
63
|
+
Ohai.plugins(:ExtraS) do
|
64
|
+
provides "the_letter_s"
|
65
|
+
end
|
66
66
|
EOF
|
67
67
|
|
68
|
-
with_plugin("no_method.rb",
|
69
|
-
Ohai.plugin(:NoMethod) do
|
70
|
-
|
71
|
-
end
|
68
|
+
with_plugin("no_method.rb", <<~EOF)
|
69
|
+
Ohai.plugin(:NoMethod) do
|
70
|
+
really_wants "this_attribute"
|
71
|
+
end
|
72
72
|
EOF
|
73
73
|
|
74
|
-
with_plugin("illegal_def.rb",
|
75
|
-
Ohai.plugin(:Zoo) do
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
end
|
74
|
+
with_plugin("illegal_def.rb", <<~EOF)
|
75
|
+
Ohai.plugin(:Zoo) do
|
76
|
+
collect_data(:darwin) do
|
77
|
+
end
|
78
|
+
collect_data(:darwin) do
|
79
|
+
end
|
80
|
+
end
|
81
81
|
EOF
|
82
82
|
|
83
|
-
with_plugin("unexpected_error.rb",
|
84
|
-
Ohai.plugin(:Zoo) do
|
85
|
-
|
86
|
-
end
|
83
|
+
with_plugin("unexpected_error.rb", <<~EOF)
|
84
|
+
Ohai.plugin(:Zoo) do
|
85
|
+
raise "You aren't expecting this."
|
86
|
+
end
|
87
87
|
EOF
|
88
88
|
|
89
|
-
with_plugin("bad_symbol.rb",
|
90
|
-
Ohai.plugin(:1nval!d) do
|
91
|
-
|
92
|
-
end
|
89
|
+
with_plugin("bad_symbol.rb", <<~EOF)
|
90
|
+
Ohai.plugin(:1nval!d) do
|
91
|
+
provides "not_a_symbol"
|
92
|
+
end
|
93
93
|
EOF
|
94
94
|
|
95
|
-
with_plugin("no_end.rb",
|
96
|
-
Ohai.plugin(:NoEnd) do
|
97
|
-
|
98
|
-
|
99
|
-
end
|
95
|
+
with_plugin("no_end.rb", <<~EOF)
|
96
|
+
Ohai.plugin(:NoEnd) do
|
97
|
+
provides "fish_oil"
|
98
|
+
collect_data do
|
99
|
+
end
|
100
100
|
EOF
|
101
101
|
|
102
|
-
with_plugin("bad_name.rb",
|
103
|
-
Ohai.plugin(:you_give_plugins_a_bad_name) do
|
104
|
-
|
105
|
-
end
|
102
|
+
with_plugin("bad_name.rb", <<~EOF)
|
103
|
+
Ohai.plugin(:you_give_plugins_a_bad_name) do
|
104
|
+
provides "that/one/song"
|
105
|
+
end
|
106
106
|
EOF
|
107
107
|
|
108
108
|
describe "load_plugin() method" do
|
@@ -43,7 +43,7 @@ describe Ohai::Mixin::AzureMetadata do
|
|
43
43
|
|
44
44
|
describe "#fetch_metadata" do
|
45
45
|
it "returns an empty hash given a non-200 response" do
|
46
|
-
http_mock = double("http", { :
|
46
|
+
http_mock = double("http", { code: "500" })
|
47
47
|
allow(mixin).to receive(:http_get).and_return(http_mock)
|
48
48
|
|
49
49
|
expect(mixin.logger).to receive(:warn)
|
@@ -52,7 +52,7 @@ describe Ohai::Mixin::AzureMetadata do
|
|
52
52
|
end
|
53
53
|
|
54
54
|
it "returns an empty hash given invalid JSON response" do
|
55
|
-
http_mock = double("http", { :
|
55
|
+
http_mock = double("http", { code: "200", body: '{ "foo" "bar"}' })
|
56
56
|
allow(mixin).to receive(:http_get).and_return(http_mock)
|
57
57
|
|
58
58
|
expect(mixin.logger).to receive(:warn)
|
@@ -61,7 +61,7 @@ describe Ohai::Mixin::AzureMetadata do
|
|
61
61
|
end
|
62
62
|
|
63
63
|
it "returns a populated hash given valid JSON response" do
|
64
|
-
http_mock = double("http", { :
|
64
|
+
http_mock = double("http", { code: "200", body: '{ "foo": "bar"}' })
|
65
65
|
allow(mixin).to receive(:http_get).and_return(http_mock)
|
66
66
|
|
67
67
|
expect(mixin.logger).not_to receive(:warn)
|