ohai 8.4.0 → 8.5.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/lib/ohai/plugins/cloud_v2.rb +2 -2
- data/lib/ohai/plugins/linux/platform.rb +37 -17
- data/lib/ohai/plugins/solaris2/network.rb +11 -3
- data/lib/ohai/system.rb +1 -1
- data/lib/ohai/version.rb +1 -1
- data/spec/spec_helper.rb +5 -1
- data/spec/unit/mixin/ec2_metadata_spec.rb +2 -2
- data/spec/unit/plugins/cloud_v2_spec.rb +4 -4
- data/spec/unit/plugins/linux/platform_spec.rb +195 -98
- data/spec/unit/plugins/platform_spec.rb +6 -6
- data/spec/unit/plugins/ruby_spec.rb +5 -5
- data/spec/unit/runner_spec.rb +1 -1
- metadata +7 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c04612616e40294b66bb4d491b79ccdcc76bd5da
|
4
|
+
data.tar.gz: fa3e3c8a9194bc1260e41bef0175dd3f0e1bfcba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 06f53f0663a21eff360e7e3466472484238832b5b4b7e04d9cbedc8bcdd060810aa6f93992f01c7f4033ee4d730e2e674fe6b98429885673a3639092c8c869e2
|
7
|
+
data.tar.gz: b37a7bc60df9b61f293e62c8d2cdc784a507b4e2e84a118178f24b41b4f2645881c3b47898b2e429d35e8ab36de55f22c5b69d05c73c8ef9cc2894d4d38ded0c
|
@@ -62,7 +62,7 @@ Ohai.plugin(:CloudV2) do
|
|
62
62
|
@cloud[:local_ipv4_addrs] ||= Array.new
|
63
63
|
@cloud[:local_ipv4_addrs] << ipaddr.to_s
|
64
64
|
else
|
65
|
-
raise "ERROR:
|
65
|
+
raise "ERROR: invalid accessibility param of '#{accessibility}'. must be :public or :private."
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
@@ -79,7 +79,7 @@ Ohai.plugin(:CloudV2) do
|
|
79
79
|
@cloud[:local_ipv6_addrs] ||= Array.new
|
80
80
|
@cloud[:local_ipv6_addrs] << ipaddr.to_s
|
81
81
|
else
|
82
|
-
raise "ERROR:
|
82
|
+
raise "ERROR: invalid accessibility param of '#{accessibility}'. must be :public or :private."
|
83
83
|
end
|
84
84
|
end
|
85
85
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
|
-
# Author:: Adam Jacob (<adam@
|
3
|
-
# Copyright:: Copyright (c)
|
2
|
+
# Author:: Adam Jacob (<adam@chef.io>)
|
3
|
+
# Copyright:: Copyright (c) 2015 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");
|
@@ -28,17 +28,31 @@ Ohai.plugin(:Platform) do
|
|
28
28
|
contents[/Rawhide/i] ? contents[/((\d+) \(Rawhide\))/i, 1].downcase : contents[/release ([\d\.]+)/, 1]
|
29
29
|
end
|
30
30
|
|
31
|
+
def os_release_file_is_cisco?
|
32
|
+
return false unless File.exist?('/etc/os-release')
|
33
|
+
os_release_info = File.read('/etc/os-release').split.inject({}) do |map, key_value_line|
|
34
|
+
key, _separator, value = key_value_line.partition('=')
|
35
|
+
map[key] = value
|
36
|
+
map
|
37
|
+
end
|
38
|
+
if os_release_info['CISCO_RELEASE_INFO'] && File.exist?(os_release_info['CISCO_RELEASE_INFO'])
|
39
|
+
os_release_info
|
40
|
+
else
|
41
|
+
false
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
31
45
|
collect_data(:linux) do
|
32
46
|
# platform [ and platform_version ? ] should be lower case to avoid dealing with RedHat/Redhat/redhat matching
|
33
|
-
if File.
|
47
|
+
if File.exist?("/etc/oracle-release")
|
34
48
|
contents = File.read("/etc/oracle-release").chomp
|
35
49
|
platform "oracle"
|
36
50
|
platform_version get_redhatish_version(contents)
|
37
|
-
elsif File.
|
51
|
+
elsif File.exist?("/etc/enterprise-release")
|
38
52
|
contents = File.read("/etc/enterprise-release").chomp
|
39
53
|
platform "oracle"
|
40
54
|
platform_version get_redhatish_version(contents)
|
41
|
-
elsif File.
|
55
|
+
elsif File.exist?("/etc/debian_version")
|
42
56
|
# Ubuntu and Debian both have /etc/debian_version
|
43
57
|
# Ubuntu should always have a working lsb, debian does not by default
|
44
58
|
if lsb[:id] =~ /Ubuntu/i
|
@@ -48,29 +62,35 @@ Ohai.plugin(:Platform) do
|
|
48
62
|
platform "linuxmint"
|
49
63
|
platform_version lsb[:release]
|
50
64
|
else
|
51
|
-
if File.
|
65
|
+
if File.exist?("/usr/bin/raspi-config")
|
52
66
|
platform "raspbian"
|
53
67
|
else
|
54
68
|
platform "debian"
|
55
69
|
end
|
56
70
|
platform_version File.read("/etc/debian_version").chomp
|
57
71
|
end
|
58
|
-
elsif File.
|
72
|
+
elsif File.exist?("/etc/parallels-release")
|
59
73
|
contents = File.read("/etc/parallels-release").chomp
|
60
74
|
platform get_redhatish_platform(contents)
|
61
75
|
platform_version contents.match(/(\d\.\d\.\d)/)[0]
|
62
|
-
elsif File.
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
76
|
+
elsif File.exist?("/etc/redhat-release")
|
77
|
+
if File.exist?('/etc/os-release') && (os_release_info = os_release_file_is_cisco? ) # check if Cisco
|
78
|
+
platform os_release_info['ID']
|
79
|
+
platform_family os_release_info['ID_LIKE']
|
80
|
+
platform_version os_release_info['VERSION'] || ""
|
81
|
+
else
|
82
|
+
contents = File.read("/etc/redhat-release").chomp
|
83
|
+
platform get_redhatish_platform(contents)
|
84
|
+
platform_version get_redhatish_version(contents)
|
85
|
+
end
|
86
|
+
elsif File.exist?("/etc/system-release")
|
67
87
|
contents = File.read("/etc/system-release").chomp
|
68
88
|
platform get_redhatish_platform(contents)
|
69
89
|
platform_version get_redhatish_version(contents)
|
70
|
-
elsif File.
|
90
|
+
elsif File.exist?('/etc/gentoo-release')
|
71
91
|
platform "gentoo"
|
72
92
|
platform_version File.read('/etc/gentoo-release').scan(/(\d+|\.+)/).join
|
73
|
-
elsif File.
|
93
|
+
elsif File.exist?('/etc/SuSE-release')
|
74
94
|
suse_release = File.read("/etc/SuSE-release")
|
75
95
|
suse_version = suse_release.scan(/VERSION = (\d+)\nPATCHLEVEL = (\d+)/).flatten.join(".")
|
76
96
|
suse_version = suse_release[/VERSION = ([\d\.]{2,})/, 1] if suse_version == ""
|
@@ -80,15 +100,15 @@ Ohai.plugin(:Platform) do
|
|
80
100
|
else
|
81
101
|
platform "suse"
|
82
102
|
end
|
83
|
-
elsif File.
|
103
|
+
elsif File.exist?('/etc/slackware-version')
|
84
104
|
platform "slackware"
|
85
105
|
platform_version File.read("/etc/slackware-version").scan(/(\d+|\.+)/).join
|
86
|
-
elsif File.
|
106
|
+
elsif File.exist?('/etc/arch-release')
|
87
107
|
platform "arch"
|
88
108
|
# no way to determine platform_version in a rolling release distribution
|
89
109
|
# kernel release will be used - ex. 2.6.32-ARCH
|
90
110
|
platform_version `uname -r`.strip
|
91
|
-
elsif File.
|
111
|
+
elsif File.exist?('/etc/exherbo-release')
|
92
112
|
platform "exherbo"
|
93
113
|
# no way to determine platform_version in a rolling release distribution
|
94
114
|
# kernel release will be used - ex. 3.13
|
@@ -53,13 +53,19 @@
|
|
53
53
|
# srcof qfe1
|
54
54
|
# inet6 fe80::203:baff:fe17:4444/128
|
55
55
|
|
56
|
+
# Extracted from http://illumos.org/hcl/
|
57
|
+
ETHERNET_ENCAPS = %w{ afe amd8111s arn atge ath bfe bge bnx bnxe ce cxgbe
|
58
|
+
dmfe e1000g efe elxl emlxs eri hermon hme hxge igb
|
59
|
+
iprb ipw iwh iwi iwk iwp ixgb ixgbe mwl mxfe myri10ge
|
60
|
+
nge ntxn nxge pcn platform qfe qlc ral rge rtls rtw rwd
|
61
|
+
rwn sfe tavor vr wpi xge yge}
|
62
|
+
|
56
63
|
Ohai.plugin(:Network) do
|
57
64
|
provides "network", "network/interfaces"
|
58
65
|
provides "counters/network", "counters/network/interfaces"
|
59
66
|
|
60
67
|
def solaris_encaps_lookup(ifname)
|
61
|
-
return "Ethernet" if
|
62
|
-
return "Ethernet" if ifname.eql?("eri")
|
68
|
+
return "Ethernet" if ETHERNET_ENCAPS.include?(ifname)
|
63
69
|
return "Ethernet" if ifname.eql?("net")
|
64
70
|
return "Loopback" if ifname.eql?("lo")
|
65
71
|
"Unknown"
|
@@ -117,9 +123,11 @@ Ohai.plugin(:Network) do
|
|
117
123
|
end
|
118
124
|
end
|
119
125
|
|
126
|
+
# Device IP Address Mask Flags Phys Addr
|
127
|
+
# bge1 172.16.0.129 255.255.255.255 SPLA 00:03:ba:xx:xx:xx
|
120
128
|
so = shell_out("arp -an")
|
121
129
|
so.stdout.lines do |line|
|
122
|
-
if line =~ /([0-9a-zA-Z]+)\s+(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\s+(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\s+(\w+)
|
130
|
+
if line =~ /([0-9a-zA-Z]+)\s+(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\s+(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\s+(\w+)?\s+([a-zA-Z0-9\.\:\-]+)/
|
123
131
|
next unless iface[arpname_to_ifname(iface, $1)] # this should never happen, except on solaris because sun hates you.
|
124
132
|
iface[arpname_to_ifname(iface, $1)][:arp] = Mash.new unless iface[arpname_to_ifname(iface, $1)][:arp]
|
125
133
|
iface[arpname_to_ifname(iface, $1)][:arp][$2] = $5
|
data/lib/ohai/system.rb
CHANGED
@@ -178,7 +178,7 @@ module Ohai
|
|
178
178
|
# Pretty Print this object as JSON
|
179
179
|
#
|
180
180
|
def json_pretty_print(item=nil)
|
181
|
-
FFI_Yajl::Encoder.new(:
|
181
|
+
FFI_Yajl::Encoder.new(pretty: true, validate_utf8: false).encode(item || @data)
|
182
182
|
end
|
183
183
|
|
184
184
|
def attributes_print(a)
|
data/lib/ohai/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -33,7 +33,7 @@ def get_plugin(plugin, ohai = Ohai::System.new, path = PLUGIN_PATH)
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def convert_windows_output(stdout)
|
36
|
-
|
36
|
+
stdout.gsub("\n", "\r\n")
|
37
37
|
end
|
38
38
|
|
39
39
|
def it_should_check_from(plugin, attribute, from, value)
|
@@ -91,6 +91,10 @@ end
|
|
91
91
|
|
92
92
|
RSpec.configure do |config|
|
93
93
|
|
94
|
+
# Not worth addressing warnings in Ohai until upstream ones in ffi-yajl are
|
95
|
+
# fixed.
|
96
|
+
# config.warnings = true
|
97
|
+
|
94
98
|
config.raise_errors_for_deprecations!
|
95
99
|
|
96
100
|
# `expect` should be preferred for new tests or when refactoring old tests,
|
@@ -49,7 +49,7 @@ describe Ohai::Mixin::Ec2Metadata do
|
|
49
49
|
let(:response) { double("Net::HTTP Response", :body => "2020-01-01\nUnsupported", :code => "200") }
|
50
50
|
|
51
51
|
it "raises an error" do
|
52
|
-
expect { mixin.best_api_version}.to raise_error
|
52
|
+
expect { mixin.best_api_version}.to raise_error(RuntimeError)
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
@@ -66,7 +66,7 @@ describe Ohai::Mixin::Ec2Metadata do
|
|
66
66
|
let(:response) { double("Net::HTTP Response", :body => "1.0\n2011-05-01\n2012-01-12\nUnsupported", :code => "418") }
|
67
67
|
|
68
68
|
it "raises an error" do
|
69
|
-
expect { mixin.best_api_version}.to raise_error
|
69
|
+
expect { mixin.best_api_version}.to raise_error(RuntimeError)
|
70
70
|
end
|
71
71
|
end
|
72
72
|
end
|
@@ -52,22 +52,22 @@ describe "CloudAttrs object" do
|
|
52
52
|
|
53
53
|
it "throws exception with a bad ipv4 address" do
|
54
54
|
@cloud_attr_obj = ::CloudAttrs.new()
|
55
|
-
expect { @cloud_attr_obj.add_ipv6_addr("somebogusstring", :public) }.to raise_error
|
55
|
+
expect { @cloud_attr_obj.add_ipv6_addr("somebogusstring", :public) }.to raise_error(RuntimeError)
|
56
56
|
end
|
57
57
|
|
58
58
|
it "throws exception with a bad ipv6 address" do
|
59
59
|
@cloud_attr_obj = ::CloudAttrs.new()
|
60
|
-
expect { @cloud_attr_obj.add_ipv6_addr("FEED:B0B:DEAD:BEEF", :public) }.to raise_error
|
60
|
+
expect { @cloud_attr_obj.add_ipv6_addr("FEED:B0B:DEAD:BEEF", :public) }.to raise_error(RuntimeError)
|
61
61
|
end
|
62
62
|
|
63
63
|
it "throws exception with ipv6 address passed to ipv4" do
|
64
64
|
@cloud_attr_obj = ::CloudAttrs.new()
|
65
|
-
expect { @cloud_attr_obj.add_ipv4_addr("3ffe:506:2::1", :public) }.to raise_error
|
65
|
+
expect { @cloud_attr_obj.add_ipv4_addr("3ffe:506:2::1", :public) }.to raise_error(RuntimeError)
|
66
66
|
end
|
67
67
|
|
68
68
|
it "throws exception with ipv4 address passed to ipv6" do
|
69
69
|
@cloud_attr_obj = ::CloudAttrs.new()
|
70
|
-
expect { @cloud_attr_obj.add_ipv6_addr("1.2.3.4", :public) }.to raise_error
|
70
|
+
expect { @cloud_attr_obj.add_ipv6_addr("1.2.3.4", :public) }.to raise_error(RuntimeError)
|
71
71
|
end
|
72
72
|
|
73
73
|
|
@@ -21,22 +21,40 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
|
|
21
21
|
require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
|
22
22
|
|
23
23
|
describe Ohai::System, "Linux plugin platform" do
|
24
|
+
|
25
|
+
let(:have_debian_version) { false }
|
26
|
+
let(:have_redhat_release) { false }
|
27
|
+
let(:have_gentoo_release) { false }
|
28
|
+
let(:have_exherbo_release) { false }
|
29
|
+
let(:have_suse_release) { false }
|
30
|
+
let(:have_arch_release) { false }
|
31
|
+
let(:have_system_release) { false }
|
32
|
+
let(:have_slackware_version) { false }
|
33
|
+
let(:have_enterprise_release) { false }
|
34
|
+
let(:have_oracle_release) { false }
|
35
|
+
let(:have_parallels_release) { false }
|
36
|
+
let(:have_raspi_config) { false }
|
37
|
+
let(:have_os_release) { false }
|
38
|
+
|
24
39
|
before(:each) do
|
25
40
|
@plugin = get_plugin("linux/platform")
|
26
41
|
allow(@plugin).to receive(:collect_os).and_return(:linux)
|
27
42
|
@plugin[:lsb] = Mash.new
|
28
|
-
allow(File).to receive(:
|
29
|
-
allow(File).to receive(:
|
30
|
-
allow(File).to receive(:
|
31
|
-
allow(File).to receive(:
|
32
|
-
allow(File).to receive(:
|
33
|
-
allow(File).to receive(:
|
34
|
-
allow(File).to receive(:
|
35
|
-
allow(File).to receive(:
|
36
|
-
allow(File).to receive(:
|
37
|
-
allow(File).to receive(:
|
38
|
-
allow(File).to receive(:
|
39
|
-
allow(File).to receive(:
|
43
|
+
allow(File).to receive(:exist?).with("/etc/debian_version").and_return(have_debian_version)
|
44
|
+
allow(File).to receive(:exist?).with("/etc/redhat-release").and_return(have_redhat_release)
|
45
|
+
allow(File).to receive(:exist?).with("/etc/gentoo-release").and_return(have_gentoo_release)
|
46
|
+
allow(File).to receive(:exist?).with("/etc/exherbo-release").and_return(have_exherbo_release)
|
47
|
+
allow(File).to receive(:exist?).with("/etc/SuSE-release").and_return(have_suse_release)
|
48
|
+
allow(File).to receive(:exist?).with("/etc/arch-release").and_return(have_arch_release)
|
49
|
+
allow(File).to receive(:exist?).with("/etc/system-release").and_return(have_system_release)
|
50
|
+
allow(File).to receive(:exist?).with("/etc/slackware-version").and_return(have_slackware_version)
|
51
|
+
allow(File).to receive(:exist?).with("/etc/enterprise-release").and_return(have_enterprise_release)
|
52
|
+
allow(File).to receive(:exist?).with("/etc/oracle-release").and_return(have_oracle_release)
|
53
|
+
allow(File).to receive(:exist?).with("/etc/parallels-release").and_return(have_parallels_release)
|
54
|
+
allow(File).to receive(:exist?).with("/usr/bin/raspi-config").and_return(have_raspi_config)
|
55
|
+
allow(File).to receive(:exist?).with("/etc/os-release").and_return(have_os_release)
|
56
|
+
|
57
|
+
allow(File).to receive(:read).with("PLEASE STUB ALL File.read CALLS")
|
40
58
|
end
|
41
59
|
|
42
60
|
describe "on lsb compliant distributions" do
|
@@ -109,9 +127,11 @@ describe Ohai::System, "Linux plugin platform" do
|
|
109
127
|
end
|
110
128
|
|
111
129
|
describe "on debian" do
|
130
|
+
|
131
|
+
let(:have_debian_version) { true }
|
132
|
+
|
112
133
|
before(:each) do
|
113
134
|
@plugin.lsb = nil
|
114
|
-
expect(File).to receive(:exists?).with("/etc/debian_version").and_return(true)
|
115
135
|
end
|
116
136
|
|
117
137
|
it "should read the version from /etc/debian_version" do
|
@@ -134,20 +154,26 @@ describe Ohai::System, "Linux plugin platform" do
|
|
134
154
|
expect(@plugin[:platform]).to eq("ubuntu")
|
135
155
|
end
|
136
156
|
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
157
|
+
context "on raspbian" do
|
158
|
+
|
159
|
+
let(:have_raspi_config) { true }
|
160
|
+
|
161
|
+
# Raspbian is a debian clone
|
162
|
+
it "should detect Raspbian as itself with debian as the family" do
|
163
|
+
expect(File).to receive(:read).with("/etc/debian_version").and_return("wheezy/sid")
|
164
|
+
@plugin.run
|
165
|
+
expect(@plugin[:platform]).to eq("raspbian")
|
166
|
+
expect(@plugin[:platform_family]).to eq("debian")
|
167
|
+
end
|
144
168
|
end
|
145
169
|
end
|
146
170
|
|
147
171
|
describe "on slackware" do
|
172
|
+
|
173
|
+
let(:have_slackware_version) { true }
|
174
|
+
|
148
175
|
before(:each) do
|
149
176
|
@plugin.lsb = nil
|
150
|
-
expect(File).to receive(:exists?).with("/etc/slackware-version").and_return(true)
|
151
177
|
end
|
152
178
|
|
153
179
|
it "should set platform and platform_family to slackware" do
|
@@ -159,9 +185,11 @@ describe Ohai::System, "Linux plugin platform" do
|
|
159
185
|
end
|
160
186
|
|
161
187
|
describe "on arch" do
|
188
|
+
|
189
|
+
let(:have_arch_release) { true }
|
190
|
+
|
162
191
|
before(:each) do
|
163
192
|
@plugin.lsb = nil
|
164
|
-
expect(File).to receive(:exists?).with("/etc/arch-release").and_return(true)
|
165
193
|
end
|
166
194
|
|
167
195
|
it "should set platform to arch and platform_family to arch" do
|
@@ -175,13 +203,14 @@ describe Ohai::System, "Linux plugin platform" do
|
|
175
203
|
@plugin.run
|
176
204
|
expect(@plugin[:platform_version]).to eq('3.18.2-2-ARCH')
|
177
205
|
end
|
178
|
-
|
179
206
|
end
|
180
207
|
|
181
208
|
describe "on gentoo" do
|
209
|
+
|
210
|
+
let(:have_gentoo_release) { true }
|
211
|
+
|
182
212
|
before(:each) do
|
183
213
|
@plugin.lsb = nil
|
184
|
-
expect(File).to receive(:exists?).with("/etc/gentoo-release").and_return(true)
|
185
214
|
end
|
186
215
|
|
187
216
|
it "should set platform and platform_family to gentoo" do
|
@@ -193,9 +222,11 @@ describe Ohai::System, "Linux plugin platform" do
|
|
193
222
|
end
|
194
223
|
|
195
224
|
describe "on exherbo" do
|
225
|
+
|
226
|
+
let(:have_exherbo_release) { true }
|
227
|
+
|
196
228
|
before(:each) do
|
197
229
|
@plugin.lsb = nil
|
198
|
-
expect(File).to receive(:exists?).with("/etc/exherbo-release").and_return(true)
|
199
230
|
end
|
200
231
|
|
201
232
|
it "should set platform and platform_family to exherbo" do
|
@@ -264,9 +295,11 @@ describe Ohai::System, "Linux plugin platform" do
|
|
264
295
|
end
|
265
296
|
|
266
297
|
describe "without lsb_release results" do
|
298
|
+
|
299
|
+
let(:have_redhat_release) { true }
|
300
|
+
|
267
301
|
before(:each) do
|
268
302
|
@plugin.lsb = nil
|
269
|
-
expect(File).to receive(:exists?).with("/etc/redhat-release").and_return(true)
|
270
303
|
end
|
271
304
|
|
272
305
|
it "should read the platform as centos and version as 5.3" do
|
@@ -310,17 +343,56 @@ describe Ohai::System, "Linux plugin platform" do
|
|
310
343
|
expect(@plugin[:platform_version].to_i).to eq(13)
|
311
344
|
end
|
312
345
|
|
346
|
+
# https://github.com/chef/ohai/issues/560
|
347
|
+
# Issue is seen on EL7, so that's what we're testing.
|
348
|
+
context "on versions that have /etc/os-release" do
|
349
|
+
|
350
|
+
let(:have_os_release) { true }
|
351
|
+
|
352
|
+
let(:os_release_content) do
|
353
|
+
<<-OS_RELEASE
|
354
|
+
NAME="CentOS Linux"
|
355
|
+
VERSION="7 (Core)"
|
356
|
+
ID="centos"
|
357
|
+
ID_LIKE="rhel fedora"
|
358
|
+
VERSION_ID="7"
|
359
|
+
PRETTY_NAME="CentOS Linux 7 (Core)"
|
360
|
+
ANSI_COLOR="0;31"
|
361
|
+
CPE_NAME="cpe:/o:centos:centos:7"
|
362
|
+
HOME_URL="https://www.centos.org/"
|
363
|
+
BUG_REPORT_URL="https://bugs.centos.org/"
|
364
|
+
|
365
|
+
OS_RELEASE
|
366
|
+
end
|
367
|
+
|
368
|
+
before do
|
369
|
+
expect(File).to receive(:read).with("/etc/os-release").and_return(os_release_content)
|
370
|
+
expect(File).to receive(:read).with("/etc/redhat-release").and_return("CentOS release 7.1")
|
371
|
+
end
|
372
|
+
|
373
|
+
it "correctly detects EL7" do
|
374
|
+
@plugin.run
|
375
|
+
expect(@plugin[:platform]).to eq("centos")
|
376
|
+
expect(@plugin[:platform_version]).to eq("7.1")
|
377
|
+
end
|
378
|
+
|
379
|
+
end
|
380
|
+
|
313
381
|
end
|
382
|
+
|
314
383
|
end
|
315
384
|
|
316
385
|
describe "on pcs linux" do
|
386
|
+
|
387
|
+
let(:have_redhat_release) { true }
|
388
|
+
let(:have_parallels_release) { true }
|
389
|
+
|
317
390
|
describe "with lsb_result" do
|
391
|
+
|
318
392
|
it "should read the platform as parallels and version as 6.0.5" do
|
319
393
|
@plugin[:lsb][:id] = "CloudLinuxServer"
|
320
394
|
@plugin[:lsb][:release] = "6.5"
|
321
|
-
allow(File).to receive(:exists?).with("/etc/redhat-release").and_return(true)
|
322
395
|
allow(File).to receive(:read).with("/etc/redhat-release").and_return("CloudLinux Server release 6.5 (Pavel Popovich)")
|
323
|
-
expect(File).to receive(:exists?).with("/etc/parallels-release").and_return(true)
|
324
396
|
expect(File).to receive(:read).with("/etc/parallels-release").and_return("Parallels Cloud Server 6.0.5 (20007)")
|
325
397
|
@plugin.run
|
326
398
|
expect(@plugin[:platform]).to eq("parallels")
|
@@ -330,14 +402,13 @@ describe Ohai::System, "Linux plugin platform" do
|
|
330
402
|
end
|
331
403
|
|
332
404
|
describe "without lsb_results" do
|
405
|
+
|
333
406
|
before(:each) do
|
334
407
|
@plugin.lsb = nil
|
335
408
|
end
|
336
409
|
|
337
410
|
it "should read the platform as parallels and version as 6.0.5" do
|
338
|
-
allow(File).to receive(:exists?).with("/etc/redhat-release").and_return(true)
|
339
411
|
allow(File).to receive(:read).with("/etc/redhat-release").and_return("CloudLinux Server release 6.5 (Pavel Popovich)")
|
340
|
-
expect(File).to receive(:exists?).with("/etc/parallels-release").and_return(true)
|
341
412
|
expect(File).to receive(:read).with("/etc/parallels-release").and_return("Parallels Cloud Server 6.0.5 (20007)")
|
342
413
|
@plugin.run
|
343
414
|
expect(@plugin[:platform]).to eq("parallels")
|
@@ -348,93 +419,104 @@ describe Ohai::System, "Linux plugin platform" do
|
|
348
419
|
end
|
349
420
|
|
350
421
|
describe "on oracle enterprise linux" do
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
422
|
+
|
423
|
+
let(:have_redhat_release) { true }
|
424
|
+
|
425
|
+
context "with lsb_results" do
|
426
|
+
|
427
|
+
context "on version 5.x" do
|
428
|
+
|
429
|
+
let(:have_enterprise_release) { true }
|
430
|
+
|
431
|
+
it "should read the platform as oracle and version as 5.7" do
|
432
|
+
@plugin[:lsb][:id] = "EnterpriseEnterpriseServer"
|
433
|
+
@plugin[:lsb][:release] = "5.7"
|
434
|
+
allow(File).to receive(:read).with("/etc/redhat-release").and_return("Red Hat Enterprise Linux Server release 5.7 (Tikanga)")
|
435
|
+
expect(File).to receive(:read).with("/etc/enterprise-release").and_return("Enterprise Linux Enterprise Linux Server release 5.7 (Carthage)")
|
436
|
+
@plugin.run
|
437
|
+
expect(@plugin[:platform]).to eq("oracle")
|
438
|
+
expect(@plugin[:platform_version]).to eq("5.7")
|
439
|
+
end
|
362
440
|
end
|
363
441
|
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
442
|
+
context "on version 6.x" do
|
443
|
+
|
444
|
+
let(:have_oracle_release) { true }
|
445
|
+
|
446
|
+
it "should read the platform as oracle and version as 6.1" do
|
447
|
+
@plugin[:lsb][:id] = "OracleServer"
|
448
|
+
@plugin[:lsb][:release] = "6.1"
|
449
|
+
allow(File).to receive(:read).with("/etc/redhat-release").and_return("Red Hat Enterprise Linux Server release 6.1 (Santiago)")
|
450
|
+
expect(File).to receive(:read).with("/etc/oracle-release").and_return("Oracle Linux Server release 6.1")
|
451
|
+
@plugin.run
|
452
|
+
expect(@plugin[:platform]).to eq("oracle")
|
453
|
+
expect(@plugin[:platform_version]).to eq("6.1")
|
454
|
+
end
|
455
|
+
|
374
456
|
end
|
375
457
|
end
|
376
458
|
|
377
|
-
|
459
|
+
context "without lsb_results" do
|
378
460
|
before(:each) do
|
379
461
|
@plugin.lsb = nil
|
380
462
|
end
|
381
463
|
|
382
|
-
|
383
|
-
allow(File).to receive(:exists?).with("/etc/redhat-release").and_return(true)
|
384
|
-
allow(File).to receive(:read).with("/etc/redhat-release").and_return("Enterprise Linux Enterprise Linux Server release 5 (Carthage)")
|
385
|
-
expect(File).to receive(:exists?).with("/etc/enterprise-release").and_return(true)
|
386
|
-
expect(File).to receive(:read).with("/etc/enterprise-release").and_return("Enterprise Linux Enterprise Linux Server release 5 (Carthage)")
|
387
|
-
@plugin.run
|
388
|
-
expect(@plugin[:platform]).to eq("oracle")
|
389
|
-
expect(@plugin[:platform_version]).to eq("5")
|
390
|
-
end
|
464
|
+
context "on version 5.x" do
|
391
465
|
|
392
|
-
|
393
|
-
allow(File).to receive(:exists?).with("/etc/redhat-release").and_return(true)
|
394
|
-
allow(File).to receive(:read).with("/etc/redhat-release").and_return("Enterprise Linux Enterprise Linux Server release 5.1 (Carthage)")
|
395
|
-
expect(File).to receive(:exists?).with("/etc/enterprise-release").and_return(true)
|
396
|
-
expect(File).to receive(:read).with("/etc/enterprise-release").and_return("Enterprise Linux Enterprise Linux Server release 5.1 (Carthage)")
|
397
|
-
@plugin.run
|
398
|
-
expect(@plugin[:platform]).to eq("oracle")
|
399
|
-
expect(@plugin[:platform_version]).to eq("5.1")
|
400
|
-
end
|
466
|
+
let(:have_enterprise_release) { true }
|
401
467
|
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
468
|
+
it "should read the platform as oracle and version as 5" do
|
469
|
+
allow(File).to receive(:read).with("/etc/redhat-release").and_return("Enterprise Linux Enterprise Linux Server release 5 (Carthage)")
|
470
|
+
expect(File).to receive(:read).with("/etc/enterprise-release").and_return("Enterprise Linux Enterprise Linux Server release 5 (Carthage)")
|
471
|
+
@plugin.run
|
472
|
+
expect(@plugin[:platform]).to eq("oracle")
|
473
|
+
expect(@plugin[:platform_version]).to eq("5")
|
474
|
+
end
|
475
|
+
|
476
|
+
it "should read the platform as oracle and version as 5.1" do
|
477
|
+
allow(File).to receive(:read).with("/etc/redhat-release").and_return("Enterprise Linux Enterprise Linux Server release 5.1 (Carthage)")
|
478
|
+
expect(File).to receive(:read).with("/etc/enterprise-release").and_return("Enterprise Linux Enterprise Linux Server release 5.1 (Carthage)")
|
479
|
+
@plugin.run
|
480
|
+
expect(@plugin[:platform]).to eq("oracle")
|
481
|
+
expect(@plugin[:platform_version]).to eq("5.1")
|
482
|
+
end
|
483
|
+
|
484
|
+
it "should read the platform as oracle and version as 5.7" do
|
485
|
+
allow(File).to receive(:read).with("/etc/redhat-release").and_return("Red Hat Enterprise Linux Server release 5.7 (Tikanga)")
|
486
|
+
expect(File).to receive(:read).with("/etc/enterprise-release").and_return("Enterprise Linux Enterprise Linux Server release 5.7 (Carthage)")
|
487
|
+
@plugin.run
|
488
|
+
expect(@plugin[:platform]).to eq("oracle")
|
489
|
+
expect(@plugin[:platform_version]).to eq("5.7")
|
490
|
+
end
|
411
491
|
|
412
|
-
it "should read the platform as oracle and version as 6.0" do
|
413
|
-
allow(File).to receive(:exists?).with("/etc/redhat-release").and_return(true)
|
414
|
-
allow(File).to receive(:read).with("/etc/redhat-release").and_return("Red Hat Enterprise Linux Server release 6.0 (Santiago)")
|
415
|
-
expect(File).to receive(:exists?).with("/etc/oracle-release").and_return(true)
|
416
|
-
expect(File).to receive(:read).with("/etc/oracle-release").and_return("Oracle Linux Server release 6.0")
|
417
|
-
@plugin.run
|
418
|
-
expect(@plugin[:platform]).to eq("oracle")
|
419
|
-
expect(@plugin[:platform_version]).to eq("6.0")
|
420
492
|
end
|
421
493
|
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
494
|
+
context "on version 6.x" do
|
495
|
+
|
496
|
+
let(:have_oracle_release) { true }
|
497
|
+
|
498
|
+
it "should read the platform as oracle and version as 6.0" do
|
499
|
+
allow(File).to receive(:read).with("/etc/redhat-release").and_return("Red Hat Enterprise Linux Server release 6.0 (Santiago)")
|
500
|
+
expect(File).to receive(:read).with("/etc/oracle-release").and_return("Oracle Linux Server release 6.0")
|
501
|
+
@plugin.run
|
502
|
+
expect(@plugin[:platform]).to eq("oracle")
|
503
|
+
expect(@plugin[:platform_version]).to eq("6.0")
|
504
|
+
end
|
505
|
+
|
506
|
+
it "should read the platform as oracle and version as 6.1" do
|
507
|
+
allow(File).to receive(:read).with("/etc/redhat-release").and_return("Red Hat Enterprise Linux Server release 6.1 (Santiago)")
|
508
|
+
expect(File).to receive(:read).with("/etc/oracle-release").and_return("Oracle Linux Server release 6.1")
|
509
|
+
@plugin.run
|
510
|
+
expect(@plugin[:platform]).to eq("oracle")
|
511
|
+
expect(@plugin[:platform_version]).to eq("6.1")
|
512
|
+
end
|
430
513
|
end
|
431
514
|
end
|
432
515
|
end
|
433
516
|
|
434
517
|
describe "on suse" do
|
435
|
-
|
436
|
-
|
437
|
-
end
|
518
|
+
|
519
|
+
let(:have_suse_release) { true }
|
438
520
|
|
439
521
|
describe "with lsb_release results" do
|
440
522
|
before(:each) do
|
@@ -510,4 +592,19 @@ describe Ohai::System, "Linux plugin platform" do
|
|
510
592
|
end
|
511
593
|
end
|
512
594
|
end
|
595
|
+
|
596
|
+
describe "on Wind River Linux for Cisco Nexus" do
|
597
|
+
|
598
|
+
let(:have_redhat_release) { true }
|
599
|
+
|
600
|
+
let(:have_os_release) { true }
|
601
|
+
|
602
|
+
it "should set platform to nexus and platform_family to wrlinux" do
|
603
|
+
@plugin.lsb = nil
|
604
|
+
expect(File).to receive(:read).with("/etc/os-release").and_return("ID_LIKE=wrlinux\nID=nexus\nCISCO_RELEASE_INFO=/etc/os-release")
|
605
|
+
@plugin.run
|
606
|
+
expect(@plugin[:platform]).to eq("nexus")
|
607
|
+
expect(@plugin[:platform_family]).to eq("wrlinux")
|
608
|
+
end
|
609
|
+
end
|
513
610
|
end
|
@@ -6,9 +6,9 @@
|
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
7
|
# you may not use this file except in compliance with the License.
|
8
8
|
# You may obtain a copy of the License at
|
9
|
-
#
|
9
|
+
#
|
10
10
|
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
11
|
+
#
|
12
12
|
# Unless required by applicable law or agreed to in writing, software
|
13
13
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
14
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
@@ -32,20 +32,20 @@ describe Ohai::System, "plugin platform" do
|
|
32
32
|
expect(@plugin[:platform]).to eql("monkey")
|
33
33
|
expect(@plugin[:platform_family]).to eql("monkey")
|
34
34
|
end
|
35
|
-
|
35
|
+
|
36
36
|
it "should not set the platform to the os if it was set earlier" do
|
37
37
|
@plugin[:platform] = 'lars'
|
38
38
|
@plugin.run
|
39
39
|
expect(@plugin[:platform]).to eql("lars")
|
40
40
|
end
|
41
|
-
|
41
|
+
|
42
42
|
it "should set the platform_family to the platform if platform was set earlier but not platform_family" do
|
43
43
|
@plugin[:platform] = 'lars'
|
44
44
|
@plugin[:platform_family] = 'jack'
|
45
45
|
@plugin.run
|
46
46
|
expect(@plugin[:platform_family]).to eql("jack")
|
47
47
|
end
|
48
|
-
|
48
|
+
|
49
49
|
it "should not set the platform_family if the platform_family was set earlier." do
|
50
50
|
@plugin[:platform] = 'lars'
|
51
51
|
@plugin.run
|
@@ -57,7 +57,7 @@ describe Ohai::System, "plugin platform" do
|
|
57
57
|
@plugin.run
|
58
58
|
expect(@plugin[:os_version]).to eql("poop")
|
59
59
|
end
|
60
|
-
|
60
|
+
|
61
61
|
it "should not set the platform to the os if it was set earlier" do
|
62
62
|
@plugin[:platform_version] = 'ulrich'
|
63
63
|
@plugin.run
|
@@ -6,9 +6,9 @@
|
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
7
|
# you may not use this file except in compliance with the License.
|
8
8
|
# You may obtain a copy of the License at
|
9
|
-
#
|
9
|
+
#
|
10
10
|
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
11
|
+
#
|
12
12
|
# Unless required by applicable law or agreed to in writing, software
|
13
13
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
14
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
@@ -47,14 +47,14 @@ describe Ohai::System, "plugin ruby" do
|
|
47
47
|
:host_cpu => ::RbConfig::CONFIG['host_cpu'],
|
48
48
|
:host_os => ::RbConfig::CONFIG['host_os'],
|
49
49
|
:host_vendor => ::RbConfig::CONFIG['host_vendor'],
|
50
|
-
:gems_dir => %x{#{ruby_bin} #{::RbConfig::CONFIG['bindir']}/gem env gemdir}.chomp
|
50
|
+
:gems_dir => %x{#{ruby_bin} #{::RbConfig::CONFIG['bindir']}/gem env gemdir}.chomp,
|
51
51
|
:gem_bin => [ ::Gem.default_exec_format % 'gem', 'gem' ].map{|bin| "#{::RbConfig::CONFIG['bindir']}/#{bin}"
|
52
52
|
}.find{|bin| ::File.exists? bin},
|
53
53
|
:ruby_bin => ruby_bin
|
54
54
|
}.each do |attribute, value|
|
55
|
-
it "should have #{attribute} set" do
|
55
|
+
it "should have #{attribute} set to #{value.inspect}" do
|
56
56
|
expect(@ruby_ohai_data[attribute]).to eql(value)
|
57
57
|
end
|
58
58
|
end
|
59
|
-
|
59
|
+
|
60
60
|
end
|
data/spec/unit/runner_spec.rb
CHANGED
@@ -141,7 +141,7 @@ describe Ohai::Runner, "run_plugin" do
|
|
141
141
|
end
|
142
142
|
|
143
143
|
it "should not run the plugin" do
|
144
|
-
expect{ @runner.run_plugin(@plugin) }.to raise_error
|
144
|
+
expect{ @runner.run_plugin(@plugin) }.to raise_error(Ohai::Exceptions::AttributeNotFound)
|
145
145
|
expect(@plugin.has_run?).to be false
|
146
146
|
end
|
147
147
|
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.5.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: 2015-
|
11
|
+
date: 2015-06-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mime-types
|
@@ -42,22 +42,16 @@ dependencies:
|
|
42
42
|
name: ffi-yajl
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '1.1'
|
48
|
-
- - "<"
|
45
|
+
- - "~>"
|
49
46
|
- !ruby/object:Gem::Version
|
50
|
-
version: '
|
47
|
+
version: '2.2'
|
51
48
|
type: :runtime
|
52
49
|
prerelease: false
|
53
50
|
version_requirements: !ruby/object:Gem::Requirement
|
54
51
|
requirements:
|
55
|
-
- - "
|
56
|
-
- !ruby/object:Gem::Version
|
57
|
-
version: '1.1'
|
58
|
-
- - "<"
|
52
|
+
- - "~>"
|
59
53
|
- !ruby/object:Gem::Version
|
60
|
-
version: '
|
54
|
+
version: '2.2'
|
61
55
|
- !ruby/object:Gem::Dependency
|
62
56
|
name: mixlib-cli
|
63
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -537,7 +531,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
537
531
|
version: '0'
|
538
532
|
requirements: []
|
539
533
|
rubyforge_project:
|
540
|
-
rubygems_version: 2.4.
|
534
|
+
rubygems_version: 2.4.4
|
541
535
|
signing_key:
|
542
536
|
specification_version: 4
|
543
537
|
summary: Ohai profiles your system and emits JSON
|