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 5 Issues Prompt #1620

Closed thrashlisaro closed 1 year ago

thrashlisaro commented 5 years ago

Switch Model : HPE 5800 - 24G Firmware + OS Version: Comware 5.20.105 Release 1810P01

Config model: comware interval: 3600 log: "/root/.config/oxidized/logs/oxidized.log" use_syslog: false debug: false threads: 30 timeout: 20 retries: 3 prompt: !ruby/regexp /^([\w.@-]+[#>]\s?)$/ rest: 0.0.0.0:8888 next_adds_job: false vars: {} groups: {comware}`

comware.rb

`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.gsub /\r/, ''
cfg.each_line.to_a[1..-2].join

end

cmd :secret do |cfg|

cfg.gsub! /^( snmp-agent community).*/, '\1 '

cfg.gsub! /^( password hash).*/, '\1 '

cfg

end

cfg :telnet do username /^Username:$/ 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
    send "_cmdline-mode on\n"
    send "y\n"
    send vars(:comware_cmdline) + "\n"
  end
end

post_login 'screen-length disable'
post_login 'undo terminal monitor'
pre_logout 'quit'

end

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

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

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

Snippet from device log

Users (authorised or unauthorised) have no explicit or implicit expectation^M of privacy. Any or all uses of this system may be subject to one or more of^M the following actions:^M interception, monitoring, recording, auditing, inspection and disclosure to^M security personnel.^M By using this system, the user consents to these actions.^M ****^M Press Y or ENTER to continue, N to exit.

oxidized.log W, [2018-11-07T10:42:37.293903 #22] WARN -- : /10.107.101.253 status no_connection, retry attempt 1 D, [2018-11-07T10:42:37.295140 #22] DEBUG -- : lib/oxidized/worker.rb: Added /10.107.101.253 to the job queue D, [2018-11-07T10:42:37.296173 #22] DEBUG -- : lib/oxidized/job.rb: Starting fetching process for 10.107.101.253 at 2018-11-07 10:42:37 UTC D, [2018-11-07T10:42:37.297711 #22] DEBUG -- : lib/oxidized/input/ssh.rb: Connecting to 10.107.101.253 D, [2018-11-07T10:42:37.299779 #22] DEBUG -- net.ssh.transport.session[18e2e9c]: establishing connection to 10.107.101.253:22 D, [2018-11-07T10:42:37.976382 #22] DEBUG -- : lib/oxidized/input/ssh.rb: expecting [/^\0(<[\w.-]+>).?$/] at 10.107.101.253 W, [2018-11-07T10:42:57.978399 #22] WARN -- : 10.107.101.253 raised Oxidized::PromptUndetect with msg " D, [2018-11-07T10:42:57.978649 #22] DEBUG -- : lib/oxidized/node.rb: Oxidized::SSH failed for 10.107.101.253 D, [2018-11-07T10:42:57.978909 #22] DEBUG -- : lib/oxidized/job.rb: Config fetched for 10.107.101.253 at 2018-11-07 10:42:57 UTC W, [2018-11-07T10:42:58.310239 #22] WARN -- : /10.107.101.253 status no_connection, retry attempt 2 D, [2018-11-07T10:42:58.310971 #22] DEBUG -- : lib/oxidized/worker.rb: Added /10.107.101.253 to the job queue D, [2018-11-07T10:42:58.311166 #22] DEBUG -- : lib/oxidized/job.rb: Starting fetching process for 10.107.101.253 at 2018-11-07 10:42:58 UTC D, [2018-11-07T10:42:58.311500 #22] DEBUG -- : lib/oxidized/input/ssh.rb: Connecting to 10.107.101.253 D, [2018-11-07T10:42:58.312353 #22] DEBUG -- net.ssh.transport.session[17b98e0]: establishing connection to 10.107.101.253:22 D, [2018-11-07T10:42:59.051363 #22] DEBUG -- : lib/oxidized/input/ssh.rb: expecting [/^\0(<[\w.-]+>).?$/] at 10.107.101.253 W, [2018-11-07T10:43:19.052933 #22] WARN -- : 10.107.101.253 raised Oxidized::PromptUndetect with msg " D, [2018-11-07T10:43:19.053179 #22] DEBUG -- : lib/oxidized/node.rb: Oxidized::SSH failed for 10.107.101.253 D, [2018-11-07T10:43:19.053427 #22] DEBUG -- : lib/oxidized/job.rb: Config fetched for 10.107.101.253 at 2018-11-07 10:43:19 UTC W, [2018-11-07T10:43:19.327048 #22] WARN -- : /10.107.101.253 status no_connection, retry attempt 3 D, [2018-11-07T10:43:19.328082 #22] DEBUG -- : lib/oxidized/worker.rb: Added /10.107.101.253 to the job queue D, [2018-11-07T10:43:19.328238 #22] DEBUG -- : lib/oxidized/job.rb: Starting fetching process for 10.107.101.253 at 2018-11-07 10:43:19 UTC D, [2018-11-07T10:43:19.329247 #22] DEBUG -- : lib/oxidized/input/ssh.rb: Connecting to 10.107.101.253 D, [2018-11-07T10:43:19.331505 #22] DEBUG -- net.ssh.transport.session[1405ba4]: establishing connection to 10.107.101.253:22 D, [2018-11-07T10:43:20.136731 #22] DEBUG -- : lib/oxidized/input/ssh.rb: expecting [/^\0*(<[\w.-]+>).?$/] at 10.107.101.253 W, [2018-11-07T10:43:40.138379 #22] WARN -- : 10.107.101.253 raised Oxidized::PromptUndetect with msg " D, [2018-11-07T10:43:40.138625 #22] DEBUG -- : lib/oxidized/node.rb: Oxidized::SSH failed for 10.107.101.253 D, [2018-11-07T10:43:40.138834 #22] DEBUG -- : lib/oxidized/job.rb: Config fetched for 10.107.101.253 at 2018-11-07 10:43:40 UTC W, [2018-11-07T10:43:40.342710 #22] WARN -- : /10.107.101.253 status no_connection, retries exhausted, giving up

We have oxidized working fine with our Comware 7 devices, but we are having the above issue when it comes to backing up our Comware 5 devices, I have implemented the solution suggested by your documentation -

info-center source default channel 1 log state off debug state off

and we still get the same result, any help or guidance would be much appreciated.

berilslv commented 5 years ago

Yeap, still facing the same for HP 1920v. Can't get config out of it. Can somebody point me direction to which i should look at? Getting simillar issue as author.

WiXZlo commented 5 years ago

I use vars_map. In config for hp1910

source:
  default: csv
  csv:
    file: ~/router.db
    delimiter: !ruby/regexp /:/
    map:
      name: 0
      model: 1
      ip: 2
      group: 3
      username: 4
      password: 5
    vars_map:
      enable: 6
      comware_cmdline: 6

In router.db

hpv1910-48g:comware:192.168.0.1:HP:admin:adminpassword:512900

For different models use different password for _cmdline-mode on

512900 (HP1910)
Jinhua1920unauthorized (HP1920)
berilslv commented 5 years ago

Thanks alot mate for the answer!