Module: Train::Extras::DetectAristaEos

Included in:
OSCommon
Defined in:
lib/train/extras/os_detect_arista_eos.rb

Instance Method Summary collapse

Instance Method Details

#detect_arista_eosObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/train/extras/os_detect_arista_eos.rb', line 10

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

  # in PTY mode, stderr is matched with stdout, therefore it may not be empty
  output = cmd.stdout
  if cmd.exit_status == 0 && !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
  else
    false
  end
end