From 82dc9fad5d59fa2bc9533a62af35f0985dabadec Mon Sep 17 00:00:00 2001
From: MrRJ45 <couton@gmail.com>
Date: Mon, 30 Mar 2015 09:09:07 +0100
Subject: PowerConnect Model not skipping some details

Some PowerConnect models were skipping fine as "Uptime" for example is shown across one line. Some models show this as a heading, and then lines for each stack member and so this was being included in the configuration. This will skip that "section" which is terminated by the next blank line.
---
 lib/oxidized/model/powerconnect.rb | 25 ++++++++++++++++++++++---
 1 file changed, 22 insertions(+), 3 deletions(-)

(limited to 'lib/oxidized')

diff --git a/lib/oxidized/model/powerconnect.rb b/lib/oxidized/model/powerconnect.rb
index 429f1c8..17674f1 100644
--- a/lib/oxidized/model/powerconnect.rb
+++ b/lib/oxidized/model/powerconnect.rb
@@ -19,9 +19,8 @@ class PowerConnect < Oxidized::Model
   end
 
   cmd 'show system' do |cfg|
-    cfg = cfg.split("\n").select { |line| not line[/Up\sTime/] }
-    cfg = cfg[0..-28]<<" "
-    comment cfg.join("\n")
+    @model = $1 if cfg.match /Power[C|c]onnect (\d{4}[A-Z]?)/
+    clean cfg
   end
 
   cmd 'show running-config'
@@ -46,4 +45,24 @@ class PowerConnect < Oxidized::Model
     
   end
 
+  def clean cfg
+    out = []
+    skip_block = false
+    cfg.each_line do |line|
+      if line.match /Up\sTime|Temperature|Power Supplies/i
+        # For 34xx, 54xx, 55xx, and 8024F we should skip this block (terminated by a blank line)
+        skip_block = true if @model =~ /^34(24|48)$|^54(24|48)$|^55(24|48)$|^8024F$/
+      end
+      # If we have lines to skip do this until we reach and empty line
+      if skip_block
+        skip_block = false if /\S/ !~ line
+        next
+      end
+      out << line.strip
+    end
+    out = comment out.join "\n"
+    out << "\n"
+  end
+
+
 end
-- 
cgit v1.2.3