summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMatthew Boehlig <matthew@complexgames.com>2014-08-15 14:40:19 -0500
committerMatthew Boehlig <matthew@complexgames.com>2014-08-18 13:58:05 -0500
commit44c67a6b5ae88dd24f5026223547cf2e37fda560 (patch)
tree0b27c29645d6202d11c1d182b2739545e35b123b /lib
parent3ee2f961bc3cb615435e53d1c1f23838f9d4856f (diff)
Add model for Cisco small business switches
Supports 200, 300, 500, and ESW2 series switches
Diffstat (limited to 'lib')
-rw-r--r--lib/oxidized/model/ciscosmb.rb48
1 files changed, 48 insertions, 0 deletions
diff --git a/lib/oxidized/model/ciscosmb.rb b/lib/oxidized/model/ciscosmb.rb
new file mode 100644
index 0000000..718c60e
--- /dev/null
+++ b/lib/oxidized/model/ciscosmb.rb
@@ -0,0 +1,48 @@
+class CiscoSMB < Oxidized::Model
+
+ # Cisco Small Business 200, 300, 500, and ESW2 series switches
+ # http://www.cisco.com/c/en/us/support/switches/small-business-300-series-managed-switches/products-release-notes-list.html
+
+ prompt /^\r?([\w.@()-]+[#>]\s?)$/
+ comment '! '
+
+ cmd :all do |cfg|
+ lines = cfg.each_line.to_a[1..-2]
+ # Remove \r from beginning of response
+ lines[0].gsub!(/^\r.*?/, '') if lines.length > 0
+ lines.join
+ end
+
+ cmd :secret do |cfg|
+ cfg.gsub! /^(snmp-server community).*/, '\\1 <configuration removed>'
+ cfg.gsub! /username (\S+) privilege (\d+) (\S+).*/, '<secret hidden>'
+ cfg
+ end
+
+ cmd 'show version' do |cfg|
+ comment cfg
+ end
+
+ cmd 'show inventory' do |cfg|
+ comment cfg
+ end
+
+ cmd 'show running-config' do |cfg|
+ cfg = cfg.each_line.to_a[0..-1].join
+ cfg.gsub! /^Current configuration : [^\n]*\n/, ''
+ cfg.sub! /^(ntp clock-period).*/, '! \1'
+ cfg.gsub! /^\ tunnel\ mpls\ traffic-eng\ bandwidth[^\n]*\n*(
+ (?:\ [^\n]*\n*)*
+ tunnel\ mpls\ traffic-eng\ auto-bw)/mx, '\1'
+ cfg
+ end
+
+ cfg :telnet, :ssh do
+ username /^User Name:/
+ password /^\r?Password:$/
+ post_login 'terminal datadump' # Disable pager
+ post_login 'terminal width 0'
+ pre_logout 'exit'
+ end
+
+end