diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/oxidized/model/ipos.rb | 36 |
1 files changed, 30 insertions, 6 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 - |