diff options
author | Mikaƫl Mantel <mikaelmantel@users.noreply.github.com> | 2017-12-04 21:18:27 +0100 |
---|---|---|
committer | Neil Lathwood <neil@lathwood.co.uk> | 2017-12-04 20:18:27 +0000 |
commit | d2a9c75b02eb18f13121c9f653a443f58682505b (patch) | |
tree | 93fb2a8778378ee3c02a8ce2839082b94744d019 | |
parent | 2803e49ec9e10e97a0b28550f495eeb8e59b2c8d (diff) |
model: Added support for SLX-OS (#1056)
* Add support for SLX-OS
* Remove commented code
* Add SLX-OS on the list of Supported OS Types
* Replace tabs with spaces
* Regex modification for remove the display of uptime
-rw-r--r-- | docs/Supported-OS-Types.md | 11 | ||||
-rw-r--r-- | lib/oxidized/model/slxos.rb | 61 |
2 files changed, 67 insertions, 5 deletions
diff --git a/docs/Supported-OS-Types.md b/docs/Supported-OS-Types.md index 99566c4..a6ee713 100644 --- a/docs/Supported-OS-Types.md +++ b/docs/Supported-OS-Types.md @@ -27,11 +27,12 @@ * [VOSS (VSP Operating System Software)](/lib/oxidized/model/voss.rb) * [BOSS (Baystack Operating System Software)](/lib/oxidized/model/boss.rb) * Brocade - * [FabricOS](/lib/oxidized/model/fabricos.rb) - * [Ironware](/lib/oxidized/model/ironware.rb) - * [NOS (Network Operating System)](/lib/oxidized/model/nos.rb) - * [Vyatta](/lib/oxidized/model/vyatta.rb) - * [6910](/lib/oxidized/model/br6910.rb) + * [FabricOS](lib/oxidized/model/fabricos.rb) + * [Ironware](lib/oxidized/model/ironware.rb) + * [NOS (Network Operating System)](lib/oxidized/model/nos.rb) + * [Vyatta](lib/oxidized/model/vyatta.rb) + * [6910](lib/oxidized/model/br6910.rb) + * [SLX-OS](lib/oxidized/model/slxos.rb) * Casa * [Casa](/lib/oxidized/model/casa.rb) * Check Point diff --git a/lib/oxidized/model/slxos.rb b/lib/oxidized/model/slxos.rb new file mode 100644 index 0000000..934da5b --- /dev/null +++ b/lib/oxidized/model/slxos.rb @@ -0,0 +1,61 @@ +class SLXOS < Oxidized::Model + + prompt /^.*[>#]\s?$/i + comment '! ' + + cmd 'show version' do |cfg| + cfg.gsub! /(^((.*)[Ss]ystem [Uu]ptime(.*))$)/, '' #remove unwanted line system uptime + cfg.gsub! /[Uu]p\s?[Tt]ime is .*/,'' + + comment cfg + end + + cmd 'show chassis' do |cfg| + cfg.encode!("UTF-8", :invalid => :replace, :undef => :replace) #sometimes ironware returns broken encoding + cfg.gsub! /.*Power Usage.*/, '' #remove unwanted lines power usage + cfg.gsub! /Time A(live|wake).*/, '' #remove unwanted lines time alive/awake + cfg.gsub! /([\[]*)1([\]]*)<->([\[]*)2([\]]*)(<->([\[]*)3([\]]*))*/, '' + + comment cfg + end + + cmd 'show system' do |cfg| + cfg.gsub! /Up Time.*/, '' #removes uptime line + cfg.gsub! /Current Time.*/, '' #remove current time line + cfg.gsub! /.*speed is.*/, '' #removes fan speed lines + + comment cfg + end + + cmd 'show slots' do |cfg| + cfg.gsub! /^-*^$/, '' # some slx devices are fixed config + cfg.gsub! /syntax error: element does not exist/, '' # same as above + + comment cfg + end + + cmd 'show running-config' do |cfg| + arr = cfg.each_line.to_a + arr[2..-1].join unless arr.length < 2 + end + + cfg :telnet do + # match expected prompts + username /^(Please Enter Login Name|Username):/ + password /^(Please Enter Password ?|Password):/ + end + + #handle pager with enable + cfg :telnet, :ssh do + if vars :enable + post_login do + send "enable\n" + cmd vars(:enable) + end + end + post_login '' + post_login 'terminal length 0' + pre_logout 'exit' + end + +end |