diff --git a/lib/train/extras/os_common.rb b/lib/train/extras/os_common.rb index b126f523..0ebc981d 100644 --- a/lib/train/extras/os_common.rb +++ b/lib/train/extras/os_common.rb @@ -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 @@ -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) @@ -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 diff --git a/lib/train/extras/os_detect_arista_eos.rb b/lib/train/extras/os_detect_arista_eos.rb new file mode 100644 index 00000000..ad5fb69a --- /dev/null +++ b/lib/train/extras/os_detect_arista_eos.rb @@ -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