diff options
Diffstat (limited to 'lib/oxidized/model')
-rw-r--r-- | lib/oxidized/model/ipos.rb | 36 | ||||
-rw-r--r-- | lib/oxidized/model/procurve.rb | 37 | ||||
-rw-r--r-- | lib/oxidized/model/tmos.rb | 2 |
3 files changed, 56 insertions, 19 deletions
diff --git a/lib/oxidized/model/ipos.rb b/lib/oxidized/model/ipos.rb index 1a77807..5efd831 100644 --- a/lib/oxidized/model/ipos.rb +++ b/lib/oxidized/model/ipos.rb @@ -7,18 +7,43 @@ class IPOS < Oxidized::Model comment '! ' cmd 'show chassis' do |cfg| - comment cfg + comment cfg.each_line.to_a[0..-2].join end - cmd 'show hardware detail' do |cfg| - comment cfg + cmd 'show hardware' do |cfg| + comment cfg.each_line.to_a[0..-2].join end cmd 'show release' do |cfg| - comment cfg + comment cfg.each_line.to_a[0..-2].join end - cmd 'show config' + cmd 'show configuration' do |cfg| + # SEOS regularly adds some odd line breaks in random places + # when showing the config, triggering changes. + cfg.gsub! "\r\n", "\n" + + cfg = cfg.each_line.to_a + + # Keeps the issued command commented but removes the uncommented "Building configuration..." + # and "Current configuration:" lines as well as the last prompt at the end. + cfg = cfg[4..-2].unshift comment cfg[0] + + # Later IPOS releases add this line in addition to the usual "last changed" line. + # It's touched regularly (as often as multiple times per minute) by the OS without actual visible config changes. + cfg = cfg.reject { |line| line.match "Configuration last changed by system user" } + + # Earlier IPOS releases lack the "changed by system user" line and instead overwrite + # the single "last changed by user" line. Because the line has a timestamp it will + # trigger constant changes if not removed. By doing so there will only be a single + # extra change trigged after an actual config change by a user but still have the + # real user. + cfg = cfg.reject { |line| line.match "Configuration last changed by user '%LICM%' at" } + cfg = cfg.reject { |line| line.match "Configuration last changed by user '<NO USER>' at" } + cfg = cfg.reject { |line| line.match "Configuration last changed by user '' at" } + + cfg.join + end cfg :telnet do username /^login:/ @@ -34,4 +59,3 @@ class IPOS < Oxidized::Model end end - diff --git a/lib/oxidized/model/procurve.rb b/lib/oxidized/model/procurve.rb index 684a4b6..e667f48 100644 --- a/lib/oxidized/model/procurve.rb +++ b/lib/oxidized/model/procurve.rb @@ -1,36 +1,49 @@ class Procurve < Oxidized::Model - # FIXME: this is way too unsafe - prompt /.*?(\w+# ).*/m + # some models start lines with \r + # previous command is repeated followed by "\eE", which sometimes ends up on last line + prompt /^\r?([\w -]+\eE)?([\w-]+# )$/ comment '! ' + # replace all used vt100 control sequences + expect /\e\[\??\d+(;\d+)*[A-Za-z]/ do |data, re| + data.gsub re, '' + end + expect /Press any key to continue/ do - send ' ' - "" + send ' ' + "" end cmd :all do |cfg| cfg = cfg.each_line.to_a[1..-3].join - cfg = cfg.gsub /\r/, '' - new_cfg = '' - cfg.each_line do |line| - line.sub! /^\e.*(\e.*)/, '\1' #leave last escape - line.sub! /\e\[24;1H/, '' #remove last escape, is it always this? - new_cfg << line - end - new_cfg + cfg = cfg.gsub /^\r/, '' + end + + cmd :secret do |cfg| + cfg.gsub! /^(snmp-server community).*/, '\\1 <configuration removed>' + cfg.gsub! /^(snmp-server host).*/, '\\1 <configuration removed>' + cfg.gsub! /^(radius-server host).*/, '\\1 <configuration removed>' + cfg end cmd 'show version' do |cfg| comment cfg end + # not supported on all models cmd 'show system-information' do |cfg| cfg = cfg.split("\n")[0..-8].join("\n") comment cfg end + # not supported on all models + cmd 'show system information' do |cfg| + cfg = cfg.split("\n")[0..-8].join("\n") + comment cfg + end + cmd 'show running-config' cfg :telnet do diff --git a/lib/oxidized/model/tmos.rb b/lib/oxidized/model/tmos.rb index 9f8183f..abaec9f 100644 --- a/lib/oxidized/model/tmos.rb +++ b/lib/oxidized/model/tmos.rb @@ -23,7 +23,7 @@ class TMOS < Oxidized::Model cmd('cat /config/bigip.license') { |cfg| comment cfg } cmd 'tmsh -q list' do |cfg| - cfg.gsub!(/state (up|down)/, '') + cfg.gsub!(/state (up|down|checking|irule-down)/, '') cfg.gsub!(/errors (\d+)/, '') cfg end |