From eaaef17151017210bb20a936c89b43584914f92c Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Thu, 10 Nov 2016 22:19:40 +0100 Subject: add support for PLANET SG switches So far, only SGS switches were supported. Now, we check the model type during the 'show version' command, and only execute the 'show transceiver details' command in case an SGS switch was detected (as its not supported on SG models). We will also strip lines containing the current System Time and Uptime. These only appear on SG models, but it's a good idea to strip them anyways. --- README.md | 3 +- lib/oxidized/model/planet.rb | 83 +++++++++++++++++++++++++++++++++++++++++ lib/oxidized/model/planetsgs.rb | 63 ------------------------------- 3 files changed, 84 insertions(+), 65 deletions(-) create mode 100644 lib/oxidized/model/planet.rb delete mode 100644 lib/oxidized/model/planetsgs.rb diff --git a/README.md b/README.md index 5595685..9ca6854 100644 --- a/README.md +++ b/README.md @@ -140,8 +140,7 @@ Oxidized is a network device configuration backup tool. It's a RANCID replacemen * [Opengear](lib/oxidized/model/opengear.rb) * Palo Alto * [PANOS](lib/oxidized/model/panos.rb) - * PLANET - * [SGS](lib/oxidized/model/planetsgs.rb) + * [PLANET SG/SGS Switches](lib/oxidized/model/planet.rb) * [pfSense](lib/oxidized/model/pfsense.rb) * Quanta * [Quanta / VxWorks 6.6 (1.1.0.8)](lib/oxidized/model/quantaos.rb) diff --git a/lib/oxidized/model/planet.rb b/lib/oxidized/model/planet.rb new file mode 100644 index 0000000..05a369a --- /dev/null +++ b/lib/oxidized/model/planet.rb @@ -0,0 +1,83 @@ +class Planet < Oxidized::Model + + prompt /^\r?([\w.@()-]+[#>]\s?)$/ + comment '! ' + + # example how to handle pager + #expect /^\s--More--\s+.*$/ do |data, re| + # send ' ' + # data.sub re, '' + #end + + # non-preferred way to handle additional PW prompt + #expect /^[\w.]+>$/ do |data| + # send "enable\n" + # send vars(:enable) + "\n" + # data + #end + + cmd :all do |cfg| + #cfg.gsub! /\cH+\s{8}/, '' # example how to handle pager + #cfg.gsub! /\cH+/, '' # example how to handle pager + cfg.each_line.to_a[1..-2].join + end + + cmd :secret do |cfg| + cfg.gsub! /^(snmp-server community).*/, '\\1 ' + cfg.gsub! /username (\S+) privilege (\d+) (\S+).*/, '