summaryrefslogtreecommitdiff
path: root/lib/oxidized/model/gcombnps.rb
diff options
context:
space:
mode:
authorWild Kat <wk@futureinquestion.net>2018-03-17 11:30:47 +0100
committerWild Kat <wk@futureinquestion.net>2018-03-17 11:30:47 +0100
commitf17736cabf0edda6788eff206aa12c9e35a22341 (patch)
tree113fa19d95571137018e5465e07f499cfa551bd1 /lib/oxidized/model/gcombnps.rb
parent81fc3a4b423d8ce9fe69def57007312a96db6f67 (diff)
parent7ecd5abe1cc2f2bbc6b29687352564cb7f087a5a (diff)
refactor supermicro support
Diffstat (limited to 'lib/oxidized/model/gcombnps.rb')
-rw-r--r--lib/oxidized/model/gcombnps.rb85
1 files changed, 85 insertions, 0 deletions
diff --git a/lib/oxidized/model/gcombnps.rb b/lib/oxidized/model/gcombnps.rb
new file mode 100644
index 0000000..4a97162
--- /dev/null
+++ b/lib/oxidized/model/gcombnps.rb
@@ -0,0 +1,85 @@
+class GcomBNPS < Oxidized::Model
+ # For switches from GCOM Technologies Co.,Ltd. running the "Broadband Network Platform Software"
+ # Author: Frederik Kriewitz <frederik@kriewitz.eu>
+ #
+ # tested with:
+ # - S5330 (aka Fiberstore S3800)
+
+ prompt /^\r?([\w.@()-]+?(\(1-16 chars\))?[#>:]\s?)$/ # also match SSH password promt (post_login commands are sent after the first prompt)
+ comment '! '
+
+# alternative to handle the SSH login, but this breaks telnet
+# expect /^Password\(1-16 chars\):/ do |data|
+# send @node.auth[:password] + "\n"
+# ''
+# end
+
+ # handle pager (can't be disabled?)
+ expect /^\.\.\.\.press ENTER to next line, CTRL_C to quit, other key to next page\.\.\.\.$/ do |data, re|
+ send ' '
+ data.sub re, ''
+ end
+
+ cmd :all do |cfg|
+ cfg = cfg.gsub " \e[73D\e[K", '' # remove garbage remaining from the pager
+ cfg.each_line.to_a[1..-2].join
+ end
+
+ cmd :secret do |cfg|
+ cfg.gsub! /^(snmp-server community)\s+[^\s]+\s+(.*)/, '\\1 <community hidden> \\2'
+ cfg
+ end
+
+ cmd 'show running-config' do |cfg|
+ cfg
+ end
+
+ cmd 'show interface sfp' do |cfg|
+ out = []
+ cfg.each_line do |line|
+ next if line.match /^ Temperature/
+ next if line.match /^ Voltage\(V\)/
+ next if line.match /^ Bias Current\(mA\)/
+ next if line.match /^ RX Power\(dBM\)/
+ next if line.match /^ TX Power\(dBM\)/
+ out << line
+ end
+
+ comment out.join
+ end
+
+
+ cmd 'show version' do |cfg|
+ comment cfg
+ end
+
+ cmd 'show system' do |cfg|
+ out = []
+ cfg.each_line do |line|
+ next if line.match /^system run time :/
+ next if line.match /^switch temperature :/
+ out << line
+ end
+
+ comment out.join
+ end
+
+ cfg :telnet do
+ username /^Username\(1-32 chars\):/
+ password /^Password\(1-16 chars\):/
+ end
+
+ cfg :ssh do
+ # the switch blindy accepts the SSH connection without password validation and then spawns a telnet login prompt
+ # first thing we've to send is the password
+ post_login do
+ send @node.auth[:password] + "\n"
+ end
+ end
+
+ cfg :telnet, :ssh do
+ pre_logout 'exit'
+ end
+
+end
+