summaryrefslogtreecommitdiff
path: root/lib/oxidized/model/quanta.rb
blob: 870b77259002d8669b36b1055d615becce360a26 (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
class Quanta < Oxidized::Model

  prompt /^\((\w|\S)+\) (>|#)$/
  comment '! '
  cmd 'show run' do |cfg|
    cfg = cfg.each_line.select { |line| not line.match /^!.*$/ }
    cfg = cfg.join
    cfg = cfg.each_line.select { |line| not line.match /^\((\w|\S)+\) (>|#)$/ }
    cfg = cfg.join
    cfg = cfg.each_line.select { |line| not line.match /^show run$/ }
    cfg = cfg.join
  end

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

  cfg :telnet, :ssh do
    post_login do
      send "enable\n"
      if vars :enable
        cmd vars(:enable)
      else
        cmd ""
      end
    end
    post_login 'terminal length 0'
    pre_logout do
      send "quit\n"
      send "n\n"
    end
  end

end