Skip to content

Commit 0a40928

Browse files
authored
Merge pull request #158 from jerearista/Arista_EOS
Add detection for Arista EOS
2 parents cfe3641 + d9f29bc commit 0a40928

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

lib/train/extras/os_common.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
require 'train/extras/os_detect_unix'
1414
require 'train/extras/os_detect_windows'
1515
require 'train/extras/os_detect_esx'
16+
require 'train/extras/os_detect_arista_eos'
1617

1718
module Train::Extras
1819
class OSCommon
@@ -21,6 +22,7 @@ class OSCommon
2122
include Train::Extras::DetectUnix
2223
include Train::Extras::DetectWindows
2324
include Train::Extras::DetectEsx
25+
include Train::Extras::DetectAristaEos
2426

2527
attr_accessor :backend
2628
def initialize(backend, platform = nil)
@@ -122,6 +124,7 @@ def detect_family_type # rubocop:disable Metrics/CyclomaticComplexity, Metrics/P
122124
# unix based systems combine the above
123125
return true if pf == 'unix' and detect_darwin
124126
return true if pf == 'unix' and detect_esx
127+
return true if pf == 'unix' and detect_arista_eos
125128
return true if pf == 'unix' and detect_via_uname
126129

127130
# if we arrive here, we most likey have a regular linux
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# encoding: utf-8
2+
# author: Jere Julian
3+
#
4+
# Arista EOS has 2 modes. Most compliance tests will use the network CLI
5+
# but when working with vagrant, its common to encounter the raw bash shell.
6+
require 'json'
7+
8+
module Train::Extras
9+
module DetectAristaEos
10+
def detect_arista_eos
11+
if unix_file?('/usr/bin/FastCli')
12+
output = @backend.run_command('FastCli -p 15 -c "show version | json"').stdout
13+
@platform[:name] = 'arista_eos_bash'
14+
family = 'fedora'
15+
else
16+
output = @backend.run_command('show version | json').stdout
17+
end
18+
19+
unless output.empty?
20+
eos_ver = JSON.parse(output)
21+
@platform[:name] = @platform[:name] || 'arista_eos'
22+
family ||= 'arista_eos'
23+
@platform[:family] = family
24+
@platform[:release] = eos_ver['version']
25+
@platform[:arch] = eos_ver['architecture']
26+
true
27+
end
28+
end
29+
end
30+
end

0 commit comments

Comments
 (0)