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

Wrong command for Comware 1950 device #2083

Closed oh01 closed 1 year ago

oh01 commented 4 years ago

Hello, the command that unlocks the full CLI is wrong for HP 1950 devices (at least on firmware 7.1.070 Release 3208P03 and higher). Currently the command line in comware..rb is as follows:

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

Instead it should have been something like this:

# HP V1950
cmd 'xtd-cli-mode', /(#{@node.prompt}|extended CLI mode)/
cmd 'y', /(#{@node.prompt}|Password)/

The sequence on 1950 switch looks like this:

<HPA-1950switch>xtd-cli-mode
All commands can be displayed and executed in extended CLI mode. Switch to extended CLI mode? [Y/N]:y
Password:
Warning: Extended CLI mode is intended for developers to test the system. Before using commands in extended CLI mode, contact the Technical Support and make sure you know the potential impact on the device and the network.
<HPA-1950switch>

After I've changed the command as descriped above in my /var/lib/gems/2.5.0/gems/oxidized-0.27.0/lib/oxidized/model/comware.rb it started working again.

wk commented 4 years ago

Simply changing this could break older versions for some users (presuming the original variation was the correct one for devices up to a certain version). Could you test if including this variation as a 3rd block results in a working configuration for you?

      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)

        # HP V1950 > 7.1.070 Release 3208P03
        cmd 'xtd-cli-mode', /(#{@node.prompt}|extended CLI mode)/
        cmd 'y', /(#{@node.prompt}|Password)/
        cmd vars(:comware_cmdline)
      end
oh01 commented 4 years ago

Hello, I haven't tried it but this won't work, because you are expecting "Continue" and "input password" strings which are not used in my version. That's why I replaced them with "extended CLI mode" and "Password" in my workaround and also shared the sequence when logging in by hand to show why. Thank you.

wk commented 4 years ago

Hi!

It seems in haste, I've misidentified the scope of the change to be primarily the exclusion of the on suffix in the command xtd-cli-mode on. I've now adjusted the example above to reflect your suggested change, but kept the 3-block version.

The goal here is to reach a situation where the model works both on your device, as well as on other devices which expect different variations. If you can confirm this variation succeeds on your device, I'll create a PR to modify the model.

a83r commented 3 years ago

Hi, we are running a JG960A - HPE 1950 24G 2SFP+ 2XGT Switch - HPE Comware Software, Version 7.1.070, Release 3506P11 oxidized version is 0.28 When I try to get the config with these "updated" Blocks my Configexport looks like this:

^

% Unrecognized command found at '^' position.

^

% Unrecognized command found at '^' position.

^

% Unrecognized command found at '^' position.

               ^

% Unrecognized command found at '^' position.

When I manually excecute the commands from the comware Models file everything works as expected. Could some help me with the issue?

D, [2021-09-08T11:49:10.864544 #19695] DEBUG -- : lib/oxidized/job.rb: Starting fetching process for nd-swhpe1 at 2021-09-08 09:49:10 UTC D, [2021-09-08T11:49:10.865077 #19695] DEBUG -- : lib/oxidized/input/ssh.rb: Connecting to nd-swhpe1 D, [2021-09-08T11:49:10.865223 #19695] DEBUG -- : AUTH METHODS::["none", "publickey", "password"] D, [2021-09-08T11:49:11.517608 #19695] DEBUG -- : lib/oxidized/input/ssh.rb: expecting [/^\0(<[\w.-]+>).?$/] at nd-swhpe1 D, [2021-09-08T11:49:11.864624 #19695] DEBUG -- : lib/oxidized/worker.rb: 1 jobs running in parallel D, [2021-09-08T11:49:12.865001 #19695] DEBUG -- : lib/oxidized/worker.rb: 1 jobs running in parallel D, [2021-09-08T11:49:13.865236 #19695] DEBUG -- : lib/oxidized/worker.rb: 1 jobs running in parallel D, [2021-09-08T11:49:14.631734 #19695] DEBUG -- : lib/oxidized/input/cli.rb: Running post_login commands at nd-swhpe1 D, [2021-09-08T11:49:14.631995 #19695] DEBUG -- : lib/oxidized/input/cli.rb: Running post_login command: "screen-length disable", block: nil at nd-swhpe1 D, [2021-09-08T11:49:14.632016 #19695] DEBUG -- : lib/oxidized/input/ssh.rb screen-length disable @ nd-swhpe1 with expect: /^\0(<[\w.-]+>).?$/ D, [2021-09-08T11:49:14.632374 #19695] DEBUG -- : lib/oxidized/input/ssh.rb: expecting [/^\0(<[\w.-]+>).?$/] at nd-swhpe1 D, [2021-09-08T11:49:14.865444 #19695] DEBUG -- : lib/oxidized/worker.rb: 1 jobs running in parallel D, [2021-09-08T11:49:15.034963 #19695] DEBUG -- : lib/oxidized/input/cli.rb: Running post_login command: "undo terminal monitor", block: nil at nd-swhpe1 D, [2021-09-08T11:49:15.035196 #19695] DEBUG -- : lib/oxidized/input/ssh.rb undo terminal monitor @ nd-swhpe1 with expect: /^\0(<[\w.-]+>).?$/ D, [2021-09-08T11:49:15.035641 #19695] DEBUG -- : lib/oxidized/input/ssh.rb: expecting [/^\0(<[\w.-]+>).?$/] at nd-swhpe1 D, [2021-09-08T11:49:15.437643 #19695] DEBUG -- : lib/oxidized/model/model.rb Collecting commands' outputs D, [2021-09-08T11:49:15.437730 #19695] DEBUG -- : lib/oxidized/model/model.rb Executing display version D, [2021-09-08T11:49:15.437748 #19695] DEBUG -- : lib/oxidized/input/ssh.rb display version @ nd-swhpe1 with expect: /^\0(<[\w.-]+>).?$/ D, [2021-09-08T11:49:15.437890 #19695] DEBUG -- : lib/oxidized/input/ssh.rb: expecting [/^\0(<[\w.-]+>).?$/] at nd-swhpe1 D, [2021-09-08T11:49:15.840654 #19695] DEBUG -- : lib/oxidized/model/model.rb Executing display device D, [2021-09-08T11:49:15.840769 #19695] DEBUG -- : lib/oxidized/input/ssh.rb display device @ nd-swhpe1 with expect: /^\0(<[\w.-]+>).?$/ D, [2021-09-08T11:49:15.841082 #19695] DEBUG -- : lib/oxidized/input/ssh.rb: expecting [/^\0(<[\w.-]+>).?$/] at nd-swhpe1 D, [2021-09-08T11:49:15.865657 #19695] DEBUG -- : lib/oxidized/worker.rb: 1 jobs running in parallel D, [2021-09-08T11:49:16.243242 #19695] DEBUG -- : lib/oxidized/model/model.rb Executing display device manuinfo D, [2021-09-08T11:49:16.243601 #19695] DEBUG -- : lib/oxidized/input/ssh.rb display device manuinfo @ nd-swhpe1 with expect: /^\0(<[\w.-]+>).?$/ D, [2021-09-08T11:49:16.243976 #19695] DEBUG -- : lib/oxidized/input/ssh.rb: expecting [/^\0(<[\w.-]+>).?$/] at nd-swhpe1 D, [2021-09-08T11:49:16.645763 #19695] DEBUG -- : lib/oxidized/model/model.rb Executing display current-configuration D, [2021-09-08T11:49:16.646305 #19695] DEBUG -- : lib/oxidized/input/ssh.rb display current-configuration @ nd-swhpe1 with expect: /^\0(<[\w.-]+>).?$/ D, [2021-09-08T11:49:16.646705 #19695] DEBUG -- : lib/oxidized/input/ssh.rb: expecting [/^\0*(<[\w.-]+>).?$/] at nd-swhpe1 D, [2021-09-08T11:49:16.865859 #19695] DEBUG -- : lib/oxidized/worker.rb: 1 jobs running in parallel D, [2021-09-08T11:49:17.049017 #19695] DEBUG -- : lib/oxidized/input/cli.rb Running pre_logout commands at nd-swhpe1 D, [2021-09-08T11:49:17.049215 #19695] DEBUG -- : lib/oxidized/input/ssh.rb quit @ nd-swhpe1 with expect: nil D, [2021-09-08T11:49:17.106800 #19695] DEBUG -- : lib/oxidized/node.rb: Oxidized::SSH ran for nd-swhpe1 successfully D, [2021-09-08T11:49:17.106979 #19695] DEBUG -- : lib/oxidized/job.rb: Config fetched for nd-swhpe1 at 2021-09-08 09:49:17 UTC D, [2021-09-08T11:49:17.870197 #19695] DEBUG -- : lib/oxidized/worker.rb: Jobs running: 0 of 1 - ended: 1 of 1

a83r commented 3 years ago

My colleague did get it fixed, I'm not a Ruby Coding Expert. Here ist the working snippet from comware.rb

comware_snip.txt

mortzu commented 2 years ago

Please provide a PR