summaryrefslogtreecommitdiff
path: root/lib/oxidized/model/junos.rb
blob: d1f4de6f379231913f57daec99e7bebd219077cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
class JunOS < Oxidized::Model

  comment  '# '

  def telnet
    @input.class.to_s.match /Telnet/
  end

  cmd :all do |cfg|
    # we don't need screen-scraping in ssh due to exec
    cfg = cfg.lines[1..-2].join if telnet
    cfg
  end

  cmd 'show configuration'

  cmd 'show version' do |cfg|
    chassis = model $1 if cfg.match /^Model: (\S+)/
    comment cfg << chassis.to_s
  end

  def model chassis
    case chassis
    when 'mx960'
      cmd('show chassis fabric reachability')  { |cfg| comment cfg }
    end
  end

  cmd 'show chassis hardware' do |cfg|
    comment cfg
  end

  cfg :telnet do
    username  /^login:/
    password  /^Password:/
  end

  cfg :ssh do
    exec true  # don't run shell, run each command in exec channel
  end

  cfg :telnet, :ssh do
    post_login 'set cli screen-length 0'
    post_login 'set cli screen-width 0'
    pre_logout 'exit'
  end

end