diff options
author | Torbjörn Lönnemark <ketl@nsc.liu.se> | 2017-09-19 16:28:41 +0200 |
---|---|---|
committer | Torbjörn Lönnemark <ketl@nsc.liu.se> | 2017-10-09 17:39:02 +0200 |
commit | 81fc3a4b423d8ce9fe69def57007312a96db6f67 (patch) | |
tree | 3aa704de93da6415417a4c7a1c2c549398986696 /lib/oxidized/model/supermicro2.rb | |
parent | 3826ec33af608a377c4421ea75622eebccdebee4 (diff) |
Add support for Supermicro SSE-G48-TG4
This model (and possibly others) runs an OS with a different set of
commands than the Supermicro model that already exists.
Diffstat (limited to 'lib/oxidized/model/supermicro2.rb')
-rw-r--r-- | lib/oxidized/model/supermicro2.rb | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/lib/oxidized/model/supermicro2.rb b/lib/oxidized/model/supermicro2.rb new file mode 100644 index 0000000..710603c --- /dev/null +++ b/lib/oxidized/model/supermicro2.rb @@ -0,0 +1,48 @@ +# Developed against: +# #show version +# Switch ID Hardware Version Firmware Version +# 0 SSE-G48-TG4 (P2-01) 1.0.16-9 + +class Supermicro2 < Oxidized::Model + prompt (/^(\e\[27m)?[ \r]*\w+# ?$/) + + cfg :ssh do + post_login 'no cli pagignation' + pre_logout 'exit' + end + + cmd :all do |cfg| + # * Drop first line that contains the command, and the last line that + # contains a prompt + # * Strip carriage returns + cfg.delete("\r").each_line.to_a[1..-2].join + end + + cmd :secret do |cfg| + cfg.gsub(/^(snmp community) .*/, '\1 <hidden>') + end + + cmd 'show system information' do |cfg| + cfg.sub! /^Device Up Time.*\n/, '' + cfg.delete! "\r" + comment(cfg).gsub(/ +$/, '') + end + + cmd 'show running-config' do |cfg| + comment_next = 0 + cfg.each_line.map { |l| + next '' if l.match /^Building configuration/ + + if l.match /^Switch ID.*Hardware Version.*Firmware Version/ then + comment_next = 2 + end + + if comment_next > 0 then + comment_next -= 1 + next comment(l) + end + + l + }.join.gsub(/ +$/, '') + end +end |