diff options
author | Reinier Schoof <reinier@skoef.nl> | 2015-09-25 14:34:33 +0200 |
---|---|---|
committer | Reinier Schoof <reinier@skoef.nl> | 2015-09-25 14:34:33 +0200 |
commit | 8a63ff7e333457de9f6145e83c0ed3f1ebdba136 (patch) | |
tree | 85813746a30894959f6b148fa6a106d19772187d /lib/oxidized/model/foundry.rb | |
parent | 1da4f3f6a5b1c6a1c76bd1d34693fb4e5840aafa (diff) |
added model for older Foundry/Brocade model switches
Oxidized model for Foundry/Brocade switch models that run IronWare but
require carriage return instead of newline on enable command and
require different filters for temperature/uptime lines
Diffstat (limited to 'lib/oxidized/model/foundry.rb')
-rw-r--r-- | lib/oxidized/model/foundry.rb | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/lib/oxidized/model/foundry.rb b/lib/oxidized/model/foundry.rb new file mode 100644 index 0000000..beaf49d --- /dev/null +++ b/lib/oxidized/model/foundry.rb @@ -0,0 +1,58 @@ +# Oxidized model for Foundry/Brocade switch models that run IronWare +# but require carriage return instead of newline on enable command +# and require different filters for temperature/uptime lines +class Foundry < Oxidized::Model + + prompt /^.*(telnet|ssh)\@.+[>#]\s?$/i + comment '! ' + + cmd :all do |cfg| + cfg.each_line.to_a[1..-2].join + end + + cmd 'show running-config' do |cfg| + arr = cfg.each_line.to_a + arr[3..-1].join unless arr.length <= 3 + end + + cmd 'show version' do |cfg| + cfg.gsub! /(^((.*)[Ss]ystem uptime(.*))$)/, '' #remove unwanted line system uptime + + comment cfg + end + + cmd 'show chassis' do |cfg| + cfg.encode!("UTF-8", :invalid => :replace) #sometimes ironware returns broken encoding + cfg.gsub! /\d{2}\.\d deg-C$/, 'XX.X deg-C' + + comment cfg + end + + cmd 'show flash' do |cfg| + comment cfg + end + + cmd 'show module' do |cfg| + comment cfg + end + + cfg :telnet do + username /^Please Enter Login Name:/ + password /^Please Enter Password:/ + end + + #handle pager with enable + cfg :telnet, :ssh do + if vars :enable + post_login do + send "enable\r" + send vars(:enable) + "\r" + end + end + post_login 'skip-page-display' + pre_logout 'logout' + pre_logout 'exit' + pre_logout 'exit' + end + +end |