Skip to content

Commit

Permalink
Merge pull request #158 from jerearista/Arista_EOS
Browse files Browse the repository at this point in the history
Add detection for Arista EOS
  • Loading branch information
chris-rock authored Nov 3, 2016
2 parents cfe3641 + d9f29bc commit 0a40928
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/train/extras/os_common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
require 'train/extras/os_detect_unix'
require 'train/extras/os_detect_windows'
require 'train/extras/os_detect_esx'
require 'train/extras/os_detect_arista_eos'

module Train::Extras
class OSCommon
Expand All @@ -21,6 +22,7 @@ class OSCommon
include Train::Extras::DetectUnix
include Train::Extras::DetectWindows
include Train::Extras::DetectEsx
include Train::Extras::DetectAristaEos

attr_accessor :backend
def initialize(backend, platform = nil)
Expand Down Expand Up @@ -122,6 +124,7 @@ def detect_family_type # rubocop:disable Metrics/CyclomaticComplexity, Metrics/P
# unix based systems combine the above
return true if pf == 'unix' and detect_darwin
return true if pf == 'unix' and detect_esx
return true if pf == 'unix' and detect_arista_eos
return true if pf == 'unix' and detect_via_uname

# if we arrive here, we most likey have a regular linux
Expand Down
30 changes: 30 additions & 0 deletions lib/train/extras/os_detect_arista_eos.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# encoding: utf-8
# author: Jere Julian
#
# Arista EOS has 2 modes. Most compliance tests will use the network CLI
# but when working with vagrant, its common to encounter the raw bash shell.
require 'json'

module Train::Extras
module DetectAristaEos
def detect_arista_eos
if unix_file?('/usr/bin/FastCli')
output = @backend.run_command('FastCli -p 15 -c "show version | json"').stdout
@platform[:name] = 'arista_eos_bash'
family = 'fedora'
else
output = @backend.run_command('show version | json').stdout
end

unless output.empty?
eos_ver = JSON.parse(output)
@platform[:name] = @platform[:name] || 'arista_eos'
family ||= 'arista_eos'
@platform[:family] = family
@platform[:release] = eos_ver['version']
@platform[:arch] = eos_ver['architecture']
true
end
end
end
end

0 comments on commit 0a40928

Please sign in to comment.