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 SMB switch #236

Closed agustinguayama closed 6 years ago

agustinguayama commented 8 years ago

Hi guys! I'm having trouble with a Comware SMB switch. It's a HP V1910-24G. The system connects just fine to the switch, but it seems that it's not using the '_cmdline-mode on' command. All I got when I look at the config is this:

#          ^
#  % Unrecognized command found at '^' position.
#          ^
#  % Unrecognized command found at '^' position.
         ^
 % Unrecognized command found at '^' position.

I've been trying to debug the comware gem, but I'm useless with this and I don't want to quit this awesome tool just for not being able to solve a problem with one of my devices. Could anybody throw me a hand here?

ytti commented 8 years ago

Hopefully @erJasp @sid3windr or @nickhilliard have some clue, I don't have access to any Comware box

erJasp commented 8 years ago

@ujemvi Have you provided the unlock password with the comware_cmdline variable? What happens when you connect to the switch (with the same user as configured in oxidized), run _cmdline-mode on and provide the unlock password?

Can you post the debug log of the telnet/SSH session?

admlko commented 8 years ago

I had the same problem and here's what's going on: First, the prompt doesn't work with the default hostaname <HP 1920G Switch>

So I modified comware.rb file from: prompt /^\0*(<[\w.-]+>)$/ to allow whitespaces prompt /^\0*(<[\w\s.-]+>)$/

Then the problem with unrecognized command: The problem only exists when using Telnet, SSH seems to work just fine. With Telnet, I noticed that post_login 'screen-length disable' post_login 'undo terminal monitor

commands were executed without newline, and that was causing the unrecognized command error: <HP 1920G Switch>screen-length disableundo terminal monitor ^ % Unrecognized command found at '^' position. <HP 1920G Switch>display version Sorry for the arrow position, it should be pointing to the beginning of disableundo

I was able to work around it by adding extra post_login '' after both commands but hey, that's pretty damn ugly.

If someone has an idea how to fix this behavior, that would be just great!

danilopopeye commented 7 years ago

as per #637 comment changing the prompt should fix this.

sau70networkadmin commented 6 years ago

I am using ssh, but getting the same (I think) error:

#                    ^
#  % Unrecognized command found at '^' position.
#                    ^
#  % Unrecognized command found at '^' position.
                   ^
 % Unrecognized command found at '^' position.

I changed the switch's hostname to not include spaces and reverted the change I made to the prompt, but no dice. I've also tried disabling ssh and falling back to telnet. I'm stuck. @admlko Could you please post your sanitized config + modded comware.rb files somewhere I can see them? Thanks!

admlko commented 6 years ago

This is currently my comware.rb: https://privatebin.net/?0a52e8d7456e8748#J0+6Z6c7LvPrvhM3z1hu9oZ8nXelBaL3/pvRe8bbRmw=

No idea how it differs from upstream version, haven't had time to check it as it works for now.

sau70networkadmin commented 6 years ago

Thank you, I think mine's the same but I will try with yours! Also, here is my config:

username: manager
password: seekrit
model: procurve
interval: 600
log: ~/.config/oxidized/log
debug: false
threads: 30
timeout: 20
retries: 3
prompt: !ruby/regexp /^([\w.@-]+[#>]\s?)$/
rest: 0.0.0.0:8787
next_adds_job: false
vars: 
  enable: superseekrit
  remove_secret: true
groups: {}
models: {}
pid: /home/oxidized/.config/oxidized/pid
input:
  default: ssh, telnet
  debug: true
  ssh:
    secure: false
output:
  file:
    directory: /home/oxidized/deviceconfigs
source:
  default: csv
  csv:
    file: /home/oxidized/.config/oxidized/router.db
    delimiter: !ruby/regexp /:/
    map:
      name: 0
      model: 1
      username: 2
      password: 3
    vars_map:
      enable: 4
model_map:
  cisco: ios
  juniper: junos
models:
  comware:
    vars_map:
      comware_cmdline: 6

and here's my router.db:

10.2.0.26:comware:admin:superseekrit:512900

Have I messed those up? How do yours compare?

THANK YOU again!

-- MB

sau70networkadmin commented 6 years ago

(bump) -- @admlko I beg of you, could you please post your sanitized config + a sanitized line for a 1920 from your router.db? I changed my comware_cmdline: to 512900 because now I think I see where the model sends that, but no help. The node says

{:name=>"10.2.0.26",
 :full_name=>"10.2.0.26",
 :ip=>"10.2.0.26",
 :group=>nil,
 :model=>"Comware",
 :last=>
  {:start=>2017-11-17 16:39:16 UTC,
   :end=>2017-11-17 16:39:22 UTC,
   :status=>:success,
   :time=>6.834662489},
 :vars=>{:enable=>nil}}

and this is what I see in the debug log:

[oxidized@woody oxidized]$ cat logs/10.2.0.26-ssh 

******************************************************************************
* Copyright (c) 2010-2015 Hewlett-Packard Development Company, L.P.          *
* Without the owner's prior written consent,                                 *
* no decompiling or reverse-engineering shall be allowed.                    *
******************************************************************************

<HP-1910-26>screen-length disable
            ^
 % Unrecognized command found at '^' position.
<HP-1910-26>
<HP-1910-26>undo terminal monitor
            ^
 % Unrecognized command found at '^' position.
<HP-1910-26>
<HP-1910-26>display version
            ^
 % Unrecognized command found at '^' position.
<HP-1910-26>display device
            ^
 % Unrecognized command found at '^' position.
<HP-1910-26>display current-configuration
            ^
 % Unrecognized command found at '^' position.

I'm sure there's something boneheaded I've done in the config, but I'm so stumped. I'd be eternally grateful for help. Thanks!

-- MB

admlko commented 6 years ago

LOL, sure, gotta help a brother out!

Here's my config starting from input:

input:
  default: ssh, telnet
  debug: false
  ssh:
    secure: false
output:
  default: git
  git:
    user: Oxidized
    email: oxidized@oxidized.intra.tld
    repo: "~/var/lib/oxidized/git-repos/devices.git"
source:
  default: csv
  csv:
    file: "~/.config/oxidized/router.db"
    delimiter: !ruby/regexp /:/
    map:
      group: 0
      name: 1
      model: 2
      username: 3
      password: 4
    vars_map:
      enable: 5
      ssh_proxy: 6
      comware_cmdline: 7

In router.db, I have declared the hosts like this: group:devicename:model:user:pwd:enablepwd:sshproxy:<optional_enable_for_hp19xx>

BTW, if I read your config corrently, you have mapped your things wrongly. Your config says:

    map:
      name: 0
      model: 1
      username: 2
      password: 3
    vars_map:
      enable: 4
models:
  comware:
    vars_map:
      comware_cmdline: 6

But you declare host like this: 10.2.0.26:comware:admin:superseekrit:512900

So your name would be index 0, so 10.2.0.26, model comware, username admin, password superseekrit, enable 512900. But should this be the comware_cmdline? Maybe.

sau70networkadmin commented 6 years ago

@admlko You are a GOD AMONG MEN. Email me the dot bates at gmail and I will send you something for your trouble. You were right, it was the mapping. Mine now looks like

    map:
      name: 0
      model: 1
      username: 2
      password: 3
    vars_map:
      enable: 4
      comware_cmdline: 5

and the relevant line in router.db is

10.2.0.26:comware:admin:superseekrit:superseekrit:512900 Note that I needed to put the enable password in there TWICE...I don't have an operator password on these, and depending on the config, normal ProCurve gear lets you straight in as enable, which is how all my other entries were like...just the single password, both to connect AND to enable. These are different, obviously.

THANK YOU VERY MUCH! :)