diff options
author | Jesper Geertsen Jonsson <jesper.geertsen.jonsson@ericsson.com> | 2016-03-17 13:09:51 +0100 |
---|---|---|
committer | Jesper Geertsen Jonsson <jesper.geertsen.jonsson@ericsson.com> | 2016-03-17 13:09:51 +0100 |
commit | 5132c40e6e8028924b3eb8d70477a2ef83394f5b (patch) | |
tree | a824dc1f08971fd11d831769cbe63146eea8091d /lib | |
parent | 27ee487c9681e735de83dbd26463c07c3a91d869 (diff) |
IPOS model improvements to fix unwanted diffs.
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 - |