summaryrefslogtreecommitdiff
path: root/lib/oxidized/model/zynoscli.rb
blob: ae64b0429c37bb2466a3a81c1cdb0b9ab1b1ec6d (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
class ZyNOSCLI < Oxidized::Model
  # Used in Zyxel DSLAMs, such as SAM1316

  # Typical prompt "XGS4600#"
  prompt /^([\w.@()-]+[#>]\s\e7)$/
  comment  ';; '

  cmd :all do |cfg|
    cfg.gsub! /^.*\e7/, ''
  end
  cmd 'show stacking'

  cmd 'show version'

  cmd 'show running-config'

  cfg :telnet do
    username /^User name:/i
    password /^Password:/i
  end

  cfg :telnet, :ssh do
    if vars :enable
      post_login do
        send "enable\n"
        # Interpret enable: true as meaning we won't be prompted for a password
        unless vars(:enable).is_a? TrueClass
          expect /[pP]assword:\s?$/
          send vars(:enable) + "\n"
        end
        expect /^.+[#]$/
      end
    end
    pre_logout 'exit'
  end
end