ytti / oxidized

Oxidized is a network device configuration backup tool. It's a RANCID replacement!
Apache License 2.0
2.79k stars 922 forks source link

(Comware) "Current terminal monitor is off" Flapping issue #1754

Closed berilslv closed 1 year ago

berilslv commented 5 years ago

Hi Oxidized enthusiasts,

Im facing problem with git version flapping. Exactly the same problem as #1447 . Problem screenshot: Here

I tried to solve issue by adding vars_map:

IGNORE_DISPLAY_MY

if vars :ignore_display cfg.gsub! /"! Info: Current terminal monitor is off. .*/, '' Oxidized.logger.debug "Ignoring terminal off" end

But without success. I hope for some advices.

Have a nice friday guys! ;)

berilslv commented 5 years ago

Can somebody help me with this issue? Im still getting this current info flapping.

raunz commented 5 years ago

I ran into the same problem with current master comware model and HP 1910/1920 switches. First issue with the same problem seems to be #1447 These 19x0 units are tricky and cause very funky stuff with using 'send' Here a snippet of writeshark telnet tcp stream with current master comware.rb and it explains how 'send' commands get input/output/prompts totally messed up:

Username:oxidizeduser
oxidizeduser
Password:oxidizedpass

<hp1910switch>_cmdline-mode on
_y
512900
xtd-cli-mode on
y
512900
screen-length disable
.cmdline-mode on
All commands can be displayed and executed. Continue? [Y/N]y
Please input password:******
Warning: Now you enter an all-command mode for developer's testing, some commands may affect operation by wrong use, please carefully use it with our engineer's direction.
<hp1910switch>xundo terminal monitor
.td-cli-mode on
                     ^
 % Unrecognized command found at '^' position.
<hp1910switch>ydisplay version
.
                     ^
 % Unrecognized command found at '^' position.
<hp1910switch>display device
.512900
                     ^
 % Unrecognized command found at '^' position.
<hp1910switch>sdisplay device manuinfo
.creen-length disableundo terminal monitor
                                   ^
 % Unrecognized command found at '^' position.
<hp1910switch>ddisplay current-configuration
.isplay version
HPE Comware Platform Software
Comware Software, Version 5.20.99, Release 1113
Copyright (c) 2010-2016 Hewlett Packard Enterprise Development LP
HPE 1910-24 Switch uptime is 127 weeks, 5 days, 11 hours, 55 minutes

HPE 1910-24 Switch
128M    bytes DRAM
32M     bytes Flash Memory
Config Register points to Flash

Hardware Version is REV.A
Bootrom Version is 117
[SubSlot 0] 24FE+2GE Combo Hardware Version is REV.A

<hp1910switch>dquit
isplay device

After struggling with this I achieved not the prettiest but working model, which successfully works with the following units on telnet and ssh input:

Here's my current comware.rb. Instead of 'send' I use 'cmd' with additional prompt regex.

class Comware < Oxidized::Model
  # HP (A-series)/H3C/3Com Comware

  # sometimes the prompt might have a leading nul or trailing ASCII Bell (^G)
  prompt /^\0*(<[\w.-]+>).*$/
  comment '# '

  # example how to handle pager
  # expect /^\s*---- More ----$/ do |data, re|
  #  send ' '
  #  data.sub re, ''
  # end

  cmd :all do |cfg|
    # cfg.gsub! /^.*\e\[42D/, ''        # example how to handle pager
    # skip rogue ^M
    cfg = cfg.delete "\r"
    cfg.cut_both
  end

  cmd :secret do |cfg|
    cfg.gsub! /^( snmp-agent community).*/, '\\1 <configuration removed>'
    cfg.gsub! /^( password hash).*/, '\\1 <configuration removed>'
    cfg.gsub! /^( password cipher).*/, '\\1 <configuration removed>'
    cfg
  end

  cfg :telnet do
    username /^(Username|login):/
    password /^Password:/
  end

  cfg :telnet, :ssh do
    # enable command-line mode on SMB comware switches (HP V1910, V1920)
    # autodetection is hard, because the 'summary' command is paged, and
    # the pager cannot be disabled before _cmdline-mode on.
    if vars :comware_cmdline
      post_login do
        # HP V1910, V1920
        cmd '_cmdline-mode on', /(#{@node.prompt}|Continue)/
        cmd 'y', /(#{@node.prompt}|input password)/
        cmd vars(:comware_cmdline)

        # HP V1950
        cmd 'xtd-cli-mode on', /(#{@node.prompt}|Continue)/
        cmd 'y', /(#{@node.prompt}|input password)/
        cmd vars(:comware_cmdline)
      end
    end

    post_login do
      cmd 'screen-length disable'
      cmd 'undo terminal monitor'
    end
    pre_logout 'quit'
  end

  cmd 'display version' do |cfg|
    cfg = cfg.each_line.reject { |l| l.match /uptime/i }.join
    comment cfg
  end

  cmd 'display device' do |cfg|
    comment cfg
  end

  cmd 'display device manuinfo' do |cfg|
    cfg = cfg.each_line.reject { |l| l.match 'FF'.hex.chr }.join
    comment cfg
  end

  cmd 'display current-configuration' do |cfg|
    cfg
  end
end
berilslv commented 5 years ago

I ran into the same problem with current master comware model and HP 1910/1920 switches. First issue with the same problem seems to be #1447 These 19x0 units are tricky and cause very funky stuff with using 'send' Here a snippet of writeshark telnet tcp stream with current master comware.rb and it explains how 'send' commands get input/output/prompts totally messed up:

Username:oxidizeduser
oxidizeduser
Password:oxidizedpass

<hp1910switch>_cmdline-mode on
_y
512900
xtd-cli-mode on
y
512900
screen-length disable
.cmdline-mode on
All commands can be displayed and executed. Continue? [Y/N]y
Please input password:******
Warning: Now you enter an all-command mode for developer's testing, some commands may affect operation by wrong use, please carefully use it with our engineer's direction.
<hp1910switch>xundo terminal monitor
.td-cli-mode on
                     ^
 % Unrecognized command found at '^' position.
<hp1910switch>ydisplay version
.
                     ^
 % Unrecognized command found at '^' position.
<hp1910switch>display device
.512900
                     ^
 % Unrecognized command found at '^' position.
<hp1910switch>sdisplay device manuinfo
.creen-length disableundo terminal monitor
                                   ^
 % Unrecognized command found at '^' position.
<hp1910switch>ddisplay current-configuration
.isplay version
HPE Comware Platform Software
Comware Software, Version 5.20.99, Release 1113
Copyright (c) 2010-2016 Hewlett Packard Enterprise Development LP
HPE 1910-24 Switch uptime is 127 weeks, 5 days, 11 hours, 55 minutes

HPE 1910-24 Switch
128M    bytes DRAM
32M     bytes Flash Memory
Config Register points to Flash

Hardware Version is REV.A
Bootrom Version is 117
[SubSlot 0] 24FE+2GE Combo Hardware Version is REV.A

<hp1910switch>dquit
isplay device

After struggling with this I achieved not the prettiest but working model, which successfully works with the following units on telnet and ssh input:

  • HPE 1910-24 Switch
  • HPE 1920-8G Switch
  • HPE 5820X-24XG-SFP+ Switch with 2 Processors
  • MSR954 JH299A
  • Switch 4200G 24-Port Software Version 3Com OS V3.02.04s56
  • Switch 4210G 24-Port Software Version 5.20 Release 2202P18 I don't have 1950 unit, but I expect it to work too...

Here's my current comware.rb. Instead of 'send' I use 'cmd' with additional prompt regex.

class Comware < Oxidized::Model
  # HP (A-series)/H3C/3Com Comware

  # sometimes the prompt might have a leading nul or trailing ASCII Bell (^G)
  prompt /^\0*(<[\w.-]+>).*$/
  comment '# '

  # example how to handle pager
  # expect /^\s*---- More ----$/ do |data, re|
  #  send ' '
  #  data.sub re, ''
  # end

  cmd :all do |cfg|
    # cfg.gsub! /^.*\e\[42D/, ''        # example how to handle pager
    # skip rogue ^M
    cfg = cfg.delete "\r"
    cfg.cut_both
  end

  cmd :secret do |cfg|
    cfg.gsub! /^( snmp-agent community).*/, '\\1 <configuration removed>'
    cfg.gsub! /^( password hash).*/, '\\1 <configuration removed>'
    cfg.gsub! /^( password cipher).*/, '\\1 <configuration removed>'
    cfg
  end

  cfg :telnet do
    username /^(Username|login):/
    password /^Password:/
  end

  cfg :telnet, :ssh do
    # enable command-line mode on SMB comware switches (HP V1910, V1920)
    # autodetection is hard, because the 'summary' command is paged, and
    # the pager cannot be disabled before _cmdline-mode on.
    if vars :comware_cmdline
      post_login do
        # HP V1910, V1920
        cmd '_cmdline-mode on', /(#{@node.prompt}|Continue)/
        cmd 'y', /(#{@node.prompt}|input password)/
        cmd vars(:comware_cmdline)

        # HP V1950
        cmd 'xtd-cli-mode on', /(#{@node.prompt}|Continue)/
        cmd 'y', /(#{@node.prompt}|input password)/
        cmd vars(:comware_cmdline)
      end
    end

    post_login do
      cmd 'screen-length disable'
      cmd 'undo terminal monitor'
    end
    pre_logout 'quit'
  end

  cmd 'display version' do |cfg|
    cfg = cfg.each_line.reject { |l| l.match /uptime/i }.join
    comment cfg
  end

  cmd 'display device' do |cfg|
    comment cfg
  end

  cmd 'display device manuinfo' do |cfg|
    cfg = cfg.each_line.reject { |l| l.match 'FF'.hex.chr }.join
    comment cfg
  end

  cmd 'display current-configuration' do |cfg|
    cfg
  end
end

Thanks mate for your great answer! I hope this will help for somebody, as i have migrated to different IT structure! ;)