train 3.2.14 → 3.2.20
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- metadata +29 -149
- data/LICENSE +0 -201
- data/lib/train.rb +0 -193
- data/lib/train/errors.rb +0 -44
- data/lib/train/extras.rb +0 -11
- data/lib/train/extras/command_wrapper.rb +0 -201
- data/lib/train/extras/stat.rb +0 -136
- data/lib/train/file.rb +0 -212
- data/lib/train/file/local.rb +0 -82
- data/lib/train/file/local/unix.rb +0 -96
- data/lib/train/file/local/windows.rb +0 -68
- data/lib/train/file/remote.rb +0 -40
- data/lib/train/file/remote/aix.rb +0 -29
- data/lib/train/file/remote/linux.rb +0 -21
- data/lib/train/file/remote/qnx.rb +0 -41
- data/lib/train/file/remote/unix.rb +0 -110
- data/lib/train/file/remote/windows.rb +0 -110
- data/lib/train/globals.rb +0 -5
- data/lib/train/options.rb +0 -81
- data/lib/train/platforms.rb +0 -102
- data/lib/train/platforms/common.rb +0 -34
- data/lib/train/platforms/detect.rb +0 -12
- data/lib/train/platforms/detect/helpers/os_common.rb +0 -160
- data/lib/train/platforms/detect/helpers/os_linux.rb +0 -80
- data/lib/train/platforms/detect/helpers/os_windows.rb +0 -142
- data/lib/train/platforms/detect/scanner.rb +0 -85
- data/lib/train/platforms/detect/specifications/api.rb +0 -20
- data/lib/train/platforms/detect/specifications/os.rb +0 -629
- data/lib/train/platforms/detect/uuid.rb +0 -32
- data/lib/train/platforms/family.rb +0 -31
- data/lib/train/platforms/platform.rb +0 -109
- data/lib/train/plugin_test_helper.rb +0 -51
- data/lib/train/plugins.rb +0 -40
- data/lib/train/plugins/base_connection.rb +0 -198
- data/lib/train/plugins/transport.rb +0 -49
- data/lib/train/transports/cisco_ios_connection.rb +0 -133
- data/lib/train/transports/local.rb +0 -240
- data/lib/train/transports/mock.rb +0 -183
- data/lib/train/transports/ssh.rb +0 -271
- data/lib/train/transports/ssh_connection.rb +0 -342
- data/lib/train/version.rb +0 -7
@@ -1,85 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require_relative "helpers/os_common"
|
4
|
-
|
5
|
-
module Train::Platforms::Detect
|
6
|
-
class Scanner
|
7
|
-
include Train::Platforms::Detect::Helpers::OSCommon
|
8
|
-
|
9
|
-
def initialize(backend)
|
10
|
-
@backend = backend
|
11
|
-
@platform = {}
|
12
|
-
@family_hierarchy = []
|
13
|
-
|
14
|
-
# detect cache variables
|
15
|
-
@files = {}
|
16
|
-
@uname = {}
|
17
|
-
@lsb = {}
|
18
|
-
@cache = {}
|
19
|
-
end
|
20
|
-
|
21
|
-
# Main detect method to scan all platforms for a match
|
22
|
-
#
|
23
|
-
# @return Train::Platform instance or error if none found
|
24
|
-
def scan
|
25
|
-
# start with the platform/families who have no families (the top levels)
|
26
|
-
top = Train::Platforms.top_platforms
|
27
|
-
top.each do |_name, plat|
|
28
|
-
# we are doing a instance_eval here to make sure we have the proper
|
29
|
-
# context with all the detect helper methods
|
30
|
-
next unless instance_eval(&plat.detect) == true
|
31
|
-
|
32
|
-
# if we have a match start looking at the children
|
33
|
-
plat_result = scan_children(plat)
|
34
|
-
next if plat_result.nil?
|
35
|
-
|
36
|
-
# return platform to backend
|
37
|
-
@family_hierarchy << plat.name
|
38
|
-
return get_platform(plat_result)
|
39
|
-
end
|
40
|
-
|
41
|
-
raise Train::PlatformDetectionFailed, "Sorry, we are unable to detect your platform"
|
42
|
-
end
|
43
|
-
|
44
|
-
def scan_children(parent)
|
45
|
-
parent.children.each do |plat, condition|
|
46
|
-
next unless instance_eval(&plat.detect) == true
|
47
|
-
|
48
|
-
if plat.class == Train::Platforms::Platform
|
49
|
-
return plat if condition.empty? || check_condition(condition)
|
50
|
-
elsif plat.class == Train::Platforms::Family
|
51
|
-
plat = scan_family_children(plat)
|
52
|
-
return plat unless plat.nil?
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
nil
|
57
|
-
end
|
58
|
-
|
59
|
-
def scan_family_children(plat)
|
60
|
-
child_result = scan_children(plat) unless plat.children.nil?
|
61
|
-
return if child_result.nil?
|
62
|
-
|
63
|
-
@family_hierarchy << plat.name
|
64
|
-
child_result
|
65
|
-
end
|
66
|
-
|
67
|
-
def check_condition(condition)
|
68
|
-
condition.each do |k, v|
|
69
|
-
op, expected = v.strip.split(" ")
|
70
|
-
op = "==" if op == "="
|
71
|
-
return false if @platform[k].nil? || !instance_eval("'#{@platform[k]}' #{op} '#{expected}'")
|
72
|
-
end
|
73
|
-
|
74
|
-
true
|
75
|
-
end
|
76
|
-
|
77
|
-
def get_platform(plat)
|
78
|
-
plat.backend = @backend
|
79
|
-
plat.platform = @platform
|
80
|
-
plat.add_platform_methods
|
81
|
-
plat.family_hierarchy = @family_hierarchy
|
82
|
-
plat
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
module Train::Platforms::Detect::Specifications
|
4
|
-
class Api
|
5
|
-
def self.load
|
6
|
-
plat = Train::Platforms
|
7
|
-
|
8
|
-
plat.family("api")
|
9
|
-
|
10
|
-
plat.family("cloud").in_family("api")
|
11
|
-
plat.name("aws").in_family("cloud")
|
12
|
-
plat.name("azure").in_family("cloud")
|
13
|
-
plat.name("gcp").in_family("cloud")
|
14
|
-
plat.name("vmware").in_family("cloud")
|
15
|
-
|
16
|
-
plat.family("iaas").in_family("api")
|
17
|
-
plat.name("oneview").in_family("iaas")
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,629 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
# rubocop:disable Style/Next
|
4
|
-
# rubocop:disable Metrics/AbcSize
|
5
|
-
# rubocop:disable Metrics/CyclomaticComplexity
|
6
|
-
# rubocop:disable Metrics/ClassLength
|
7
|
-
# rubocop:disable Metrics/MethodLength
|
8
|
-
# rubocop:disable Metrics/PerceivedComplexity
|
9
|
-
|
10
|
-
module Train::Platforms::Detect::Specifications
|
11
|
-
class OS
|
12
|
-
def self.load
|
13
|
-
plat = Train::Platforms
|
14
|
-
|
15
|
-
# master family
|
16
|
-
plat.family("os").detect { true }
|
17
|
-
|
18
|
-
plat.family("windows").in_family("os")
|
19
|
-
.detect do
|
20
|
-
# Can't return from a `proc` thus the `is_windows` shenanigans
|
21
|
-
is_windows = false
|
22
|
-
is_windows = true if winrm?
|
23
|
-
|
24
|
-
if @backend.class.to_s == "Train::Transports::Local::Connection"
|
25
|
-
is_windows = true if ruby_host_os(/mswin|mingw32|windows/)
|
26
|
-
end
|
27
|
-
|
28
|
-
# Try to detect windows even for ssh transport
|
29
|
-
if !is_windows && detect_windows == true
|
30
|
-
is_windows = true
|
31
|
-
end
|
32
|
-
|
33
|
-
is_windows
|
34
|
-
end
|
35
|
-
# windows platform
|
36
|
-
plat.name("windows").in_family("windows")
|
37
|
-
.detect do
|
38
|
-
true if detect_windows == true
|
39
|
-
end
|
40
|
-
|
41
|
-
# unix master family
|
42
|
-
plat.family("unix").in_family("os")
|
43
|
-
.detect do
|
44
|
-
# we want to catch a special case here where cisco commands
|
45
|
-
# don't return an exit status and still print to stdout
|
46
|
-
if unix_uname_s =~ /./ && !unix_uname_s.start_with?("Line has invalid autocommand ") && !unix_uname_s.start_with?("The command you have entered")
|
47
|
-
@platform[:arch] = unix_uname_m
|
48
|
-
true
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
# linux master family
|
53
|
-
plat.family("linux").in_family("unix")
|
54
|
-
.detect do
|
55
|
-
true if unix_uname_s =~ /linux/i
|
56
|
-
end
|
57
|
-
|
58
|
-
# debian family
|
59
|
-
plat.family("debian").in_family("linux")
|
60
|
-
.detect do
|
61
|
-
true unless unix_file_contents("/etc/debian_version").nil?
|
62
|
-
end
|
63
|
-
plat.name("ubuntu").title("Ubuntu Linux").in_family("debian")
|
64
|
-
.detect do
|
65
|
-
lsb = read_linux_lsb
|
66
|
-
if lsb && lsb[:id] =~ /ubuntu/i
|
67
|
-
@platform[:release] = lsb[:release]
|
68
|
-
true
|
69
|
-
end
|
70
|
-
end
|
71
|
-
plat.name("linuxmint").title("LinuxMint").in_family("debian")
|
72
|
-
.detect do
|
73
|
-
lsb = read_linux_lsb
|
74
|
-
if lsb && lsb[:id] =~ /linuxmint/i
|
75
|
-
@platform[:release] = lsb[:release]
|
76
|
-
true
|
77
|
-
end
|
78
|
-
end
|
79
|
-
plat.name("raspbian").title("Raspbian Linux").in_family("debian")
|
80
|
-
.detect do
|
81
|
-
if (linux_os_release && linux_os_release["NAME"] =~ /raspbian/i) || \
|
82
|
-
unix_file_exist?("/usr/bin/raspi-config")
|
83
|
-
@platform[:release] = unix_file_contents("/etc/debian_version").chomp
|
84
|
-
true
|
85
|
-
end
|
86
|
-
end
|
87
|
-
plat.name("debian").title("Debian Linux").in_family("debian")
|
88
|
-
.detect do
|
89
|
-
lsb = read_linux_lsb
|
90
|
-
if lsb && lsb[:id] =~ /debian/i
|
91
|
-
@platform[:release] = lsb[:release]
|
92
|
-
true
|
93
|
-
end
|
94
|
-
|
95
|
-
# if we get this far we have to be some type of debian
|
96
|
-
@platform[:release] = unix_file_contents("/etc/debian_version").chomp
|
97
|
-
true
|
98
|
-
end
|
99
|
-
|
100
|
-
# fedora family
|
101
|
-
plat.family("fedora").in_family("linux")
|
102
|
-
.detect do
|
103
|
-
true if linux_os_release && linux_os_release["NAME"] =~ /fedora/i
|
104
|
-
end
|
105
|
-
plat.name("fedora").title("Fedora").in_family("fedora")
|
106
|
-
.detect do
|
107
|
-
@platform[:release] = linux_os_release["VERSION_ID"]
|
108
|
-
true
|
109
|
-
end
|
110
|
-
|
111
|
-
# arista_eos family
|
112
|
-
# this checks for the arista bash shell
|
113
|
-
# must come before redhat as it uses fedora under the hood
|
114
|
-
plat.family("arista_eos").title("Arista EOS Family").in_family("linux")
|
115
|
-
.detect do
|
116
|
-
true
|
117
|
-
end
|
118
|
-
plat.name("arista_eos_bash").title("Arista EOS Bash Shell").in_family("arista_eos")
|
119
|
-
.detect do
|
120
|
-
if unix_file_exist?("/usr/bin/FastCli")
|
121
|
-
cmd = @backend.run_command('FastCli -p 15 -c "show version | json"')
|
122
|
-
if cmd.exit_status == 0 && !cmd.stdout.empty?
|
123
|
-
require "json"
|
124
|
-
begin
|
125
|
-
eos_ver = JSON.parse(cmd.stdout)
|
126
|
-
@platform[:release] = eos_ver["version"]
|
127
|
-
@platform[:arch] = eos_ver["architecture"]
|
128
|
-
true
|
129
|
-
rescue JSON::ParserError
|
130
|
-
nil
|
131
|
-
end
|
132
|
-
end
|
133
|
-
end
|
134
|
-
end
|
135
|
-
|
136
|
-
# redhat family
|
137
|
-
plat.family("redhat").in_family("linux")
|
138
|
-
.detect do
|
139
|
-
# I am not sure this returns true for all redhats in this family
|
140
|
-
# for now we are going to just try each platform
|
141
|
-
# return true unless unix_file_contents('/etc/redhat-release').nil?
|
142
|
-
|
143
|
-
true
|
144
|
-
end
|
145
|
-
plat.name("centos").title("Centos Linux").in_family("redhat")
|
146
|
-
.detect do
|
147
|
-
lsb = read_linux_lsb
|
148
|
-
if lsb && lsb[:id] =~ /centos/i
|
149
|
-
@platform[:release] = lsb[:release]
|
150
|
-
true
|
151
|
-
elsif linux_os_release && linux_os_release["NAME"] =~ /centos/i
|
152
|
-
@platform[:release] = redhatish_version(unix_file_contents("/etc/redhat-release"))
|
153
|
-
true
|
154
|
-
end
|
155
|
-
end
|
156
|
-
plat.name("oracle").title("Oracle Linux").in_family("redhat")
|
157
|
-
.detect do
|
158
|
-
if !(raw = unix_file_contents("/etc/oracle-release")).nil?
|
159
|
-
@platform[:release] = redhatish_version(raw)
|
160
|
-
true
|
161
|
-
elsif !(raw = unix_file_contents("/etc/enterprise-release")).nil?
|
162
|
-
@platform[:release] = redhatish_version(raw)
|
163
|
-
true
|
164
|
-
end
|
165
|
-
end
|
166
|
-
plat.name("scientific").title("Scientific Linux").in_family("redhat")
|
167
|
-
.detect do
|
168
|
-
lsb = read_linux_lsb
|
169
|
-
if lsb && lsb[:id] =~ /scientific/i
|
170
|
-
@platform[:release] = lsb[:release]
|
171
|
-
true
|
172
|
-
end
|
173
|
-
end
|
174
|
-
plat.name("xenserver").title("Xenserer Linux").in_family("redhat")
|
175
|
-
.detect do
|
176
|
-
lsb = read_linux_lsb
|
177
|
-
if lsb && lsb[:id] =~ /xenserver/i
|
178
|
-
@platform[:release] = lsb[:release]
|
179
|
-
true
|
180
|
-
end
|
181
|
-
end
|
182
|
-
plat.name("parallels-release").title("Parallels Linux").in_family("redhat")
|
183
|
-
.detect do
|
184
|
-
unless (raw = unix_file_contents("/etc/parallels-release")).nil?
|
185
|
-
@platform[:name] = redhatish_platform(raw)
|
186
|
-
@platform[:release] = raw[/(\d\.\d\.\d)/, 1]
|
187
|
-
true
|
188
|
-
end
|
189
|
-
end
|
190
|
-
plat.name("wrlinux").title("Wind River Linux").in_family("redhat")
|
191
|
-
.detect do
|
192
|
-
if linux_os_release && linux_os_release["ID_LIKE"] =~ /wrlinux/i
|
193
|
-
@platform[:release] = linux_os_release["VERSION"]
|
194
|
-
true
|
195
|
-
end
|
196
|
-
end
|
197
|
-
plat.name("amazon").title("Amazon Linux").in_family("redhat")
|
198
|
-
.detect do
|
199
|
-
lsb = read_linux_lsb
|
200
|
-
if lsb && lsb[:id] =~ /amazon/i
|
201
|
-
@platform[:release] = lsb[:release]
|
202
|
-
true
|
203
|
-
elsif (raw = unix_file_contents("/etc/system-release")) =~ /amazon/i
|
204
|
-
@platform[:name] = redhatish_platform(raw)
|
205
|
-
@platform[:release] = redhatish_version(raw)
|
206
|
-
true
|
207
|
-
end
|
208
|
-
end
|
209
|
-
plat.name("cloudlinux").title("CloudLinux").in_family("redhat")
|
210
|
-
.detect do
|
211
|
-
lsb = read_linux_lsb
|
212
|
-
if lsb && lsb[:id] =~ /cloudlinux/i
|
213
|
-
@platform[:release] = lsb[:release]
|
214
|
-
true
|
215
|
-
elsif (raw = unix_file_contents("/etc/redhat-release")) =~ /cloudlinux/i
|
216
|
-
@platform[:name] = redhatish_platform(raw)
|
217
|
-
@platform[:release] = redhatish_version(raw)
|
218
|
-
true
|
219
|
-
end
|
220
|
-
end
|
221
|
-
# keep redhat at the end as a fallback for anything with a redhat-release
|
222
|
-
plat.name("redhat").title("Red Hat Linux").in_family("redhat")
|
223
|
-
.detect do
|
224
|
-
lsb = read_linux_lsb
|
225
|
-
if lsb && lsb[:id] =~ /redhat/i
|
226
|
-
@platform[:release] = lsb[:release]
|
227
|
-
true
|
228
|
-
elsif !(raw = unix_file_contents("/etc/redhat-release")).nil?
|
229
|
-
# must be some type of redhat
|
230
|
-
@platform[:name] = redhatish_platform(raw)
|
231
|
-
@platform[:release] = redhatish_version(raw)
|
232
|
-
true
|
233
|
-
end
|
234
|
-
end
|
235
|
-
|
236
|
-
# suse family
|
237
|
-
plat.family("suse").in_family("linux")
|
238
|
-
.detect do
|
239
|
-
if linux_os_release && linux_os_release["ID_LIKE"] =~ /suse/i
|
240
|
-
@platform[:release] = linux_os_release["VERSION"]
|
241
|
-
true
|
242
|
-
elsif !(suse = unix_file_contents("/etc/SuSE-release")).nil?
|
243
|
-
# https://rubular.com/r/UKaYWolCYFMfp1
|
244
|
-
version = suse.scan(/VERSION = (\d+)\nPATCHLEVEL = (\d+)/).flatten.join(".")
|
245
|
-
# https://rubular.com/r/b5PN3hZDxa5amV
|
246
|
-
version = suse[/VERSION\s?=\s?"?([\d\.]{2,})"?/, 1] if version == ""
|
247
|
-
@platform[:release] = version
|
248
|
-
true
|
249
|
-
end
|
250
|
-
end
|
251
|
-
plat.name("opensuse").title("OpenSUSE Linux").in_family("suse")
|
252
|
-
.detect do
|
253
|
-
true if (linux_os_release && linux_os_release["NAME"] =~ /^opensuse/i) ||
|
254
|
-
unix_file_contents("/etc/SuSE-release") =~ /^opensuse/i
|
255
|
-
end
|
256
|
-
plat.name("suse").title("Suse Linux").in_family("suse")
|
257
|
-
.detect do
|
258
|
-
true if (linux_os_release && linux_os_release["NAME"] =~ /^sles/i) ||
|
259
|
-
unix_file_contents("/etc/SuSE-release") =~ /suse/i
|
260
|
-
end
|
261
|
-
|
262
|
-
# arch
|
263
|
-
plat.name("arch").title("Arch Linux").in_family("linux")
|
264
|
-
.detect do
|
265
|
-
unless unix_file_contents("/etc/arch-release").nil?
|
266
|
-
# Because this is a rolling release distribution,
|
267
|
-
# use the kernel release, ex. 4.1.6-1-ARCH
|
268
|
-
@platform[:release] = unix_uname_r
|
269
|
-
true
|
270
|
-
end
|
271
|
-
end
|
272
|
-
|
273
|
-
# slackware
|
274
|
-
plat.name("slackware").title("Slackware Linux").in_family("linux")
|
275
|
-
.detect do
|
276
|
-
unless (raw = unix_file_contents("/etc/slackware-version")).nil?
|
277
|
-
@platform[:release] = raw.scan(/(\d+|\.+)/).join
|
278
|
-
true
|
279
|
-
end
|
280
|
-
end
|
281
|
-
|
282
|
-
# gentoo
|
283
|
-
plat.name("gentoo").title("Gentoo Linux").in_family("linux")
|
284
|
-
.detect do
|
285
|
-
unless (raw = unix_file_contents("/etc/gentoo-release")).nil?
|
286
|
-
@platform[:release] = raw.scan(/(\d+|\.+)/).join
|
287
|
-
true
|
288
|
-
end
|
289
|
-
end
|
290
|
-
|
291
|
-
# exherbo
|
292
|
-
plat.name("exherbo").title("Exherbo Linux").in_family("linux")
|
293
|
-
.detect do
|
294
|
-
unless unix_file_contents("/etc/exherbo-release").nil?
|
295
|
-
# Because this is a rolling release distribution,
|
296
|
-
# use the kernel release, ex. 4.1.6
|
297
|
-
@platform[:release] = unix_uname_r
|
298
|
-
true
|
299
|
-
end
|
300
|
-
end
|
301
|
-
|
302
|
-
# alpine
|
303
|
-
plat.name("alpine").title("Alpine Linux").in_family("linux")
|
304
|
-
.detect do
|
305
|
-
unless (raw = unix_file_contents("/etc/alpine-release")).nil?
|
306
|
-
@platform[:release] = raw.strip
|
307
|
-
true
|
308
|
-
end
|
309
|
-
end
|
310
|
-
|
311
|
-
# coreos
|
312
|
-
plat.name("coreos").title("CoreOS Linux").in_family("linux")
|
313
|
-
.detect do
|
314
|
-
unless unix_file_contents("/etc/coreos/update.conf").nil?
|
315
|
-
lsb = read_linux_lsb
|
316
|
-
@platform[:release] = lsb[:release]
|
317
|
-
true
|
318
|
-
end
|
319
|
-
end
|
320
|
-
|
321
|
-
# yocto family
|
322
|
-
plat.family("yocto").in_family("linux")
|
323
|
-
.detect do
|
324
|
-
# /etc/issue isn't specific to yocto, but it's the only way to detect
|
325
|
-
# the platform because there are no other identifying files
|
326
|
-
if unix_file_contents("/etc/issue") &&
|
327
|
-
(unix_file_contents("/etc/issue").match?("Poky") ||
|
328
|
-
unix_file_contents("/etc/issue").match?("balenaOS"))
|
329
|
-
true
|
330
|
-
end
|
331
|
-
end
|
332
|
-
plat.name("yocto").title("Yocto Project Linux").in_family("yocto")
|
333
|
-
.detect do
|
334
|
-
if unix_file_contents("/etc/issue").match?("Poky")
|
335
|
-
# assuming the Poky version is preferred over the /etc/version build
|
336
|
-
@platform[:release] = unix_file_contents("/etc/issue").match('\d+(\.\d+)+')[0]
|
337
|
-
true
|
338
|
-
end
|
339
|
-
end
|
340
|
-
plat.name("balenaos").title("balenaOS Linux").in_family("yocto")
|
341
|
-
.detect do
|
342
|
-
# balenaOS does have the /etc/os-release file
|
343
|
-
if unix_file_contents("/etc/issue").match?("balenaOS") &&
|
344
|
-
linux_os_release["NAME"] =~ /balenaos/i
|
345
|
-
@platform[:release] = linux_os_release["META_BALENA_VERSION"]
|
346
|
-
true
|
347
|
-
end
|
348
|
-
end
|
349
|
-
|
350
|
-
# brocade family detected here if device responds to 'uname' command,
|
351
|
-
# happens when logging in as root
|
352
|
-
plat.family("brocade").title("Brocade Family").in_family("linux")
|
353
|
-
.detect do
|
354
|
-
!brocade_version.nil?
|
355
|
-
end
|
356
|
-
|
357
|
-
# generic linux
|
358
|
-
# this should always be last in the linux family list
|
359
|
-
plat.name("linux").title("Generic Linux").in_family("linux")
|
360
|
-
.detect do
|
361
|
-
true
|
362
|
-
end
|
363
|
-
|
364
|
-
# openvms
|
365
|
-
plat.name("openvms").title("OpenVMS").in_family("unix")
|
366
|
-
.detect do
|
367
|
-
if unix_uname_s =~ /unrecognized command verb/i
|
368
|
-
cmd = @backend.run_command("show system/noprocess")
|
369
|
-
unless cmd.exit_status != 0 || cmd.stdout.empty?
|
370
|
-
@platform[:name] = cmd.stdout.downcase.split(" ")[0]
|
371
|
-
cmd = @backend.run_command('write sys$output f$getsyi("VERSION")')
|
372
|
-
@platform[:release] = cmd.stdout.downcase.split("\n")[1][1..-1]
|
373
|
-
cmd = @backend.run_command('write sys$output f$getsyi("ARCH_NAME")')
|
374
|
-
@platform[:arch] = cmd.stdout.downcase.split("\n")[1]
|
375
|
-
true
|
376
|
-
end
|
377
|
-
end
|
378
|
-
end
|
379
|
-
|
380
|
-
# aix
|
381
|
-
plat.family("aix").in_family("unix")
|
382
|
-
.detect do
|
383
|
-
true if unix_uname_s =~ /aix/i
|
384
|
-
end
|
385
|
-
plat.name("aix").title("Aix").in_family("aix")
|
386
|
-
.detect do
|
387
|
-
out = @backend.run_command("uname -rvp").stdout
|
388
|
-
m = out.match(/(\d+)\s+(\d+)\s+(.*)/)
|
389
|
-
unless m.nil?
|
390
|
-
@platform[:release] = "#{m[2]}.#{m[1]}"
|
391
|
-
@platform[:arch] = m[3].to_s
|
392
|
-
end
|
393
|
-
true
|
394
|
-
end
|
395
|
-
|
396
|
-
# solaris family
|
397
|
-
plat.family("solaris").in_family("unix")
|
398
|
-
.detect do
|
399
|
-
if unix_uname_s =~ /sunos/i
|
400
|
-
unless (version = /^5\.(?<release>\d+)$/.match(unix_uname_r)).nil?
|
401
|
-
@platform[:release] = version["release"]
|
402
|
-
end
|
403
|
-
|
404
|
-
arch = @backend.run_command("uname -p")
|
405
|
-
@platform[:arch] = arch.stdout.chomp if arch.exit_status == 0
|
406
|
-
true
|
407
|
-
end
|
408
|
-
end
|
409
|
-
plat.name("smartos").title("SmartOS").in_family("solaris")
|
410
|
-
.detect do
|
411
|
-
rel = unix_file_contents("/etc/release")
|
412
|
-
if /^.*(SmartOS).*$/ =~ rel
|
413
|
-
true
|
414
|
-
end
|
415
|
-
end
|
416
|
-
plat.name("omnios").title("Omnios").in_family("solaris")
|
417
|
-
.detect do
|
418
|
-
rel = unix_file_contents("/etc/release")
|
419
|
-
unless (m = /^\s*(OmniOS).*r(\d+).*$/.match(rel)).nil?
|
420
|
-
@platform[:release] = m[2]
|
421
|
-
true
|
422
|
-
end
|
423
|
-
end
|
424
|
-
plat.name("openindiana").title("Openindiana").in_family("solaris")
|
425
|
-
.detect do
|
426
|
-
rel = unix_file_contents("/etc/release")
|
427
|
-
unless (m = /^\s*(OpenIndiana).*oi_(\d+).*$/.match(rel)).nil?
|
428
|
-
@platform[:release] = m[2]
|
429
|
-
true
|
430
|
-
end
|
431
|
-
end
|
432
|
-
plat.name("opensolaris").title("Open Solaris").in_family("solaris")
|
433
|
-
.detect do
|
434
|
-
rel = unix_file_contents("/etc/release")
|
435
|
-
unless (m = /^\s*(OpenSolaris).*snv_(\d+).*$/.match(rel)).nil?
|
436
|
-
@platform[:release] = m[2]
|
437
|
-
true
|
438
|
-
end
|
439
|
-
end
|
440
|
-
plat.name("nexentacore").title("Nexentacore").in_family("solaris")
|
441
|
-
.detect do
|
442
|
-
rel = unix_file_contents("/etc/release")
|
443
|
-
if /^\s*(NexentaCore)\s.*$/ =~ rel
|
444
|
-
true
|
445
|
-
end
|
446
|
-
end
|
447
|
-
plat.name("solaris").title("Solaris").in_family("solaris")
|
448
|
-
.detect do
|
449
|
-
rel = unix_file_contents("/etc/release")
|
450
|
-
if !(m = /Oracle Solaris (\d+)/.match(rel)).nil?
|
451
|
-
# TODO: should be string!
|
452
|
-
@platform[:release] = m[1]
|
453
|
-
true
|
454
|
-
elsif /^\s*(Solaris)\s.*$/ =~ rel
|
455
|
-
true
|
456
|
-
end
|
457
|
-
|
458
|
-
# must be some unknown solaris
|
459
|
-
true
|
460
|
-
end
|
461
|
-
|
462
|
-
# hpux
|
463
|
-
plat.family("hpux").in_family("unix")
|
464
|
-
.detect do
|
465
|
-
true if unix_uname_s =~ /hp-ux/i
|
466
|
-
end
|
467
|
-
plat.name("hpux").title("Hpux").in_family("hpux")
|
468
|
-
.detect do
|
469
|
-
@platform[:release] = unix_uname_r.lines[0].chomp
|
470
|
-
true
|
471
|
-
end
|
472
|
-
|
473
|
-
# qnx
|
474
|
-
plat.family("qnx").in_family("unix")
|
475
|
-
.detect do
|
476
|
-
true if unix_uname_s =~ /qnx/i
|
477
|
-
end
|
478
|
-
plat.name("qnx").title("QNX").in_family("qnx")
|
479
|
-
.detect do
|
480
|
-
@platform[:name] = unix_uname_s.lines[0].chomp.downcase
|
481
|
-
@platform[:release] = unix_uname_r.lines[0].chomp
|
482
|
-
@platform[:arch] = unix_uname_m
|
483
|
-
true
|
484
|
-
end
|
485
|
-
|
486
|
-
# bsd family
|
487
|
-
plat.family("bsd").in_family("unix")
|
488
|
-
.detect do
|
489
|
-
# we need a better way to determine this family
|
490
|
-
# for now we are going to just try each platform
|
491
|
-
true
|
492
|
-
end
|
493
|
-
plat.family("darwin").in_family("bsd")
|
494
|
-
.detect do
|
495
|
-
if unix_uname_s =~ /darwin/i
|
496
|
-
cmd = unix_file_contents("/usr/bin/sw_vers")
|
497
|
-
unless cmd.nil?
|
498
|
-
m = cmd.match(/^ProductVersion:\s+(.+)$/)
|
499
|
-
@platform[:release] = m.nil? ? nil : m[1]
|
500
|
-
m = cmd.match(/^BuildVersion:\s+(.+)$/)
|
501
|
-
@platform[:build] = m.nil? ? nil : m[1]
|
502
|
-
end
|
503
|
-
@platform[:release] = unix_uname_r.lines[0].chomp if @platform[:release].nil?
|
504
|
-
@platform[:arch] = unix_uname_m
|
505
|
-
true
|
506
|
-
end
|
507
|
-
end
|
508
|
-
plat.name("mac_os_x").title("macOS X").in_family("darwin")
|
509
|
-
.detect do
|
510
|
-
cmd = unix_file_contents("/System/Library/CoreServices/SystemVersion.plist")
|
511
|
-
@platform[:uuid_command] = "system_profiler SPHardwareDataType | awk '/UUID/ { print $3; }'"
|
512
|
-
true if cmd =~ /Mac OS X/i
|
513
|
-
end
|
514
|
-
plat.name("darwin").title("Darwin").in_family("darwin")
|
515
|
-
.detect do
|
516
|
-
# must be some other type of darwin
|
517
|
-
@platform[:name] = unix_uname_s.lines[0].chomp
|
518
|
-
true
|
519
|
-
end
|
520
|
-
plat.name("freebsd").title("Freebsd").in_family("bsd")
|
521
|
-
.detect do
|
522
|
-
if unix_uname_s =~ /freebsd/i
|
523
|
-
@platform[:name] = unix_uname_s.lines[0].chomp
|
524
|
-
@platform[:release] = unix_uname_r.lines[0].chomp
|
525
|
-
true
|
526
|
-
end
|
527
|
-
end
|
528
|
-
plat.name("openbsd").title("Openbsd").in_family("bsd")
|
529
|
-
.detect do
|
530
|
-
if unix_uname_s =~ /openbsd/i
|
531
|
-
@platform[:name] = unix_uname_s.lines[0].chomp
|
532
|
-
@platform[:release] = unix_uname_r.lines[0].chomp
|
533
|
-
true
|
534
|
-
end
|
535
|
-
end
|
536
|
-
plat.name("netbsd").title("Netbsd").in_family("bsd")
|
537
|
-
.detect do
|
538
|
-
if unix_uname_s =~ /netbsd/i
|
539
|
-
@platform[:name] = unix_uname_s.lines[0].chomp
|
540
|
-
@platform[:release] = unix_uname_r.lines[0].chomp
|
541
|
-
true
|
542
|
-
end
|
543
|
-
end
|
544
|
-
|
545
|
-
# arista_eos family
|
546
|
-
plat.family("arista_eos").title("Arista EOS Family").in_family("os")
|
547
|
-
.detect do
|
548
|
-
true
|
549
|
-
end
|
550
|
-
plat.name("arista_eos").title("Arista EOS").in_family("arista_eos")
|
551
|
-
.detect do
|
552
|
-
cmd = @backend.run_command("show version | json")
|
553
|
-
if cmd.exit_status == 0 && !cmd.stdout.empty?
|
554
|
-
require "json"
|
555
|
-
begin
|
556
|
-
eos_ver = JSON.parse(cmd.stdout)
|
557
|
-
@platform[:release] = eos_ver["version"]
|
558
|
-
@platform[:arch] = eos_ver["architecture"]
|
559
|
-
true
|
560
|
-
rescue JSON::ParserError
|
561
|
-
nil
|
562
|
-
end
|
563
|
-
end
|
564
|
-
end
|
565
|
-
|
566
|
-
# esx
|
567
|
-
plat.family("esx").title("ESXi Family").in_family("os")
|
568
|
-
.detect do
|
569
|
-
true if unix_uname_s =~ /vmkernel/i
|
570
|
-
end
|
571
|
-
plat.name("vmkernel").in_family("esx")
|
572
|
-
.detect do
|
573
|
-
@platform[:name] = unix_uname_s.lines[0].chomp
|
574
|
-
@platform[:release] = unix_uname_r.lines[0].chomp
|
575
|
-
true
|
576
|
-
end
|
577
|
-
|
578
|
-
# cisco_ios family
|
579
|
-
plat.family("cisco").title("Cisco Family").in_family("os")
|
580
|
-
.detect do
|
581
|
-
!cisco_show_version.nil?
|
582
|
-
end
|
583
|
-
plat.name("cisco_ios").title("Cisco IOS").in_family("cisco")
|
584
|
-
.detect do
|
585
|
-
v = cisco_show_version
|
586
|
-
next unless v[:type] == "ios"
|
587
|
-
|
588
|
-
@platform[:release] = v[:version]
|
589
|
-
@platform[:arch] = nil
|
590
|
-
true
|
591
|
-
end
|
592
|
-
plat.name("cisco_ios_xe").title("Cisco IOS XE").in_family("cisco")
|
593
|
-
.detect do
|
594
|
-
v = cisco_show_version
|
595
|
-
next unless v[:type] == "ios-xe"
|
596
|
-
|
597
|
-
@platform[:release] = v[:version]
|
598
|
-
@platform[:arch] = nil
|
599
|
-
true
|
600
|
-
end
|
601
|
-
plat.name("cisco_nexus").title("Cisco Nexus").in_family("cisco")
|
602
|
-
.detect do
|
603
|
-
v = cisco_show_version
|
604
|
-
next unless v[:type] == "nexus"
|
605
|
-
|
606
|
-
@platform[:release] = v[:version]
|
607
|
-
@platform[:arch] = nil
|
608
|
-
@platform[:uuid_command] = "show version | include Processor"
|
609
|
-
true
|
610
|
-
end
|
611
|
-
|
612
|
-
# brocade family
|
613
|
-
plat.family("brocade").title("Brocade Family").in_family("os")
|
614
|
-
.detect do
|
615
|
-
!brocade_version.nil?
|
616
|
-
end
|
617
|
-
|
618
|
-
plat.name("brocade_fos").title("Brocade FOS").in_family("brocade")
|
619
|
-
.detect do
|
620
|
-
v = brocade_version
|
621
|
-
next unless v[:type] == "fos"
|
622
|
-
|
623
|
-
@platform[:release] = v[:version]
|
624
|
-
@platform[:arch] = nil
|
625
|
-
true
|
626
|
-
end
|
627
|
-
end
|
628
|
-
end
|
629
|
-
end
|