ohai 14.15.0 → 15.0.35
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/application.rb +0 -4
- data/lib/ohai/common/dmi.rb +43 -43
- data/lib/ohai/config.rb +1 -1
- data/lib/ohai/loader.rb +32 -47
- data/lib/ohai/mixin/dmi_decode.rb +29 -32
- data/lib/ohai/mixin/os.rb +0 -2
- data/lib/ohai/mixin/softlayer_metadata.rb +5 -5
- data/lib/ohai/plugins/aix/virtualization.rb +4 -4
- data/lib/ohai/plugins/bsd/virtualization.rb +10 -12
- data/lib/ohai/plugins/c.rb +0 -20
- data/lib/ohai/plugins/elixir.rb +13 -13
- data/lib/ohai/plugins/filesystem.rb +10 -10
- data/lib/ohai/plugins/gce.rb +42 -8
- data/lib/ohai/plugins/go.rb +11 -11
- data/lib/ohai/plugins/groovy.rb +12 -12
- data/lib/ohai/plugins/hostname.rb +9 -2
- data/lib/ohai/plugins/linux/fips.rb +2 -9
- data/lib/ohai/plugins/linux/memory.rb +5 -0
- data/lib/ohai/plugins/linux/network.rb +1 -1
- data/lib/ohai/plugins/linux/platform.rb +84 -83
- data/lib/ohai/plugins/linux/systemd_paths.rb +0 -3
- data/lib/ohai/plugins/linux/virtualization.rb +10 -20
- data/lib/ohai/plugins/lua.rb +13 -13
- data/lib/ohai/plugins/mono.rb +23 -23
- data/lib/ohai/plugins/nodejs.rb +13 -13
- data/lib/ohai/plugins/openstack.rb +1 -1
- data/lib/ohai/plugins/packages.rb +1 -28
- data/lib/ohai/plugins/perl.rb +17 -17
- data/lib/ohai/plugins/php.rb +22 -22
- data/lib/ohai/plugins/powershell.rb +30 -30
- data/lib/ohai/plugins/ps.rb +1 -1
- data/lib/ohai/plugins/python.rb +15 -15
- data/lib/ohai/plugins/rust.rb +11 -11
- data/lib/ohai/plugins/solaris2/dmi.rb +48 -48
- data/lib/ohai/plugins/solaris2/virtualization.rb +8 -10
- data/lib/ohai/plugins/virtualbox.rb +21 -21
- data/lib/ohai/plugins/windows/filesystem.rb +2 -2
- data/lib/ohai/plugins/windows/fips.rb +2 -21
- data/lib/ohai/plugins/windows/virtualization.rb +9 -35
- data/lib/ohai/runner.rb +2 -2
- data/lib/ohai/system.rb +0 -17
- data/lib/ohai/version.rb +1 -1
- data/ohai.gemspec +2 -2
- data/spec/data/plugins/rpmquery.output +0 -2
- data/spec/functional/application_spec.rb +1 -1
- data/spec/functional/loader_spec.rb +2 -2
- data/spec/functional/plugins/powershell_spec.rb +2 -2
- data/spec/functional/plugins/root_group_spec.rb +1 -1
- data/spec/functional/plugins/windows/uptime_spec.rb +2 -2
- data/spec/ohai_spec.rb +1 -1
- data/spec/unit/application_spec.rb +1 -1
- data/spec/unit/config_spec.rb +1 -1
- data/spec/unit/dsl/plugin_spec.rb +1 -1
- data/spec/unit/hints_spec.rb +2 -2
- data/spec/unit/loader_spec.rb +12 -12
- data/spec/unit/mixin/azure_metadata_spec.rb +1 -1
- data/spec/unit/mixin/command_spec.rb +1 -1
- data/spec/unit/mixin/dmi_decode.rb +68 -0
- 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 +1 -1
- data/spec/unit/plugins/abort_spec.rb +9 -9
- data/spec/unit/plugins/aix/cpu_spec.rb +4 -4
- data/spec/unit/plugins/aix/filesystem_spec.rb +5 -5
- 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 +6 -6
- 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 +2 -2
- data/spec/unit/plugins/azure_spec.rb +1 -1
- data/spec/unit/plugins/bsd/filesystem_spec.rb +4 -4
- data/spec/unit/plugins/bsd/virtualization_spec.rb +3 -3
- data/spec/unit/plugins/c_spec.rb +1 -53
- data/spec/unit/plugins/chef_spec.rb +1 -1
- data/spec/unit/plugins/cloud_spec.rb +1 -1
- data/spec/unit/plugins/darwin/cpu_spec.rb +2 -2
- data/spec/unit/plugins/darwin/filesystem_spec.rb +5 -5
- data/spec/unit/plugins/darwin/hardware_spec.rb +2 -2
- data/spec/unit/plugins/darwin/hardware_system_profiler_output.rb +3 -3
- 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/virtualization_spec.rb +1 -1
- data/spec/unit/plugins/dmi_spec.rb +1 -1
- data/spec/unit/plugins/docker_spec.rb +1 -1
- data/spec/unit/plugins/ec2_spec.rb +1 -1
- 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 +28 -28
- 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/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 +68 -1
- data/spec/unit/plugins/init_package_spec.rb +1 -1
- data/spec/unit/plugins/java_spec.rb +1 -1
- data/spec/unit/plugins/joyent_spec.rb +3 -3
- 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 +6 -6
- data/spec/unit/plugins/linux/filesystem_spec.rb +21 -21
- data/spec/unit/plugins/linux/fips_spec.rb +13 -45
- data/spec/unit/plugins/linux/hostname_spec.rb +1 -1
- data/spec/unit/plugins/linux/hostnamectl_spec.rb +2 -2
- data/spec/unit/plugins/linux/kernel_spec.rb +8 -8
- data/spec/unit/plugins/linux/lsb_spec.rb +3 -3
- data/spec/unit/plugins/linux/lspci_spec.rb +2 -2
- data/spec/unit/plugins/linux/machineid_spec.rb +1 -1
- data/spec/unit/plugins/linux/mdadm_spec.rb +2 -2
- data/spec/unit/plugins/linux/memory_spec.rb +26 -1
- data/spec/unit/plugins/linux/network_spec.rb +37 -37
- data/spec/unit/plugins/linux/platform_spec.rb +580 -837
- data/spec/unit/plugins/linux/sessions_spec.rb +2 -2
- data/spec/unit/plugins/linux/systemd_paths_spec.rb +1 -1
- data/spec/unit/plugins/linux/uptime_spec.rb +1 -1
- data/spec/unit/plugins/linux/virtualization_spec.rb +28 -227
- data/spec/unit/plugins/lua_spec.rb +1 -1
- data/spec/unit/plugins/mono_spec.rb +2 -2
- 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 +11 -11
- 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 +8 -4
- data/spec/unit/plugins/os_spec.rb +1 -1
- data/spec/unit/plugins/packages_spec.rb +1 -21
- data/spec/unit/plugins/passwd_spec.rb +1 -1
- data/spec/unit/plugins/perl_spec.rb +1 -1
- data/spec/unit/plugins/php_spec.rb +6 -6
- data/spec/unit/plugins/platform_spec.rb +1 -1
- data/spec/unit/plugins/powershell_spec.rb +3 -3
- data/spec/unit/plugins/python_spec.rb +1 -1
- data/spec/unit/plugins/rackspace_spec.rb +2 -2
- data/spec/unit/plugins/root_group_spec.rb +1 -11
- 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 +1 -1
- data/spec/unit/plugins/scsi_spec.rb +2 -2
- 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 +3 -3
- data/spec/unit/plugins/solaris2/dmi_spec.rb +1 -1
- data/spec/unit/plugins/solaris2/filesystem.rb +4 -4
- 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 +6 -6
- data/spec/unit/plugins/solaris2/platform_spec.rb +3 -3
- data/spec/unit/plugins/solaris2/virtualization_spec.rb +41 -69
- data/spec/unit/plugins/ssh_host_keys_spec.rb +3 -3
- data/spec/unit/plugins/sysconf_spec.rb +2 -2
- 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 +1 -1
- data/spec/unit/plugins/windows/cpu_spec.rb +1 -2
- data/spec/unit/plugins/windows/filesystem_spec.rb +2 -2
- data/spec/unit/plugins/windows/fips_spec.rb +17 -77
- data/spec/unit/plugins/windows/kernel_spec.rb +1 -1
- data/spec/unit/plugins/windows/memory_spec.rb +2 -2
- data/spec/unit/plugins/windows/network_spec.rb +1 -1
- data/spec/unit/plugins/windows/system_enclosure_spec.rb +1 -1
- data/spec/unit/plugins/windows/uptime_spec.rb +1 -1
- data/spec/unit/plugins/windows/virtualization_spec.rb +20 -238
- data/spec/unit/plugins/zpools_spec.rb +7 -7
- data/spec/unit/provides_map_spec.rb +1 -1
- data/spec/unit/runner_spec.rb +1 -1
- data/spec/unit/system_spec.rb +10 -77
- data/spec/unit/util/file_helper_spec.rb +1 -1
- data/spec/unit/util/ip_helper_spec.rb +1 -1
- metadata +6 -9
- data/lib/ohai/plugins/darwin/system_profiler.rb +0 -72
- data/lib/ohai/util/win32/group_helper.rb +0 -76
- data/spec/unit/plugins/darwin/system_profiler_output.rb +0 -79524
- data/spec/unit/plugins/darwin/system_profiler_spec.rb +0 -40
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Adam Jacob (<adam@chef.io>)
|
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");
|
@@ -16,1045 +16,788 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
|
19
|
-
|
19
|
+
require "spec_helper"
|
20
20
|
|
21
21
|
describe Ohai::System, "Linux plugin platform" do
|
22
|
+
let(:plugin) { get_plugin("linux/platform") }
|
22
23
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
let(:have_eos_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
|
-
let(:have_usr_lib_os_release) { false }
|
39
|
-
let(:have_cisco_release) { false }
|
40
|
-
let(:have_f5_release) { false }
|
41
|
-
let(:have_cumulus_dir) { false }
|
42
|
-
|
43
|
-
before(:each) do
|
44
|
-
@plugin = get_plugin("linux/platform")
|
45
|
-
allow(@plugin).to receive(:collect_os).and_return(:linux)
|
46
|
-
@plugin[:lsb] = Mash.new
|
47
|
-
allow(File).to receive(:exist?).with("/etc/debian_version").and_return(have_debian_version)
|
48
|
-
allow(File).to receive(:exist?).with("/etc/redhat-release").and_return(have_redhat_release)
|
49
|
-
allow(File).to receive(:exist?).with("/etc/gentoo-release").and_return(have_gentoo_release)
|
50
|
-
allow(File).to receive(:exist?).with("/etc/exherbo-release").and_return(have_exherbo_release)
|
51
|
-
allow(File).to receive(:exist?).with("/etc/alpine-release").and_return(have_alpine_release)
|
52
|
-
allow(File).to receive(:exist?).with("/etc/Eos-release").and_return(have_eos_release)
|
53
|
-
allow(File).to receive(:exist?).with("/etc/SuSE-release").and_return(have_suse_release)
|
54
|
-
allow(File).to receive(:exist?).with("/etc/arch-release").and_return(have_arch_release)
|
55
|
-
allow(File).to receive(:exist?).with("/etc/system-release").and_return(have_system_release)
|
56
|
-
allow(File).to receive(:exist?).with("/etc/slackware-version").and_return(have_slackware_version)
|
57
|
-
allow(File).to receive(:exist?).with("/etc/enterprise-release").and_return(have_enterprise_release)
|
58
|
-
allow(File).to receive(:exist?).with("/etc/oracle-release").and_return(have_oracle_release)
|
59
|
-
allow(File).to receive(:exist?).with("/etc/parallels-release").and_return(have_parallels_release)
|
60
|
-
allow(File).to receive(:exist?).with("/usr/bin/raspi-config").and_return(have_raspi_config)
|
61
|
-
allow(File).to receive(:exist?).with("/etc/os-release").and_return(have_os_release)
|
62
|
-
allow(File).to receive(:exist?).with("/etc/f5-release").and_return(have_f5_release)
|
63
|
-
allow(File).to receive(:exist?).with("/usr/lib/os-release").and_return(have_usr_lib_os_release)
|
64
|
-
allow(File).to receive(:exist?).with("/etc/shared/os-release").and_return(have_cisco_release)
|
65
|
-
allow(Dir).to receive(:exist?).with("/etc/cumulus").and_return(have_cumulus_dir)
|
66
|
-
|
67
|
-
allow(File).to receive(:read).with("PLEASE STUB ALL File.read CALLS")
|
68
|
-
end
|
69
|
-
|
70
|
-
describe "on lsb compliant distributions" do
|
71
|
-
before(:each) do
|
72
|
-
@plugin[:lsb][:id] = "Ubuntu"
|
73
|
-
@plugin[:lsb][:release] = "8.04"
|
74
|
-
end
|
75
|
-
|
76
|
-
it "should set platform to lowercased lsb[:id]" do
|
77
|
-
@plugin.run
|
78
|
-
expect(@plugin[:platform]).to eq("ubuntu")
|
79
|
-
end
|
80
|
-
|
81
|
-
it "should set platform_version to lsb[:release]" do
|
82
|
-
@plugin.run
|
83
|
-
expect(@plugin[:platform_version]).to eq("8.04")
|
84
|
-
end
|
85
|
-
|
86
|
-
it "should set platform to ubuntu and platform_family to debian [:lsb][:id] contains Ubuntu" do
|
87
|
-
@plugin[:lsb][:id] = "Ubuntu"
|
88
|
-
@plugin.run
|
89
|
-
expect(@plugin[:platform]).to eq("ubuntu")
|
90
|
-
expect(@plugin[:platform_family]).to eq("debian")
|
91
|
-
end
|
92
|
-
|
93
|
-
it "should set platform to linuxmint and platform_family to debian [:lsb][:id] contains LinuxMint" do
|
94
|
-
@plugin[:lsb][:id] = "LinuxMint"
|
95
|
-
@plugin.run
|
96
|
-
expect(@plugin[:platform]).to eq("linuxmint")
|
97
|
-
expect(@plugin[:platform_family]).to eq("debian")
|
98
|
-
end
|
99
|
-
|
100
|
-
it "should set platform to debian and platform_family to debian [:lsb][:id] contains Debian" do
|
101
|
-
@plugin[:lsb][:id] = "Debian"
|
102
|
-
@plugin.run
|
103
|
-
expect(@plugin[:platform]).to eq("debian")
|
104
|
-
expect(@plugin[:platform_family]).to eq("debian")
|
105
|
-
end
|
106
|
-
|
107
|
-
it "should set platform to redhat and platform_family to rhel when [:lsb][:id] contains Redhat" do
|
108
|
-
@plugin[:lsb][:id] = "RedHatEnterpriseServer"
|
109
|
-
@plugin[:lsb][:release] = "5.7"
|
110
|
-
@plugin.run
|
111
|
-
expect(@plugin[:platform]).to eq("redhat")
|
112
|
-
expect(@plugin[:platform_family]).to eq("rhel")
|
113
|
-
end
|
114
|
-
|
115
|
-
it "should set platform to amazon and platform_family to rhel when [:lsb][:id] contains Amazon" do
|
116
|
-
@plugin[:lsb][:id] = "AmazonAMI"
|
117
|
-
@plugin[:lsb][:release] = "2011.09"
|
118
|
-
@plugin.run
|
119
|
-
expect(@plugin[:platform]).to eq("amazon")
|
120
|
-
expect(@plugin[:platform_family]).to eq("amazon")
|
24
|
+
describe "#read_os_release_info" do
|
25
|
+
let(:file_contents) { "COW=MOO\nDOG=\"BARK\"" }
|
26
|
+
it "returns nil if the file does not exist" do
|
27
|
+
allow(File).to receive(:exist?).with("/etc/test-release").and_return(false)
|
28
|
+
expect(plugin.read_os_release_info("/etc/test-release")).to be nil
|
121
29
|
end
|
122
30
|
|
123
|
-
it "
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
expect(@plugin[:platform]).to eq("scientific")
|
128
|
-
end
|
31
|
+
it "returns a hash of expected contents" do
|
32
|
+
allow(File).to receive(:exist?).with("/etc/test-release").and_return(true)
|
33
|
+
allow(File).to receive(:read).with("/etc/test-release").and_return(file_contents)
|
34
|
+
release_info = plugin.read_os_release_info("/etc/test-release")
|
129
35
|
|
130
|
-
|
131
|
-
|
132
|
-
@plugin[:lsb][:release] = "2.1"
|
133
|
-
@plugin.run
|
134
|
-
expect(@plugin[:platform]).to eq("ibm_powerkvm")
|
135
|
-
expect(@plugin[:platform_family]).to eq("rhel")
|
36
|
+
expect(release_info["COW"]).to eq("MOO")
|
37
|
+
expect(release_info["DOG"]).to eq("BARK")
|
136
38
|
end
|
137
39
|
end
|
138
40
|
|
139
|
-
describe "
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
before(:each) do
|
144
|
-
@plugin.lsb = nil
|
145
|
-
end
|
146
|
-
|
147
|
-
it "should read the version from /etc/debian_version" do
|
148
|
-
expect(File).to receive(:read).with("/etc/debian_version").and_return("5.0")
|
149
|
-
@plugin.run
|
150
|
-
expect(@plugin[:platform_version]).to eq("5.0")
|
151
|
-
end
|
152
|
-
|
153
|
-
it "should correctly strip any newlines" do
|
154
|
-
expect(File).to receive(:read).with("/etc/debian_version").and_return("5.0\n")
|
155
|
-
@plugin.run
|
156
|
-
expect(@plugin[:platform_version]).to eq("5.0")
|
157
|
-
end
|
158
|
-
|
159
|
-
# Ubuntu has /etc/debian_version as well
|
160
|
-
it "should detect Ubuntu as itself rather than debian" do
|
161
|
-
@plugin[:lsb][:id] = "Ubuntu"
|
162
|
-
@plugin[:lsb][:release] = "8.04"
|
163
|
-
@plugin.run
|
164
|
-
expect(@plugin[:platform]).to eq("ubuntu")
|
165
|
-
end
|
41
|
+
describe "#os_release_info" do
|
42
|
+
context "when CISCO_RELEASE_INFO is not populated" do
|
43
|
+
let(:release_info) { { "ID" => "os_id" } }
|
166
44
|
|
167
|
-
|
45
|
+
before do
|
46
|
+
allow(File).to receive(:exist?).with("/etc/os-release").and_return(true)
|
47
|
+
allow(plugin).to receive(:read_os_release_info).with("/etc/os-release").and_return(release_info)
|
48
|
+
end
|
168
49
|
|
169
|
-
|
50
|
+
it "reads the os-release file" do
|
51
|
+
expect(plugin).to receive(:read_os_release_info).with("/etc/os-release").and_return(release_info)
|
52
|
+
plugin.os_release_info
|
53
|
+
end
|
170
54
|
|
171
|
-
|
172
|
-
|
173
|
-
expect(File).to receive(:read).with("/etc/debian_version").and_return("wheezy/sid")
|
174
|
-
@plugin.run
|
175
|
-
expect(@plugin[:platform]).to eq("raspbian")
|
176
|
-
expect(@plugin[:platform_family]).to eq("debian")
|
55
|
+
it "returns a hash of expected contents" do
|
56
|
+
expect(plugin.os_release_info["ID"]).to eq("os_id")
|
177
57
|
end
|
178
58
|
end
|
179
59
|
|
180
|
-
context "
|
181
|
-
|
182
|
-
let(:
|
183
|
-
let(:cumulus_release_content) do
|
184
|
-
<<~OS_RELEASE
|
185
|
-
NAME="Cumulus Linux"
|
186
|
-
VERSION_ID=3.1.2
|
187
|
-
VERSION="Cumulus Linux 3.1.2"
|
188
|
-
PRETTY_NAME="Cumulus Linux"
|
189
|
-
ID=cumulus-linux
|
190
|
-
ID_LIKE=debian
|
191
|
-
CPE_NAME=cpe:/o:cumulusnetworks:cumulus_linux:3.1.2
|
192
|
-
HOME_URL="http://www.cumulusnetworks.com/"
|
193
|
-
SUPPORT_URL="http://support.cumulusnetworks.com/"
|
194
|
-
|
195
|
-
OS_RELEASE
|
196
|
-
end
|
60
|
+
context "when CISCO_RELEASE_INFO is populated" do
|
61
|
+
let(:release_info) { { "ID" => "os_id", "CISCO_RELEASE_INFO" => "/etc/cisco-release" } }
|
62
|
+
let(:cisco_release_info) { { "ID" => "cisco_id" } }
|
197
63
|
|
198
|
-
before
|
199
|
-
|
64
|
+
before do
|
65
|
+
allow(File).to receive(:exist?).with("/etc/os-release").and_return(true)
|
66
|
+
allow(File).to receive(:exist?).with("/etc/cisco-release").and_return(true)
|
67
|
+
allow(plugin).to receive(:read_os_release_info).with("/etc/os-release").and_return(release_info)
|
68
|
+
allow(plugin).to receive(:read_os_release_info).with("/etc/cisco-release").and_return(cisco_release_info)
|
200
69
|
end
|
201
70
|
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
expect(@plugin[:platform_family]).to eq("debian")
|
71
|
+
it "reads the os-release AND the cisco-release file" do
|
72
|
+
expect(plugin).to receive(:read_os_release_info).with("/etc/os-release").and_return(release_info)
|
73
|
+
expect(plugin).to receive(:read_os_release_info).with("/etc/cisco-release").and_return(release_info)
|
74
|
+
plugin.os_release_info
|
207
75
|
end
|
208
76
|
|
209
|
-
it "
|
210
|
-
|
211
|
-
expect(@plugin[:platform_version]).to eq("3.1.2")
|
77
|
+
it "returns the ID from the cisco-release file instead of the os-release file" do
|
78
|
+
expect(plugin.os_release_info["ID"]).to eq("cisco_id")
|
212
79
|
end
|
213
80
|
end
|
214
81
|
end
|
215
82
|
|
216
|
-
describe "
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
before(:each) do
|
221
|
-
@plugin.lsb = nil
|
83
|
+
describe "#platform_id_remap" do
|
84
|
+
# https://github.com/chef/os_release/blob/master/redhat_7
|
85
|
+
it "returns redhat for rhel os-release id" do
|
86
|
+
expect(plugin.platform_id_remap("rhel")).to eq("redhat")
|
222
87
|
end
|
223
88
|
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
expect(@plugin[:platform]).to eq("slackware")
|
228
|
-
expect(@plugin[:platform_family]).to eq("slackware")
|
89
|
+
# https://github.com/chef/os_release/blob/master/amazon_2018
|
90
|
+
it "returns amazon for amzn os-release id" do
|
91
|
+
expect(plugin.platform_id_remap("amzn")).to eq("amazon")
|
229
92
|
end
|
230
93
|
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
expect(@plugin[:platform_version]).to eq("12.0.0")
|
94
|
+
# https://github.com/chef/os_release/blob/master/oracle_7
|
95
|
+
it "returns oracle for ol os-release id" do
|
96
|
+
expect(plugin.platform_id_remap("ol")).to eq("oracle")
|
235
97
|
end
|
236
|
-
end
|
237
|
-
|
238
|
-
describe "on arch" do
|
239
|
-
|
240
|
-
let(:have_arch_release) { true }
|
241
98
|
|
242
|
-
|
243
|
-
|
99
|
+
# https://github.com/chef/os_release/blob/master/sles_sap_12_3
|
100
|
+
it "returns suse for sles_sap os-release id" do
|
101
|
+
expect(plugin.platform_id_remap("sles_sap")).to eq("suse")
|
244
102
|
end
|
245
103
|
|
246
|
-
|
247
|
-
|
248
|
-
expect(
|
249
|
-
expect(@plugin[:platform_family]).to eq("arch")
|
104
|
+
# https://github.com/chef/os_release/blob/master/sles_15_0
|
105
|
+
it "returns suse for sles os-release id" do
|
106
|
+
expect(plugin.platform_id_remap("sles")).to eq("suse")
|
250
107
|
end
|
251
108
|
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
expect(@plugin[:platform_version]).to eq("3.18.2-2-ARCH")
|
109
|
+
# https://github.com/chef/os_release/blob/master/opensuseleap_15_0
|
110
|
+
it "returns opensuseleap for opensuse-leap os-release id" do
|
111
|
+
expect(plugin.platform_id_remap("opensuse-leap")).to eq("opensuseleap")
|
256
112
|
end
|
257
|
-
end
|
258
113
|
|
259
|
-
|
260
|
-
|
261
|
-
|
114
|
+
# https://github.com/chef/os_release/blob/master/xenserver_7_6
|
115
|
+
it "returns xenserver for xenenterprise os-release id" do
|
116
|
+
expect(plugin.platform_id_remap("xenenterprise")).to eq("xenserver")
|
117
|
+
end
|
262
118
|
|
263
|
-
|
264
|
-
|
119
|
+
# https://github.com/chef/os_release/blob/master/cumulus_3_7
|
120
|
+
it "returns cumulus for cumulus-linux os-release id" do
|
121
|
+
expect(plugin.platform_id_remap("cumulus-linux")).to eq("cumulus")
|
265
122
|
end
|
266
123
|
|
267
|
-
it "
|
268
|
-
|
269
|
-
expect(@plugin[:platform]).to eq("gentoo")
|
270
|
-
expect(@plugin[:platform_family]).to eq("gentoo")
|
124
|
+
it "does not transformation for any other platform" do
|
125
|
+
expect(plugin.platform_id_remap("ubuntu")).to eq("ubuntu")
|
271
126
|
end
|
272
127
|
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
128
|
+
context "on a centos subshell on a nexus switch" do
|
129
|
+
let(:os_release_content) do
|
130
|
+
<<~OS_RELEASE
|
131
|
+
NAME="CentOS Linux"
|
132
|
+
VERSION="7 (Core)"
|
133
|
+
ID="centos"
|
134
|
+
ID_LIKE="rhel fedora"
|
135
|
+
VERSION_ID="7"
|
136
|
+
PRETTY_NAME="CentOS Linux 7 (Core)"
|
137
|
+
|
138
|
+
CISCO_RELEASE_INFO=/etc/shared/os-release
|
139
|
+
OS_RELEASE
|
140
|
+
end
|
141
|
+
|
142
|
+
let(:cisco_release_content) do
|
143
|
+
<<~CISCO_RELEASE
|
144
|
+
ID=nexus
|
145
|
+
ID_LIKE=wrlinux
|
146
|
+
NAME=Nexus
|
147
|
+
VERSION="7.0(3)I2(0.475E.6)"
|
148
|
+
VERSION_ID="7.0(3)I2"
|
149
|
+
PRETTY_NAME="Nexus 7.0(3)I2"
|
150
|
+
HOME_URL=http://www.cisco.com
|
151
|
+
BUILD_ID=6
|
152
|
+
CISCO_RELEASE_INFO=/etc/shared/os-release
|
153
|
+
CISCO_RELEASE
|
154
|
+
end
|
155
|
+
|
156
|
+
it "returns nexus_centos for centos os-release id" do
|
157
|
+
expect(File).to receive(:exist?).at_least(:once).with("/etc/shared/os-release").and_return(true)
|
158
|
+
expect(File).to receive(:exist?).at_least(:once).with("/etc/os-release").and_return(true)
|
159
|
+
expect(File).to receive(:read).with("/etc/os-release").and_return(os_release_content)
|
160
|
+
expect(File).to receive(:read).with("/etc/shared/os-release").and_return(cisco_release_content)
|
161
|
+
expect(plugin.platform_id_remap("centos")).to eq("nexus_centos")
|
162
|
+
end
|
277
163
|
end
|
278
164
|
end
|
279
165
|
|
280
|
-
describe "
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
@plugin.lsb = nil
|
166
|
+
describe "#platform_family_from_platform" do
|
167
|
+
%w{oracle centos redhat scientific enterpriseenterprise xenserver cloudlinux ibm_powerkvm parallels nexus_centos clearos bigip}.each do |p|
|
168
|
+
it "returns rhel for #{p} platform" do
|
169
|
+
expect(plugin.platform_family_from_platform(p)).to eq("rhel")
|
170
|
+
end
|
286
171
|
end
|
287
172
|
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
expect(@plugin[:platform_family]).to eq("alpine")
|
293
|
-
expect(@plugin[:platform_version]).to eq("3.2.3")
|
173
|
+
%w{suse sles opensuse opensuseleap sled}.each do |p|
|
174
|
+
it "returns suse for #{p} platform_family" do
|
175
|
+
expect(plugin.platform_family_from_platform(p)).to eq("suse")
|
176
|
+
end
|
294
177
|
end
|
295
|
-
end
|
296
|
-
|
297
|
-
describe "on arista eos" do
|
298
178
|
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
before(:each) do
|
304
|
-
@plugin.lsb = nil
|
179
|
+
%w{fedora pidora arista_eos}.each do |p|
|
180
|
+
it "returns fedora for #{p} platform_family" do
|
181
|
+
expect(plugin.platform_family_from_platform(p)).to eq("fedora")
|
182
|
+
end
|
305
183
|
end
|
306
184
|
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
expect(@plugin[:platform_family]).to eq("fedora")
|
312
|
-
expect(@plugin[:platform_version]).to eq("4.21.1.1F")
|
185
|
+
%w{nexus ios_xr}.each do |p|
|
186
|
+
it "returns wrlinux for #{p} platform_family" do
|
187
|
+
expect(plugin.platform_family_from_platform(p)).to eq("wrlinux")
|
188
|
+
end
|
313
189
|
end
|
314
|
-
end
|
315
|
-
|
316
|
-
describe "on f5 big-ip" do
|
317
190
|
|
318
|
-
|
191
|
+
%w{arch manjaro antergos}.each do |p|
|
192
|
+
it "returns arch for #{p} platform_family" do
|
193
|
+
expect(plugin.platform_family_from_platform(p)).to eq("arch")
|
194
|
+
end
|
195
|
+
end
|
319
196
|
|
320
|
-
|
321
|
-
|
197
|
+
%w{amazon slackware gentoo exherbo alpine clearlinux}.each do |same_name|
|
198
|
+
it "returns #{same_name} for #{same_name} platform_family" do
|
199
|
+
expect(plugin.platform_family_from_platform(same_name)).to eq(same_name)
|
200
|
+
end
|
322
201
|
end
|
323
202
|
|
324
|
-
it "
|
325
|
-
expect(
|
326
|
-
@plugin.run
|
327
|
-
expect(@plugin[:platform]).to eq("bigip")
|
328
|
-
expect(@plugin[:platform_family]).to eq("rhel")
|
329
|
-
expect(@plugin[:platform_version]).to eq("13.0.0")
|
203
|
+
it "returns mandriva for mangeia platform" do
|
204
|
+
expect(plugin.platform_family_from_platform("mangeia")).to eq("mandriva")
|
330
205
|
end
|
331
206
|
end
|
332
207
|
|
333
|
-
describe "on
|
334
|
-
|
335
|
-
let(:have_exherbo_release) { true }
|
336
|
-
|
208
|
+
describe "on system with /etc/os-release" do
|
337
209
|
before(:each) do
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
it "should set platform and platform_family to exherbo" do
|
342
|
-
@plugin.run
|
343
|
-
expect(@plugin[:platform]).to eq("exherbo")
|
344
|
-
expect(@plugin[:platform_family]).to eq("exherbo")
|
210
|
+
allow(plugin).to receive(:collect_os).and_return(:linux)
|
211
|
+
allow(::File).to receive(:exist?).with("/etc/os-release").and_return(true)
|
345
212
|
end
|
346
213
|
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
214
|
+
context "when os-release data is correct" do
|
215
|
+
let(:os_data) do
|
216
|
+
<<~OS_DATA
|
217
|
+
NAME="Ubuntu"
|
218
|
+
VERSION="14.04.5 LTS, Trusty Tahr"
|
219
|
+
ID=ubuntu
|
220
|
+
ID_LIKE=debian
|
221
|
+
PRETTY_NAME="Ubuntu 14.04.5 LTS"
|
222
|
+
VERSION_ID="14.04"
|
223
|
+
OS_DATA
|
224
|
+
end
|
352
225
|
|
353
|
-
|
226
|
+
before(:each) do
|
227
|
+
expect(File).to receive(:read).with("/etc/os-release").and_return(os_data)
|
228
|
+
end
|
354
229
|
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
@plugin.run
|
361
|
-
expect(@plugin[:platform]).to eq("redhat")
|
362
|
-
expect(@plugin[:platform_version]).to eq("6.1")
|
363
|
-
expect(@plugin[:platform_family]).to eq("rhel")
|
230
|
+
it "should set platform, platform_family, and platform_version from os-release" do
|
231
|
+
plugin.run
|
232
|
+
expect(plugin[:platform]).to eq("ubuntu")
|
233
|
+
expect(plugin[:platform_family]).to eq("debian")
|
234
|
+
expect(plugin[:platform_version]).to eq("14.04")
|
364
235
|
end
|
236
|
+
end
|
365
237
|
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
238
|
+
context "when os-release data is missing a version_id" do
|
239
|
+
let(:os_data) do
|
240
|
+
<<~OS_DATA
|
241
|
+
NAME="Arch Linux"
|
242
|
+
PRETTY_NAME="Arch Linux"
|
243
|
+
ID=arch
|
244
|
+
ID_LIKE=archlinux
|
245
|
+
OS_DATA
|
373
246
|
end
|
374
247
|
|
375
|
-
|
376
|
-
|
377
|
-
@plugin.run
|
378
|
-
expect(@plugin[:platform_family]).to eq("rhel")
|
248
|
+
before(:each) do
|
249
|
+
expect(File).to receive(:read).with("/etc/os-release").and_return(os_data)
|
379
250
|
end
|
380
251
|
|
381
|
-
it "should set
|
382
|
-
|
383
|
-
|
384
|
-
expect(
|
252
|
+
it "should set platform_version using kernel version from uname" do
|
253
|
+
allow(plugin).to receive(:shell_out).with("/bin/uname -r").and_return(mock_shell_out(0, "3.18.2-2-ARCH\n", ""))
|
254
|
+
plugin.run
|
255
|
+
expect(plugin[:platform]).to eq("arch")
|
256
|
+
expect(plugin[:platform_family]).to eq("arch")
|
257
|
+
expect(plugin[:platform_version]).to eq("3.18.2-2-ARCH")
|
385
258
|
end
|
259
|
+
end
|
386
260
|
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
261
|
+
context "when platform requires remapping" do
|
262
|
+
let(:os_data) do
|
263
|
+
<<~OS_DATA
|
264
|
+
NAME="openSUSE Leap"
|
265
|
+
VERSION="15.0"
|
266
|
+
ID="opensuse-leap"
|
267
|
+
ID_LIKE="suse opensuse"
|
268
|
+
VERSION_ID="15.0"
|
269
|
+
PRETTY_NAME="openSUSE Leap 15.0"
|
270
|
+
OS_DATA
|
391
271
|
end
|
392
272
|
|
393
|
-
|
394
|
-
|
395
|
-
@plugin.run
|
396
|
-
expect(@plugin[:platform_family]).to eq("rhel")
|
273
|
+
before(:each) do
|
274
|
+
expect(File).to receive(:read).with("/etc/os-release").and_return(os_data)
|
397
275
|
end
|
398
276
|
|
399
|
-
it "should set
|
400
|
-
|
401
|
-
|
402
|
-
expect(
|
277
|
+
it "should set platform, platform_family, and platform_version from os-release" do
|
278
|
+
plugin.run
|
279
|
+
expect(plugin[:platform]).to eq("opensuseleap")
|
280
|
+
expect(plugin[:platform_family]).to eq("suse")
|
281
|
+
expect(plugin[:platform_version]).to eq("15.0")
|
403
282
|
end
|
404
283
|
end
|
405
284
|
|
406
|
-
|
407
|
-
|
408
|
-
|
285
|
+
context "when on centos where version data in os-release is wrong" do
|
286
|
+
let(:os_data) do
|
287
|
+
<<~OS_DATA
|
288
|
+
NAME="CentOS Linux"
|
289
|
+
VERSION="7 (Core)"
|
290
|
+
ID="centos"
|
291
|
+
ID_LIKE="rhel fedora"
|
292
|
+
VERSION_ID="7"
|
293
|
+
PRETTY_NAME="CentOS Linux 7 (Core)"
|
294
|
+
OS_DATA
|
295
|
+
end
|
409
296
|
|
410
297
|
before(:each) do
|
411
|
-
|
298
|
+
expect(File).to receive(:read).with("/etc/os-release").and_return(os_data)
|
299
|
+
expect(File).to receive(:read).with("/etc/redhat-release").and_return("CentOS Linux release 7.5.1804 (Core)")
|
412
300
|
end
|
413
301
|
|
414
|
-
it "should
|
415
|
-
|
416
|
-
|
417
|
-
expect(
|
302
|
+
it "should set platform, platform_family, and platform_version from os-release" do
|
303
|
+
plugin.run
|
304
|
+
expect(plugin[:platform]).to eq("centos")
|
305
|
+
expect(plugin[:platform_family]).to eq("rhel")
|
306
|
+
expect(plugin[:platform_version]).to eq("7.5.1804")
|
418
307
|
end
|
308
|
+
end
|
309
|
+
end
|
419
310
|
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
311
|
+
context "on system without /etc/os-release (legacy)" do
|
312
|
+
let(:have_debian_version) { false }
|
313
|
+
let(:have_redhat_release) { false }
|
314
|
+
let(:have_exherbo_release) { false }
|
315
|
+
let(:have_eos_release) { false }
|
316
|
+
let(:have_suse_release) { false }
|
317
|
+
let(:have_system_release) { false }
|
318
|
+
let(:have_slackware_version) { false }
|
319
|
+
let(:have_enterprise_release) { false }
|
320
|
+
let(:have_oracle_release) { false }
|
321
|
+
let(:have_parallels_release) { false }
|
322
|
+
let(:have_os_release) { false }
|
323
|
+
let(:have_os_release) { false }
|
324
|
+
let(:have_usr_lib_os_release) { false }
|
325
|
+
let(:have_cisco_release) { false }
|
326
|
+
let(:have_f5_release) { false }
|
426
327
|
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
328
|
+
before(:each) do
|
329
|
+
allow(plugin).to receive(:collect_os).and_return(:linux)
|
330
|
+
plugin[:lsb] = Mash.new
|
331
|
+
allow(File).to receive(:exist?).with("/etc/debian_version").and_return(have_debian_version)
|
332
|
+
allow(File).to receive(:exist?).with("/etc/redhat-release").and_return(have_redhat_release)
|
333
|
+
allow(File).to receive(:exist?).with("/etc/exherbo-release").and_return(have_exherbo_release)
|
334
|
+
allow(File).to receive(:exist?).with("/etc/Eos-release").and_return(have_eos_release)
|
335
|
+
allow(File).to receive(:exist?).with("/etc/SuSE-release").and_return(have_suse_release)
|
336
|
+
allow(File).to receive(:exist?).with("/etc/system-release").and_return(have_system_release)
|
337
|
+
allow(File).to receive(:exist?).with("/etc/slackware-version").and_return(have_slackware_version)
|
338
|
+
allow(File).to receive(:exist?).with("/etc/enterprise-release").and_return(have_enterprise_release)
|
339
|
+
allow(File).to receive(:exist?).with("/etc/oracle-release").and_return(have_oracle_release)
|
340
|
+
allow(File).to receive(:exist?).with("/etc/parallels-release").and_return(have_parallels_release)
|
341
|
+
allow(File).to receive(:exist?).with("/etc/os-release").and_return(have_os_release)
|
342
|
+
allow(File).to receive(:exist?).with("/etc/f5-release").and_return(have_f5_release)
|
343
|
+
allow(File).to receive(:exist?).with("/usr/lib/os-release").and_return(have_usr_lib_os_release)
|
344
|
+
allow(File).to receive(:exist?).with("/etc/shared/os-release").and_return(have_cisco_release)
|
345
|
+
|
346
|
+
allow(File).to receive(:read).with("PLEASE STUB ALL File.read CALLS")
|
347
|
+
end
|
348
|
+
|
349
|
+
describe "on lsb compliant distributions" do
|
350
|
+
before(:each) do
|
351
|
+
plugin[:lsb][:id] = "Ubuntu"
|
352
|
+
plugin[:lsb][:release] = "18.04"
|
432
353
|
end
|
433
354
|
|
434
|
-
it "should
|
435
|
-
|
436
|
-
|
437
|
-
expect(@plugin[:platform]).to eq("fedora")
|
438
|
-
expect(@plugin[:platform_version]).to eq("13 (rawhide)")
|
355
|
+
it "should set platform to lowercased lsb[:id]" do
|
356
|
+
plugin.run
|
357
|
+
expect(plugin[:platform]).to eq("ubuntu")
|
439
358
|
end
|
440
359
|
|
441
|
-
it "should
|
442
|
-
|
443
|
-
|
444
|
-
expect(@plugin[:platform]).to eq("fedora")
|
445
|
-
expect(@plugin[:platform_version]).to eq("10")
|
360
|
+
it "should set platform_version to lsb[:release]" do
|
361
|
+
plugin.run
|
362
|
+
expect(plugin[:platform_version]).to eq("18.04")
|
446
363
|
end
|
447
364
|
|
448
|
-
it "should
|
449
|
-
|
450
|
-
|
451
|
-
expect(
|
452
|
-
expect(
|
365
|
+
it "should set platform to ubuntu and platform_family to debian [:lsb][:id] contains Ubuntu" do
|
366
|
+
plugin[:lsb][:id] = "Ubuntu"
|
367
|
+
plugin.run
|
368
|
+
expect(plugin[:platform]).to eq("ubuntu")
|
369
|
+
expect(plugin[:platform_family]).to eq("debian")
|
453
370
|
end
|
454
371
|
|
455
|
-
it "should
|
456
|
-
|
457
|
-
|
458
|
-
expect(
|
459
|
-
expect(
|
460
|
-
expect(@plugin[:platform_version].to_f).to eq(7.3)
|
372
|
+
it "should set platform to debian and platform_family to debian [:lsb][:id] contains Debian" do
|
373
|
+
plugin[:lsb][:id] = "Debian"
|
374
|
+
plugin.run
|
375
|
+
expect(plugin[:platform]).to eq("debian")
|
376
|
+
expect(plugin[:platform_family]).to eq("debian")
|
461
377
|
end
|
462
378
|
|
463
|
-
it "should
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
expect(
|
468
|
-
expect(
|
379
|
+
it "should set platform to redhat and platform_family to rhel when [:lsb][:id] contains Redhat" do
|
380
|
+
plugin[:lsb][:id] = "RedHatEnterpriseServer"
|
381
|
+
plugin[:lsb][:release] = "7.5"
|
382
|
+
plugin.run
|
383
|
+
expect(plugin[:platform]).to eq("redhat")
|
384
|
+
expect(plugin[:platform_family]).to eq("rhel")
|
469
385
|
end
|
470
386
|
|
471
|
-
it "should
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
expect(
|
476
|
-
expect(
|
387
|
+
it "should set platform to amazon and platform_family to rhel when [:lsb][:id] contains Amazon" do
|
388
|
+
plugin[:lsb][:id] = "AmazonAMI"
|
389
|
+
plugin[:lsb][:release] = "2018.03"
|
390
|
+
plugin.run
|
391
|
+
expect(plugin[:platform]).to eq("amazon")
|
392
|
+
expect(plugin[:platform_family]).to eq("amazon")
|
477
393
|
end
|
478
394
|
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
let(:os_release_content) do
|
486
|
-
<<~OS_RELEASE
|
487
|
-
NAME="CentOS Linux"
|
488
|
-
VERSION="7 (Core)"
|
489
|
-
ID="centos"
|
490
|
-
ID_LIKE="rhel fedora"
|
491
|
-
VERSION_ID="7"
|
492
|
-
PRETTY_NAME="CentOS Linux 7 (Core)"
|
493
|
-
ANSI_COLOR="0;31"
|
494
|
-
CPE_NAME="cpe:/o:centos:centos:7"
|
495
|
-
HOME_URL="https://www.centos.org/"
|
496
|
-
BUG_REPORT_URL="https://bugs.centos.org/"
|
497
|
-
|
498
|
-
OS_RELEASE
|
499
|
-
end
|
500
|
-
|
501
|
-
before do
|
502
|
-
expect(File).to receive(:read).with("/etc/redhat-release").and_return("CentOS release 7.1")
|
503
|
-
expect(File).to receive(:read).with("/etc/os-release").and_return(os_release_content)
|
504
|
-
end
|
505
|
-
|
506
|
-
it "correctly detects EL7" do
|
507
|
-
@plugin.run
|
508
|
-
expect(@plugin[:platform]).to eq("centos")
|
509
|
-
expect(@plugin[:platform_version]).to eq("7.1")
|
510
|
-
end
|
511
|
-
|
395
|
+
it "should set platform to scientific when [:lsb][:id] contains ScientificSL" do
|
396
|
+
plugin[:lsb][:id] = "ScientificSL"
|
397
|
+
plugin[:lsb][:release] = "7.5"
|
398
|
+
plugin.run
|
399
|
+
expect(plugin[:platform]).to eq("scientific")
|
512
400
|
end
|
513
401
|
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
NAME="CentOS Linux"
|
521
|
-
VERSION="7 (Core)"
|
522
|
-
ID="centos"
|
523
|
-
ID_LIKE="rhel fedora"
|
524
|
-
VERSION_ID="7"
|
525
|
-
PRETTY_NAME="CentOS Linux 7 (Core)"
|
526
|
-
ANSI_COLOR="0;31"
|
527
|
-
CPE_NAME="cpe:/o:centos:centos:7"
|
528
|
-
HOME_URL="https://www.centos.org/"
|
529
|
-
BUG_REPORT_URL="https://bugs.centos.org/"
|
530
|
-
|
531
|
-
CENTOS_MANTISBT_PROJECT="CentOS-7"
|
532
|
-
CENTOS_MANTISBT_PROJECT_VERSION="7"
|
533
|
-
REDHAT_SUPPORT_PRODUCT="centos"
|
534
|
-
REDHAT_SUPPORT_PRODUCT_VERSION="7"
|
535
|
-
|
536
|
-
CISCO_RELEASE_INFO=/etc/shared/os-release
|
537
|
-
OS_RELEASE
|
538
|
-
end
|
539
|
-
|
540
|
-
let(:have_cisco_release) { true }
|
541
|
-
|
542
|
-
let(:cisco_release_content) do
|
543
|
-
<<~CISCO_RELEASE
|
544
|
-
ID=nexus
|
545
|
-
ID_LIKE=wrlinux
|
546
|
-
NAME=Nexus
|
547
|
-
VERSION="7.0(3)I2(0.475E.6)"
|
548
|
-
VERSION_ID="7.0(3)I2"
|
549
|
-
PRETTY_NAME="Nexus 7.0(3)I2"
|
550
|
-
HOME_URL=http://www.cisco.com
|
551
|
-
BUILD_ID=6
|
552
|
-
CISCO_RELEASE_INFO=/etc/os-release
|
553
|
-
CISCO_RELEASE
|
554
|
-
end
|
555
|
-
|
556
|
-
before do
|
557
|
-
expect(File).to receive(:read).at_least(:once).with("/etc/os-release").and_return(os_release_content)
|
558
|
-
expect(File).to receive(:read).with("/etc/shared/os-release").and_return(cisco_release_content)
|
559
|
-
end
|
560
|
-
|
561
|
-
it "should set platform to nexus_guestshell and platform_family to rhel" do
|
562
|
-
@plugin.run
|
563
|
-
expect(@plugin[:platform]).to start_with("nexus")
|
564
|
-
expect(@plugin[:platform]).to eq("nexus_centos")
|
565
|
-
expect(@plugin[:platform_family]).to eq("rhel")
|
566
|
-
expect(@plugin[:platform_version]).to eq("7.0(3)I2(0.475E.6)")
|
567
|
-
end
|
402
|
+
it "should set platform to ibm_powerkvm and platform_family to rhel when [:lsb][:id] contains IBM_PowerKVM" do
|
403
|
+
plugin[:lsb][:id] = "IBM_PowerKVM"
|
404
|
+
plugin[:lsb][:release] = "2.1"
|
405
|
+
plugin.run
|
406
|
+
expect(plugin[:platform]).to eq("ibm_powerkvm")
|
407
|
+
expect(plugin[:platform_family]).to eq("rhel")
|
568
408
|
end
|
569
409
|
end
|
570
410
|
|
571
|
-
|
572
|
-
|
573
|
-
describe "on pcs linux" do
|
574
|
-
|
575
|
-
let(:have_redhat_release) { true }
|
576
|
-
let(:have_parallels_release) { true }
|
411
|
+
describe "on debian" do
|
577
412
|
|
578
|
-
|
413
|
+
let(:have_debian_version) { true }
|
579
414
|
|
580
|
-
|
581
|
-
|
582
|
-
@plugin[:lsb][:release] = "6.5"
|
583
|
-
allow(File).to receive(:read).with("/etc/redhat-release").and_return("CloudLinux Server release 6.5 (Pavel Popovich)")
|
584
|
-
expect(File).to receive(:read).with("/etc/parallels-release").and_return("Parallels Cloud Server 6.0.5 (20007)")
|
585
|
-
@plugin.run
|
586
|
-
expect(@plugin[:platform]).to eq("parallels")
|
587
|
-
expect(@plugin[:platform_version]).to eq("6.0.5")
|
588
|
-
expect(@plugin[:platform_family]).to eq("rhel")
|
415
|
+
before(:each) do
|
416
|
+
plugin.lsb = nil
|
589
417
|
end
|
590
|
-
end
|
591
418
|
|
592
|
-
|
419
|
+
it "should read the version from /etc/debian_version" do
|
420
|
+
expect(File).to receive(:read).with("/etc/debian_version").and_return("9.5")
|
421
|
+
plugin.run
|
422
|
+
expect(plugin[:platform_version]).to eq("9.5")
|
423
|
+
end
|
593
424
|
|
594
|
-
|
595
|
-
|
425
|
+
it "should correctly strip any newlines" do
|
426
|
+
expect(File).to receive(:read).with("/etc/debian_version").and_return("9.5\n")
|
427
|
+
plugin.run
|
428
|
+
expect(plugin[:platform_version]).to eq("9.5")
|
596
429
|
end
|
597
430
|
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
expect(
|
604
|
-
expect(@plugin[:platform_family]).to eq("rhel")
|
431
|
+
# Ubuntu has /etc/debian_version as well
|
432
|
+
it "should detect Ubuntu as itself rather than debian" do
|
433
|
+
plugin[:lsb][:id] = "Ubuntu"
|
434
|
+
plugin[:lsb][:release] = "18.04"
|
435
|
+
plugin.run
|
436
|
+
expect(plugin[:platform]).to eq("ubuntu")
|
605
437
|
end
|
606
438
|
end
|
607
|
-
end
|
608
|
-
|
609
|
-
describe "on oracle enterprise linux" do
|
610
|
-
|
611
|
-
let(:have_redhat_release) { true }
|
612
439
|
|
613
|
-
|
440
|
+
describe "on slackware" do
|
614
441
|
|
615
|
-
|
442
|
+
let(:have_slackware_version) { true }
|
616
443
|
|
617
|
-
|
618
|
-
|
619
|
-
it "should read the platform as oracle and version as 5.7" do
|
620
|
-
@plugin[:lsb][:id] = "EnterpriseEnterpriseServer"
|
621
|
-
@plugin[:lsb][:release] = "5.7"
|
622
|
-
allow(File).to receive(:read).with("/etc/redhat-release").and_return("Red Hat Enterprise Linux Server release 5.7 (Tikanga)")
|
623
|
-
expect(File).to receive(:read).with("/etc/enterprise-release").and_return("Enterprise Linux Enterprise Linux Server release 5.7 (Carthage)")
|
624
|
-
@plugin.run
|
625
|
-
expect(@plugin[:platform]).to eq("oracle")
|
626
|
-
expect(@plugin[:platform_version]).to eq("5.7")
|
627
|
-
end
|
444
|
+
before(:each) do
|
445
|
+
plugin.lsb = nil
|
628
446
|
end
|
629
447
|
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
@plugin[:lsb][:id] = "OracleServer"
|
636
|
-
@plugin[:lsb][:release] = "6.1"
|
637
|
-
allow(File).to receive(:read).with("/etc/redhat-release").and_return("Red Hat Enterprise Linux Server release 6.1 (Santiago)")
|
638
|
-
expect(File).to receive(:read).with("/etc/oracle-release").and_return("Oracle Linux Server release 6.1")
|
639
|
-
@plugin.run
|
640
|
-
expect(@plugin[:platform]).to eq("oracle")
|
641
|
-
expect(@plugin[:platform_version]).to eq("6.1")
|
642
|
-
end
|
643
|
-
|
448
|
+
it "should set platform and platform_family to slackware" do
|
449
|
+
expect(File).to receive(:read).with("/etc/slackware-version").and_return("Slackware 12.0.0")
|
450
|
+
plugin.run
|
451
|
+
expect(plugin[:platform]).to eq("slackware")
|
452
|
+
expect(plugin[:platform_family]).to eq("slackware")
|
644
453
|
end
|
645
|
-
end
|
646
454
|
|
647
|
-
|
648
|
-
|
649
|
-
|
455
|
+
it "should set platform_version on slackware" do
|
456
|
+
expect(File).to receive(:read).with("/etc/slackware-version").and_return("Slackware 12.0.0")
|
457
|
+
plugin.run
|
458
|
+
expect(plugin[:platform_version]).to eq("12.0.0")
|
650
459
|
end
|
460
|
+
end
|
651
461
|
|
652
|
-
|
653
|
-
|
654
|
-
let(:have_enterprise_release) { true }
|
655
|
-
|
656
|
-
it "should read the platform as oracle and version as 5" do
|
657
|
-
allow(File).to receive(:read).with("/etc/redhat-release").and_return("Enterprise Linux Enterprise Linux Server release 5 (Carthage)")
|
658
|
-
expect(File).to receive(:read).with("/etc/enterprise-release").and_return("Enterprise Linux Enterprise Linux Server release 5 (Carthage)")
|
659
|
-
@plugin.run
|
660
|
-
expect(@plugin[:platform]).to eq("oracle")
|
661
|
-
expect(@plugin[:platform_version]).to eq("5")
|
662
|
-
end
|
663
|
-
|
664
|
-
it "should read the platform as oracle and version as 5.1" do
|
665
|
-
allow(File).to receive(:read).with("/etc/redhat-release").and_return("Enterprise Linux Enterprise Linux Server release 5.1 (Carthage)")
|
666
|
-
expect(File).to receive(:read).with("/etc/enterprise-release").and_return("Enterprise Linux Enterprise Linux Server release 5.1 (Carthage)")
|
667
|
-
@plugin.run
|
668
|
-
expect(@plugin[:platform]).to eq("oracle")
|
669
|
-
expect(@plugin[:platform_version]).to eq("5.1")
|
670
|
-
end
|
462
|
+
describe "on arista eos" do
|
671
463
|
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
@plugin.run
|
676
|
-
expect(@plugin[:platform]).to eq("oracle")
|
677
|
-
expect(@plugin[:platform_version]).to eq("5.7")
|
678
|
-
end
|
464
|
+
let(:have_system_release) { true }
|
465
|
+
let(:have_redhat_release) { true }
|
466
|
+
let(:have_eos_release) { true }
|
679
467
|
|
468
|
+
before(:each) do
|
469
|
+
plugin.lsb = nil
|
680
470
|
end
|
681
471
|
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
expect(File).to receive(:read).with("/etc/oracle-release").and_return("Oracle Linux Server release 6.0")
|
689
|
-
@plugin.run
|
690
|
-
expect(@plugin[:platform]).to eq("oracle")
|
691
|
-
expect(@plugin[:platform_version]).to eq("6.0")
|
692
|
-
end
|
693
|
-
|
694
|
-
it "should read the platform as oracle and version as 6.1" do
|
695
|
-
allow(File).to receive(:read).with("/etc/redhat-release").and_return("Red Hat Enterprise Linux Server release 6.1 (Santiago)")
|
696
|
-
expect(File).to receive(:read).with("/etc/oracle-release").and_return("Oracle Linux Server release 6.1")
|
697
|
-
@plugin.run
|
698
|
-
expect(@plugin[:platform]).to eq("oracle")
|
699
|
-
expect(@plugin[:platform_version]).to eq("6.1")
|
700
|
-
end
|
472
|
+
it "should set platform to arista_eos" do
|
473
|
+
expect(File).to receive(:read).with("/etc/Eos-release").and_return("Arista Networks EOS 4.21.1.1F")
|
474
|
+
plugin.run
|
475
|
+
expect(plugin[:platform]).to eq("arista_eos")
|
476
|
+
expect(plugin[:platform_family]).to eq("fedora")
|
477
|
+
expect(plugin[:platform_version]).to eq("4.21.1.1F")
|
701
478
|
end
|
702
479
|
end
|
703
|
-
end
|
704
480
|
|
705
|
-
|
706
|
-
context "on openSUSE 15+" do
|
481
|
+
describe "on f5 big-ip" do
|
707
482
|
|
708
|
-
let(:
|
709
|
-
let(:have_suse_release) { false }
|
710
|
-
let(:have_os_release) { true }
|
711
|
-
|
712
|
-
let(:os_release_content) do
|
713
|
-
<<~OS_RELEASE
|
714
|
-
NAME="openSUSE Leap"
|
715
|
-
VERSION="15.0"
|
716
|
-
ID="opensuse-leap"
|
717
|
-
ID_LIKE="suse opensuse"
|
718
|
-
VERSION_ID="15.0"
|
719
|
-
PRETTY_NAME="openSUSE Leap 15.0"
|
720
|
-
ANSI_COLOR="0;32"
|
721
|
-
CPE_NAME="cpe:/o:opensuse:leap:15.0"
|
722
|
-
OS_RELEASE
|
723
|
-
end
|
483
|
+
let(:have_f5_release) { true }
|
724
484
|
|
725
|
-
before do
|
726
|
-
|
727
|
-
expect(File).to receive(:read).with("/etc/os-release").and_return(os_release_content)
|
485
|
+
before(:each) do
|
486
|
+
plugin.lsb = nil
|
728
487
|
end
|
729
488
|
|
730
|
-
it "
|
731
|
-
|
732
|
-
|
733
|
-
expect(
|
734
|
-
expect(
|
489
|
+
it "should set platform to bigip" do
|
490
|
+
expect(File).to receive(:read).with("/etc/f5-release").and_return("BIG-IP release 13.0.0 (Final)")
|
491
|
+
plugin.run
|
492
|
+
expect(plugin[:platform]).to eq("bigip")
|
493
|
+
expect(plugin[:platform_family]).to eq("rhel")
|
494
|
+
expect(plugin[:platform_version]).to eq("13.0.0")
|
735
495
|
end
|
736
|
-
|
737
496
|
end
|
738
497
|
|
739
|
-
|
498
|
+
describe "on exherbo" do
|
740
499
|
|
741
|
-
let(:
|
742
|
-
let(:have_os_release) { true }
|
500
|
+
let(:have_exherbo_release) { true }
|
743
501
|
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
VERSION="15"
|
748
|
-
VERSION_ID="15"
|
749
|
-
PRETTY_NAME="SUSE Linux Enterprise Server 15"
|
750
|
-
ID="sles"
|
751
|
-
ID_LIKE="suse"
|
752
|
-
ANSI_COLOR="0;32"
|
753
|
-
CPE_NAME="cpe:/o:suse:sles:15"
|
754
|
-
|
755
|
-
OS_RELEASE
|
502
|
+
before(:each) do
|
503
|
+
allow(plugin).to receive(:shell_out).with("/bin/uname -r").and_return(mock_shell_out(0, "3.18.2-2-ARCH\n", ""))
|
504
|
+
plugin.lsb = nil
|
756
505
|
end
|
757
506
|
|
758
|
-
|
759
|
-
|
760
|
-
expect(
|
507
|
+
it "should set platform and platform_family to exherbo" do
|
508
|
+
plugin.run
|
509
|
+
expect(plugin[:platform]).to eq("exherbo")
|
510
|
+
expect(plugin[:platform_family]).to eq("exherbo")
|
761
511
|
end
|
762
512
|
|
763
|
-
it "
|
764
|
-
|
765
|
-
expect(
|
766
|
-
expect(@plugin[:platform_version]).to eq("15")
|
767
|
-
expect(@plugin[:platform_family]).to eq("suse")
|
513
|
+
it "should set platform_version to kernel release" do
|
514
|
+
plugin.run
|
515
|
+
expect(plugin[:platform_version]).to eq("3.18.2-2-ARCH")
|
768
516
|
end
|
769
|
-
end
|
770
|
-
|
771
|
-
context "on versions that have both /etc/os-release and /etc/SuSE-release (e.g. SLES12)" do
|
772
|
-
let(:have_suse_release) { true }
|
773
|
-
let(:have_os_release) { true }
|
774
|
-
|
775
|
-
describe "with lsb_release results" do
|
776
|
-
before(:each) do
|
777
|
-
@plugin[:lsb][:id] = "SUSE LINUX"
|
778
|
-
end
|
779
517
|
|
780
|
-
it "should read the platform as opensuse on openSUSE" do
|
781
|
-
@plugin[:lsb][:release] = "12.1"
|
782
|
-
expect(File).to receive(:read).with("/etc/SuSE-release").and_return("openSUSE 12.1 (x86_64)\nVERSION = 12.1\nCODENAME = Asparagus\n")
|
783
|
-
@plugin.run
|
784
|
-
expect(@plugin[:platform]).to eq("opensuse")
|
785
|
-
expect(@plugin[:platform_family]).to eq("suse")
|
786
|
-
end
|
787
|
-
end
|
788
518
|
end
|
789
519
|
|
790
|
-
|
791
|
-
let(:have_suse_release) { true }
|
792
|
-
let(:have_os_release) { false }
|
793
|
-
|
520
|
+
describe "on redhat breeds" do
|
794
521
|
describe "with lsb_release results" do
|
795
|
-
|
796
|
-
|
522
|
+
it "should set the platform to redhat and platform_family to rhel even if the LSB name is something absurd but redhat like" do
|
523
|
+
plugin[:lsb][:id] = "RedHatEnterpriseServer"
|
524
|
+
plugin[:lsb][:release] = "7.5"
|
525
|
+
plugin.run
|
526
|
+
expect(plugin[:platform]).to eq("redhat")
|
527
|
+
expect(plugin[:platform_version]).to eq("7.5")
|
528
|
+
expect(plugin[:platform_family]).to eq("rhel")
|
797
529
|
end
|
798
530
|
|
799
|
-
it "should
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
expect(
|
804
|
-
expect(
|
531
|
+
it "should set the platform to centos and platform_family to rhel" do
|
532
|
+
plugin[:lsb][:id] = "CentOS"
|
533
|
+
plugin[:lsb][:release] = "7.5"
|
534
|
+
plugin.run
|
535
|
+
expect(plugin[:platform]).to eq("centos")
|
536
|
+
expect(plugin[:platform_version]).to eq("7.5")
|
537
|
+
expect(plugin[:platform_family]).to eq("rhel")
|
805
538
|
end
|
806
539
|
end
|
807
|
-
end
|
808
|
-
|
809
|
-
context "on openSUSE and older SLES versions" do
|
810
|
-
let(:have_suse_release) { true }
|
811
|
-
let(:have_os_release) { true }
|
812
540
|
|
813
541
|
describe "without lsb_release results" do
|
542
|
+
|
543
|
+
let(:have_redhat_release) { true }
|
544
|
+
|
814
545
|
before(:each) do
|
815
|
-
|
546
|
+
plugin.lsb = nil
|
816
547
|
end
|
817
548
|
|
818
|
-
it "should
|
819
|
-
expect(File).to receive(:read).with("/etc/
|
820
|
-
|
821
|
-
expect(
|
822
|
-
expect(
|
549
|
+
it "should read the platform as centos and version as 7.5" do
|
550
|
+
expect(File).to receive(:read).with("/etc/redhat-release").and_return("CentOS Linux release 7.5.1804 (Core)")
|
551
|
+
plugin.run
|
552
|
+
expect(plugin[:platform]).to eq("centos")
|
553
|
+
expect(plugin[:platform_version]).to eq("7.5.1804")
|
823
554
|
end
|
824
555
|
|
825
|
-
it "
|
826
|
-
expect(File).to receive(:read).with("/etc/
|
827
|
-
|
828
|
-
expect(
|
829
|
-
expect(@plugin[:platform_version]).to eq("10.1")
|
830
|
-
expect(@plugin[:platform_family]).to eq("suse")
|
556
|
+
it "reads platform of Red Hat with a space" do
|
557
|
+
expect(File).to receive(:read).with("/etc/redhat-release").and_return("Red Hat Enterprise Linux Server release 6.5 (Santiago)")
|
558
|
+
plugin.run
|
559
|
+
expect(plugin[:platform]).to eq("redhat")
|
831
560
|
end
|
832
561
|
|
833
|
-
it "should read the
|
834
|
-
expect(File).to receive(:read).with("/etc/
|
835
|
-
|
836
|
-
expect(
|
837
|
-
expect(
|
838
|
-
expect(@plugin[:platform_family]).to eq("suse")
|
562
|
+
it "should read the platform as redhat without a space" do
|
563
|
+
expect(File).to receive(:read).with("/etc/redhat-release").and_return("RedHat release 5.3")
|
564
|
+
plugin.run
|
565
|
+
expect(plugin[:platform]).to eq("redhat")
|
566
|
+
expect(plugin[:platform_version]).to eq("5.3")
|
839
567
|
end
|
568
|
+
end
|
840
569
|
|
841
|
-
|
842
|
-
expect(File).to receive(:read).with("/etc/SuSE-release").exactly(1).times.and_return("openSUSE 11.3 (x86_64)\nVERSION = 11.3")
|
843
|
-
@plugin.run
|
844
|
-
expect(@plugin[:platform]).to eq("opensuse")
|
845
|
-
expect(@plugin[:platform_version]).to eq("11.3")
|
846
|
-
expect(@plugin[:platform_family]).to eq("suse")
|
847
|
-
end
|
570
|
+
end
|
848
571
|
|
849
|
-
|
850
|
-
expect(File).to receive(:read).with("/etc/SuSE-release").exactly(1).times.and_return("SuSE Linux 9.1 (i586)\nVERSION = 9.1")
|
851
|
-
@plugin.run
|
852
|
-
expect(@plugin[:platform]).to eq("suse")
|
853
|
-
expect(@plugin[:platform_version]).to eq("9.1")
|
854
|
-
expect(@plugin[:platform_family]).to eq("suse")
|
855
|
-
end
|
572
|
+
describe "on pcs linux" do
|
856
573
|
|
857
|
-
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
574
|
+
let(:have_redhat_release) { true }
|
575
|
+
let(:have_parallels_release) { true }
|
576
|
+
|
577
|
+
describe "with lsb_result" do
|
578
|
+
|
579
|
+
it "should read the platform as parallels and version as 6.0.5" do
|
580
|
+
plugin[:lsb][:id] = "CloudLinuxServer"
|
581
|
+
plugin[:lsb][:release] = "6.5"
|
582
|
+
allow(File).to receive(:read).with("/etc/redhat-release").and_return("CloudLinux Server release 6.5 (Pavel Popovich)")
|
583
|
+
expect(File).to receive(:read).with("/etc/parallels-release").and_return("Parallels Cloud Server 6.0.5 (20007)")
|
584
|
+
plugin.run
|
585
|
+
expect(plugin[:platform]).to eq("parallels")
|
586
|
+
expect(plugin[:platform_version]).to eq("6.0.5")
|
587
|
+
expect(plugin[:platform_family]).to eq("rhel")
|
863
588
|
end
|
589
|
+
end
|
590
|
+
|
591
|
+
describe "without lsb_results" do
|
864
592
|
|
865
|
-
|
866
|
-
|
867
|
-
@plugin.run
|
868
|
-
expect(@plugin[:platform]).to eq("opensuse")
|
869
|
-
expect(@plugin[:platform_family]).to eq("suse")
|
593
|
+
before(:each) do
|
594
|
+
plugin.lsb = nil
|
870
595
|
end
|
871
596
|
|
872
|
-
it "should read the platform as
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
expect(
|
597
|
+
it "should read the platform as parallels and version as 6.0.5" do
|
598
|
+
allow(File).to receive(:read).with("/etc/redhat-release").and_return("CloudLinux Server release 6.5 (Pavel Popovich)")
|
599
|
+
expect(File).to receive(:read).with("/etc/parallels-release").and_return("Parallels Cloud Server 6.0.5 (20007)")
|
600
|
+
plugin.run
|
601
|
+
expect(plugin[:platform]).to eq("parallels")
|
602
|
+
expect(plugin[:platform_version]).to eq("6.0.5")
|
603
|
+
expect(plugin[:platform_family]).to eq("rhel")
|
877
604
|
end
|
878
605
|
end
|
879
606
|
end
|
880
|
-
end
|
881
607
|
|
882
|
-
|
883
|
-
let(:file_contents) { "COW=MOO\nDOG=\"BARK\"" }
|
884
|
-
it "returns nil if the file does not exist" do
|
885
|
-
allow(File).to receive(:exist?).with("/etc/test-release").and_return(false)
|
886
|
-
expect(@plugin.read_os_release_info("/etc/test-release")).to be nil
|
887
|
-
end
|
608
|
+
describe "on oracle enterprise linux" do
|
888
609
|
|
889
|
-
|
890
|
-
allow(File).to receive(:exist?).with("/etc/test-release").and_return(true)
|
891
|
-
allow(File).to receive(:read).with("/etc/test-release").and_return(file_contents)
|
892
|
-
release_info = @plugin.read_os_release_info("/etc/test-release")
|
610
|
+
let(:have_redhat_release) { true }
|
893
611
|
|
894
|
-
|
895
|
-
expect(release_info["DOG"]).to eq("BARK")
|
896
|
-
end
|
897
|
-
end
|
612
|
+
context "with lsb_results" do
|
898
613
|
|
899
|
-
|
900
|
-
context "when CISCO_RELEASE_INFO is not populated" do
|
901
|
-
let(:release_info) { { "ID" => "os_id" } }
|
614
|
+
context "on version 5.x" do
|
902
615
|
|
903
|
-
|
904
|
-
allow(File).to receive(:exist?).with("/etc/os-release").and_return(true)
|
905
|
-
allow(@plugin).to receive(:read_os_release_info).with("/etc/os-release").and_return(release_info)
|
906
|
-
end
|
616
|
+
let(:have_enterprise_release) { true }
|
907
617
|
|
908
|
-
|
909
|
-
|
910
|
-
|
911
|
-
|
618
|
+
it "should read the platform as oracle and version as 5.7" do
|
619
|
+
plugin[:lsb][:id] = "EnterpriseEnterpriseServer"
|
620
|
+
plugin[:lsb][:release] = "5.7"
|
621
|
+
allow(File).to receive(:read).with("/etc/redhat-release").and_return("Red Hat Enterprise Linux Server release 5.7 (Tikanga)")
|
622
|
+
expect(File).to receive(:read).with("/etc/enterprise-release").and_return("Enterprise Linux Enterprise Linux Server release 5.7 (Carthage)")
|
623
|
+
plugin.run
|
624
|
+
expect(plugin[:platform]).to eq("oracle")
|
625
|
+
expect(plugin[:platform_version]).to eq("5.7")
|
626
|
+
end
|
627
|
+
end
|
912
628
|
|
913
|
-
|
914
|
-
expect(@plugin.os_release_info["ID"]).to eq("os_id")
|
915
|
-
end
|
916
|
-
end
|
629
|
+
context "on version 6.x" do
|
917
630
|
|
918
|
-
|
919
|
-
let(:release_info) { { "ID" => "os_id", "CISCO_RELEASE_INFO" => "/etc/cisco-release" } }
|
920
|
-
let(:cisco_release_info) { { "ID" => "cisco_id" } }
|
921
|
-
|
922
|
-
before do
|
923
|
-
allow(File).to receive(:exist?).with("/etc/os-release").and_return(true)
|
924
|
-
allow(File).to receive(:exist?).with("/etc/cisco-release").and_return(true)
|
925
|
-
allow(@plugin).to receive(:read_os_release_info).with("/etc/os-release").and_return(release_info)
|
926
|
-
allow(@plugin).to receive(:read_os_release_info).with("/etc/cisco-release").and_return(cisco_release_info)
|
927
|
-
end
|
631
|
+
let(:have_oracle_release) { true }
|
928
632
|
|
929
|
-
|
930
|
-
|
931
|
-
|
932
|
-
|
933
|
-
|
633
|
+
it "should read the platform as oracle and version as 6.1" do
|
634
|
+
plugin[:lsb][:id] = "OracleServer"
|
635
|
+
plugin[:lsb][:release] = "6.1"
|
636
|
+
allow(File).to receive(:read).with("/etc/redhat-release").and_return("Red Hat Enterprise Linux Server release 6.1 (Santiago)")
|
637
|
+
expect(File).to receive(:read).with("/etc/oracle-release").and_return("Oracle Linux Server release 6.1")
|
638
|
+
plugin.run
|
639
|
+
expect(plugin[:platform]).to eq("oracle")
|
640
|
+
expect(plugin[:platform_version]).to eq("6.1")
|
641
|
+
end
|
934
642
|
|
935
|
-
|
936
|
-
expect(@plugin.os_release_info["ID"]).to eq("cisco_id")
|
643
|
+
end
|
937
644
|
end
|
938
|
-
end
|
939
|
-
end
|
940
645
|
|
941
|
-
|
942
|
-
|
943
|
-
|
944
|
-
|
945
|
-
"ID" => "nexus",
|
946
|
-
"ID_LIKE" => "wrlinux",
|
947
|
-
"NAME" => "Nexus",
|
948
|
-
"VERSION" => "7.0(3)I2(0.475E.6)",
|
949
|
-
"VERSION_ID" => "7.0(3)I2",
|
950
|
-
"PRETTY_NAME" => "Nexus 7.0(3)I2",
|
951
|
-
"HOME_URL" => "http://www.cisco.com",
|
952
|
-
"BUILD_ID" => "6",
|
953
|
-
"CISCO_RELEASE_INFO" => "/etc/os-release",
|
954
|
-
}
|
955
|
-
end
|
646
|
+
context "without lsb_results" do
|
647
|
+
before(:each) do
|
648
|
+
plugin.lsb = nil
|
649
|
+
end
|
956
650
|
|
957
|
-
|
958
|
-
|
959
|
-
|
960
|
-
|
651
|
+
context "on version 5.x" do
|
652
|
+
|
653
|
+
let(:have_enterprise_release) { true }
|
654
|
+
|
655
|
+
it "should read the platform as oracle and version as 5" do
|
656
|
+
allow(File).to receive(:read).with("/etc/redhat-release").and_return("Enterprise Linux Enterprise Linux Server release 5 (Carthage)")
|
657
|
+
expect(File).to receive(:read).with("/etc/enterprise-release").and_return("Enterprise Linux Enterprise Linux Server release 5 (Carthage)")
|
658
|
+
plugin.run
|
659
|
+
expect(plugin[:platform]).to eq("oracle")
|
660
|
+
expect(plugin[:platform_version]).to eq("5")
|
661
|
+
end
|
662
|
+
|
663
|
+
it "should read the platform as oracle and version as 5.1" do
|
664
|
+
allow(File).to receive(:read).with("/etc/redhat-release").and_return("Enterprise Linux Enterprise Linux Server release 5.1 (Carthage)")
|
665
|
+
expect(File).to receive(:read).with("/etc/enterprise-release").and_return("Enterprise Linux Enterprise Linux Server release 5.1 (Carthage)")
|
666
|
+
plugin.run
|
667
|
+
expect(plugin[:platform]).to eq("oracle")
|
668
|
+
expect(plugin[:platform_version]).to eq("5.1")
|
669
|
+
end
|
670
|
+
|
671
|
+
it "should read the platform as oracle and version as 5.7" do
|
672
|
+
allow(File).to receive(:read).with("/etc/redhat-release").and_return("Red Hat Enterprise Linux Server release 5.7 (Tikanga)")
|
673
|
+
expect(File).to receive(:read).with("/etc/enterprise-release").and_return("Enterprise Linux Enterprise Linux Server release 5.7 (Carthage)")
|
674
|
+
plugin.run
|
675
|
+
expect(plugin[:platform]).to eq("oracle")
|
676
|
+
expect(plugin[:platform_version]).to eq("5.7")
|
677
|
+
end
|
961
678
|
|
962
|
-
|
963
|
-
expect(@plugin[:platform_family]).to eq("wrlinux")
|
964
|
-
expect(@plugin[:platform_version]).to eq("7.0(3)I2(0.475E.6)")
|
965
|
-
end
|
966
|
-
end
|
679
|
+
end
|
967
680
|
|
968
|
-
|
969
|
-
|
970
|
-
|
971
|
-
|
972
|
-
|
973
|
-
|
974
|
-
|
975
|
-
|
976
|
-
|
977
|
-
|
978
|
-
|
979
|
-
|
980
|
-
|
981
|
-
|
681
|
+
context "on version 6.x" do
|
682
|
+
|
683
|
+
let(:have_oracle_release) { true }
|
684
|
+
|
685
|
+
it "should read the platform as oracle and version as 6.0" do
|
686
|
+
allow(File).to receive(:read).with("/etc/redhat-release").and_return("Red Hat Enterprise Linux Server release 6.0 (Santiago)")
|
687
|
+
expect(File).to receive(:read).with("/etc/oracle-release").and_return("Oracle Linux Server release 6.0")
|
688
|
+
plugin.run
|
689
|
+
expect(plugin[:platform]).to eq("oracle")
|
690
|
+
expect(plugin[:platform_version]).to eq("6.0")
|
691
|
+
end
|
692
|
+
|
693
|
+
it "should read the platform as oracle and version as 6.1" do
|
694
|
+
allow(File).to receive(:read).with("/etc/redhat-release").and_return("Red Hat Enterprise Linux Server release 6.1 (Santiago)")
|
695
|
+
expect(File).to receive(:read).with("/etc/oracle-release").and_return("Oracle Linux Server release 6.1")
|
696
|
+
plugin.run
|
697
|
+
expect(plugin[:platform]).to eq("oracle")
|
698
|
+
expect(plugin[:platform_version]).to eq("6.1")
|
699
|
+
end
|
700
|
+
end
|
701
|
+
end
|
982
702
|
end
|
983
703
|
|
984
|
-
|
985
|
-
|
986
|
-
|
987
|
-
|
988
|
-
|
989
|
-
expect(@plugin[:platform]).to eq("ios_xr")
|
990
|
-
expect(@plugin[:platform_family]).to eq("wrlinux")
|
991
|
-
expect(@plugin[:platform_version]).to eq("6.0.0.14I")
|
992
|
-
end
|
993
|
-
end
|
704
|
+
describe "on suse" do
|
705
|
+
context "on versions that have no /etc/os-release but /etc/SuSE-release (e.g. SLES12.1)" do
|
706
|
+
let(:have_suse_release) { true }
|
707
|
+
let(:have_os_release) { false }
|
994
708
|
|
995
|
-
|
996
|
-
|
997
|
-
|
998
|
-
|
999
|
-
let(:usr_lib_os_release_content) do
|
1000
|
-
<<~CLEARLINUX_RELEASE
|
1001
|
-
NAME="Clear Linux Software for Intel Architecture"
|
1002
|
-
VERSION=1
|
1003
|
-
ID=clear-linux-os
|
1004
|
-
VERSION_ID=16140
|
1005
|
-
PRETTY_NAME="Clear Linux OS for Intel Architecture"
|
1006
|
-
ANSI_COLOR="1;35"
|
1007
|
-
HOME_URL="https://clearlinux.org"
|
1008
|
-
SUPPORT_URL="https://clearlinux.org"
|
1009
|
-
BUG_REPORT_URL="mailto:dev@lists.clearlinux.org"
|
1010
|
-
PRIVACY_POLICY_URL="http://www.intel.com/privacy"
|
1011
|
-
CLEARLINUX_RELEASE
|
1012
|
-
end
|
709
|
+
describe "with lsb_release results" do
|
710
|
+
before(:each) do
|
711
|
+
plugin[:lsb][:id] = "SUSE LINUX"
|
712
|
+
end
|
1013
713
|
|
1014
|
-
|
1015
|
-
|
714
|
+
it "should read the platform as opensuse on openSUSE" do
|
715
|
+
plugin[:lsb][:release] = "12.1"
|
716
|
+
expect(File).to receive(:read).with("/etc/SuSE-release").and_return("openSUSE 12.1 (x86_64)\nVERSION = 12.1\nCODENAME = Asparagus\n")
|
717
|
+
plugin.run
|
718
|
+
expect(plugin[:platform]).to eq("opensuse")
|
719
|
+
expect(plugin[:platform_family]).to eq("suse")
|
720
|
+
end
|
721
|
+
end
|
1016
722
|
end
|
1017
723
|
|
1018
|
-
|
1019
|
-
|
1020
|
-
|
1021
|
-
|
1022
|
-
|
1023
|
-
|
1024
|
-
|
724
|
+
context "on openSUSE and older SLES versions" do
|
725
|
+
let(:have_suse_release) { true }
|
726
|
+
|
727
|
+
describe "without lsb_release results" do
|
728
|
+
before(:each) do
|
729
|
+
plugin.lsb = nil
|
730
|
+
end
|
731
|
+
|
732
|
+
it "should set platform and platform_family to suse and bogus verion to 10.0" do
|
733
|
+
expect(File).to receive(:read).with("/etc/SuSE-release").at_least(:once).and_return("VERSION = 10.0")
|
734
|
+
plugin.run
|
735
|
+
expect(plugin[:platform]).to eq("suse")
|
736
|
+
expect(plugin[:platform_family]).to eq("suse")
|
737
|
+
end
|
738
|
+
|
739
|
+
it "should read the version as 11.2" do
|
740
|
+
expect(File).to receive(:read).with("/etc/SuSE-release").and_return("SUSE Linux Enterprise Server 11.2 (i586)\nVERSION = 11\nPATCHLEVEL = 2\n")
|
741
|
+
plugin.run
|
742
|
+
expect(plugin[:platform]).to eq("suse")
|
743
|
+
expect(plugin[:platform_version]).to eq("11.2")
|
744
|
+
expect(plugin[:platform_family]).to eq("suse")
|
745
|
+
end
|
746
|
+
|
747
|
+
it "[OHAI-272] should read the version as 11.3" do
|
748
|
+
expect(File).to receive(:read).with("/etc/SuSE-release").exactly(1).times.and_return("openSUSE 11.3 (x86_64)\nVERSION = 11.3")
|
749
|
+
plugin.run
|
750
|
+
expect(plugin[:platform]).to eq("opensuse")
|
751
|
+
expect(plugin[:platform_version]).to eq("11.3")
|
752
|
+
expect(plugin[:platform_family]).to eq("suse")
|
753
|
+
end
|
754
|
+
|
755
|
+
it "[OHAI-272] should read the version as 11.4" do
|
756
|
+
expect(File).to receive(:read).with("/etc/SuSE-release").exactly(1).times.and_return("openSUSE 11.4 (i586)\nVERSION = 11.4\nCODENAME = Celadon")
|
757
|
+
plugin.run
|
758
|
+
expect(plugin[:platform]).to eq("opensuse")
|
759
|
+
expect(plugin[:platform_version]).to eq("11.4")
|
760
|
+
expect(plugin[:platform_family]).to eq("suse")
|
761
|
+
end
|
762
|
+
|
763
|
+
it "should read the platform as opensuse on openSUSE" do
|
764
|
+
expect(File).to receive(:read).with("/etc/SuSE-release").and_return("openSUSE 12.2 (x86_64)\nVERSION = 12.2\nCODENAME = Mantis\n")
|
765
|
+
plugin.run
|
766
|
+
expect(plugin[:platform]).to eq("opensuse")
|
767
|
+
expect(plugin[:platform_family]).to eq("suse")
|
768
|
+
end
|
769
|
+
|
770
|
+
it "should read the platform as opensuseleap on openSUSE Leap" do
|
771
|
+
expect(File).to receive(:read).with("/etc/SuSE-release").and_return("openSUSE 42.1 (x86_64)\nVERSION = 42.1\nCODENAME = Malachite\n")
|
772
|
+
plugin.run
|
773
|
+
expect(plugin[:platform]).to eq("opensuseleap")
|
774
|
+
expect(plugin[:platform_family]).to eq("suse")
|
775
|
+
end
|
776
|
+
end
|
1025
777
|
end
|
1026
778
|
end
|
1027
779
|
|
1028
|
-
|
1029
|
-
let(:have_os_release) { true }
|
780
|
+
describe "on clearlinux" do
|
1030
781
|
let(:have_usr_lib_os_release) { true }
|
1031
|
-
let(:
|
782
|
+
let(:usr_lib_os_release_content) do
|
1032
783
|
<<~CLEARLINUX_RELEASE
|
1033
|
-
NAME="Clear Linux
|
784
|
+
NAME="Clear Linux OS"
|
1034
785
|
VERSION=1
|
1035
786
|
ID=clear-linux-os
|
1036
|
-
|
1037
|
-
|
1038
|
-
|
1039
|
-
|
1040
|
-
SUPPORT_URL="https://clearlinux.org"
|
1041
|
-
BUG_REPORT_URL="mailto:dev@lists.clearlinux.org"
|
1042
|
-
PRIVACY_POLICY_URL="http://www.intel.com/privacy"
|
1043
|
-
CLEARLINUX_RELEASE
|
787
|
+
ID_LIKE=clear-linux-os
|
788
|
+
VERSION_ID=26290
|
789
|
+
PRETTY_NAME="Clear Linux OS"
|
790
|
+
CLEARLINUX_RELEASE
|
1044
791
|
end
|
1045
|
-
|
1046
792
|
before do
|
1047
|
-
expect(File).to receive(:read).with("/
|
1048
|
-
expect(File).not_to receive(:read).with("/usr/lib/os-release")
|
793
|
+
expect(File).to receive(:read).with("/usr/lib/os-release").and_return(usr_lib_os_release_content)
|
1049
794
|
end
|
1050
|
-
|
1051
795
|
it "should set platform to clearlinux and platform_family to clearlinux" do
|
1052
|
-
|
1053
|
-
|
1054
|
-
|
1055
|
-
expect(
|
1056
|
-
expect(
|
1057
|
-
expect(@plugin[:platform_version]).to eq("16140")
|
796
|
+
plugin.lsb = nil
|
797
|
+
plugin.run
|
798
|
+
expect(plugin[:platform]).to eq("clearlinux")
|
799
|
+
expect(plugin[:platform_family]).to eq("clearlinux")
|
800
|
+
expect(plugin[:platform_version]).to eq("26290")
|
1058
801
|
end
|
1059
802
|
end
|
1060
803
|
end
|