diff options
author | Anton Aksola <anton.aksola@nebula.fi> | 2014-04-07 10:24:16 +0300 |
---|---|---|
committer | Anton Aksola <anton.aksola@nebula.fi> | 2014-04-07 10:24:16 +0300 |
commit | 2de3af62493cc7743d4f6d7981f3952ca040a9fe (patch) | |
tree | 1aba00198a3f9bc8c41e43d43268d7ccdf2d20c0 | |
parent | fe661afc33a967689e0c275db156c6c4bde3df8a (diff) |
add ACOS model for A10 AX and Thunder series0.0.44
-rw-r--r-- | lib/oxidized/model/acos.rb | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/lib/oxidized/model/acos.rb b/lib/oxidized/model/acos.rb new file mode 100644 index 0000000..8ac9165 --- /dev/null +++ b/lib/oxidized/model/acos.rb @@ -0,0 +1,69 @@ +class ACOS < Oxidized::Model + # A10 ACOS model for AX and Thunder series + + comment '! ' + + ##ACOS prompt changes depending on the state of the device + prompt /^([-\w.\/:?\[\]\(\)]+[#>]\s?)$/ + + cmd 'show version' do |cfg| + comment cfg + end + + cmd 'show license' do |cfg| + comment cfg + end + + cmd 'show running-config all-partitions' + + cmd 'show aflex all-partitions' do |cfg| + @partitions_aflex = cfg.lines.each_with_object({}) do |l,h| + h[$1] = [] if l.match /partition: (.+)/ + # only consider scripts that have passed syntax check + h[h.keys.last] << $1 if l.match /^([\w-]+) +Check/ + end + '' + end + + cmd :all do |cfg, cmdstring| + new_cfg = comment "COMMAND: #{cmdstring}\n" + new_cfg << cfg.each_line.to_a[1..-2].join + end + + pre do + unless @partitions_aflex.empty? + out = [] + @partitions_aflex.each do |partition,arules| + out << "! partition: #{partition}" + arules.each do |name| + cmd("show aflex #{name} partition #{partition}") do |cfg| + content = cfg.split(/Content:/).last.strip + out << "aflex create #{name}" + out << content + out << ".\n" + end + end + end + out.join "\n" + end + end + + cfg :telnet do + username /login:/ + password /^Password:/ + end + + cfg :telnet, :ssh do + # preferred way to handle additional passwords + if CFG.vars[:enable] and CFG.vars[:enable] != '' + post_login do + send "enable\n" + send CFG.vars[:enable] + "\n" + end + end + post_login 'terminal length 0' + post_login 'terminal width 0' + pre_logout "exit\nexit\ny" + end + +end |