summaryrefslogtreecommitdiff
path: root/lib/oxidized/model
diff options
context:
space:
mode:
authorReinier Schoof <reinier@skoef.nl>2015-09-28 09:37:47 +0200
committerReinier Schoof <reinier@skoef.nl>2015-09-28 09:37:47 +0200
commitbf999706f0be794563b78fb90999b5c5fa8e54d5 (patch)
tree3329af3a48513824344880bc4e018fb54f6544e5 /lib/oxidized/model
parent8a63ff7e333457de9f6145e83c0ed3f1ebdba136 (diff)
merged models for older and newer
- login prompt matches both older and newer version of IronWare - send carriage returns for both versions as it should make no difference - made temperature filters compatible and removed obsolete ā€™dā€™ character
Diffstat (limited to 'lib/oxidized/model')
-rw-r--r--lib/oxidized/model/foundry.rb58
-rw-r--r--lib/oxidized/model/ironware.rb18
2 files changed, 10 insertions, 66 deletions
diff --git a/lib/oxidized/model/foundry.rb b/lib/oxidized/model/foundry.rb
deleted file mode 100644
index beaf49d..0000000
--- a/lib/oxidized/model/foundry.rb
+++ /dev/null
@@ -1,58 +0,0 @@
-# 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
diff --git a/lib/oxidized/model/ironware.rb b/lib/oxidized/model/ironware.rb
index 805e07b..870d45a 100644
--- a/lib/oxidized/model/ironware.rb
+++ b/lib/oxidized/model/ironware.rb
@@ -20,8 +20,8 @@ class IronWare < Oxidized::Model
end
cmd 'show running-config' do |cfg|
- cfg = cfg.each_line.to_a[3..-1].join
- cfg
+ arr = cfg.each_line.to_a
+ arr[3..-1].join unless arr.length < 3
end
cmd 'show version' do |cfg|
@@ -36,7 +36,7 @@ class IronWare < Oxidized::Model
cfg.gsub! /(^((.*)Current temp(.*))$)/, '' #remove unwanted lines current temperature
cfg.gsub! /Speed = [A-Z]{3} \(\d{2}\%\)/, '' #remove unwanted lines Speed Fans
cfg.gsub! /current speed is [A-Z]{3} \(\d{2}\%\)/, ''
- cfg.gsub! /Fan controlled temperature: \d{2}\.\d deg-C/, 'Fan controlled temperature: XX.X d deg-C'
+ cfg.gsub! /\d{2}\.\d deg-C/, 'XX.X deg-C'
if cfg.include? "TEMPERATURE"
sc = StringScanner.new cfg
out = ''
@@ -59,16 +59,18 @@ class IronWare < Oxidized::Model
end
cfg :telnet do
- username /^Username:/
- password /^Password:/
+ # match expected prompts on both older and newer
+ # versions of IronWare
+ username /^(Please Enter Login Name|Username):/
+ password /^(Please Enter )Password:/
end
#handle pager with enable
cfg :telnet, :ssh do
if vars :enable
post_login do
- send "enable\n"
- send vars(:enable) + "\n"
+ send "enable\r\n"
+ send vars(:enable) + "\r\n"
end
end
post_login ''
@@ -79,4 +81,4 @@ class IronWare < Oxidized::Model
pre_logout 'exit'
end
-end \ No newline at end of file
+end