netfishers-onl / Netshot

Network Configuration and Compliance Management
http://www.netfishers.onl/netshot
246 stars 59 forks source link

Changes aren't applied #9

Closed orgitnized closed 6 years ago

orgitnized commented 6 years ago

Hi - I have issues associated with this command:

function run(cli, device) {
    cli.macro("configure");
    cli.command("default terminal length");
    cli.command("terminal length 35");
    cli.macro("end");
    cli.macro("save");
}

Reproducing the problem has gone like this:

  1. Connect to the switches (I can reproduce on the ERS48XX and ERS35XX series)
  2. Configure terminal length 0
  3. Now run the script above

The values for the length will not change. Even if I simply use terminal length 35 and leave the default terminal length statement out. Script runs as expected and reports success, but the value never changes on the switch and stays at terminal length 0.

SCadilhac commented 6 years ago

Hello, Could you run the commands manually on a device and copy/paste the full outputs here? Apart from the Run command script, is the device properly discovered, and the configuration properly retrieved by Netshot?

orgitnized commented 6 years ago

Yep, other commands work perfectly and the device is properly discovered. I can reproduce this on every 35XX and 48XX series device I have. Here's the output from every switch that takes the command:

mdf-stk-1(config)#terminal length ?
  <0-132>  Set number of lines on a screen
mdf-stk-1(config)#terminal length 35 ?
  <cr>

mdf-stk-1(config)#terminal length 35
mdf-stk-1(config)#show run
! Embedded ASCII Configuration Generator Script
! Base model = Ethernet Routing Switch 3549GTS-PWR+
! Base Software version = v5.3.5.009
!Stack Base Unit = 1
! Stack info:
!Unit# Switch Model     Pluggable Pluggable Pluggable Pluggable SW Version
!                         Port      Port      Port      Port
!----- ---------------- --------- --------- --------- --------- ----------
!1     3549GTS-PWR+     (47) None (48) None (49) Dir.           v5.3.5.009
!2     3549GTS-PWR+     (47) None (48) None (49) None           v5.3.5.009
!3     3549GTS-PWR+     (47) None (48) None (49) None           v5.3.5.009
!4     3549GTS-PWR+     (47) None (48) None (49) None           v5.3.5.009
!5     3549GTS-PWR+     (47) None (48) None (49) None           v5.3.5.009
!
! Displaying only parameters different to default
!================================================
enable
configure terminal
!
! *** CORE ***
!
no autosave enable
sntp server primary address 1.1.1.1
sntp server secondary address 1.1.1.2
sntp enable
terminal width 132
terminal length 35
orgitnized commented 6 years ago

It's really strange...I can do terminal width commands and they change as expected. But terminal length commands simply do not work.

SCadilhac commented 6 years ago

To capture the exchanges between the Netshot Avaya driver and the switch itself, you can follow this procedure:

On the server, edit the Netshot configuration file, e.g. /etc/netshot.conf, and add the following line: netshot.log.class.onl.netfishers.netshot.device.access.Cli = ALL

Then restart Netshot: #service netshot restart

Run the command script again and capture the output of /var/log/netshot/netshot.log.

Once done, rollback the change on the configuration file, as you don't want to run in full debugging mode the rest of the time.

orgitnized commented 6 years ago

Here we go!

This is the command that was sent via netshot

function run(cli, device) {
    cli.macro("configure");
    cli.command("default terminal width");
    cli.command("terminal width 132");
    cli.command("default terminal length");
    cli.command("terminal length 35");
    cli.macro("end");
    cli.macro("save");
}
2018-03-29 18:57:34,753 WARN  [main] DeviceDriver: Skipping Netshot device driver file /usr/local/netshot/netshot.jar, because a similar driver is already loaded.
2018-03-29 18:58:41,358 DEBUG [QuartzScheduler_Worker-1] Cli: Command to send: ''.
2018-03-29 18:58:41,359 DEBUG [QuartzScheduler_Worker-1] Cli: Received data '

This system is for the use of authorized users only.  Unauthorized
use is prohibited.  Individuals using this system are subject to
having all of their activities on this system monitored and recorded.
Auditing of users may include keystroke monitoring.  Any individual
who uses this system expressly consents to such monitoring and is
advised that information about their use of the system may be
provided to law enforcement or other authorities if evidence of
criminal or other unauthorized activity is found.

Enter Ctrl-Y to begin.

  ***************************************************************
  *** Ethernet Routing Switch 4850GTS-PWR+                    ***
  *** Avaya                                                   ***
  *** Copyright (c) 1996-2015,  All Rights Reserved           ***
  ***                                                         ***
  *** HW:12       FW:5.8.0.1   SW:v5.9.2.047                  ***
  ***************************************************************'.
2018-03-29 18:58:41,366 DEBUG [QuartzScheduler_Worker-1] Cli: Command to send: ''.
2018-03-29 18:58:41,487 DEBUG [QuartzScheduler_Worker-1] Cli: Received data '

             Last login: THU 2018-03-29 18:50:45
             Failed retries since last login:  0

Press ENTER to continue

'.
'.18-03-29 18:58:41,489 DEBUG [QuartzScheduler_Worker-1] Cli: Command to send: '
2018-03-29 18:58:41,610 DEBUG [QuartzScheduler_Worker-1] Cli: Received data '

khs-mdf-sw-4#'.
'.18-03-29 18:58:41,615 DEBUG [QuartzScheduler_Worker-1] Cli: Command to send: 'configure terminal
2018-03-29 18:58:41,740 DEBUG [QuartzScheduler_Worker-1] Cli: Received data 'configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
'.
2018-03-29 18:58:41,829 DEBUG [QuartzScheduler_Worker-1] Cli: Received data 'khs-mdf-sw-4(config)#'.
'.18-03-29 18:58:41,866 DEBUG [QuartzScheduler_Worker-1] Cli: Command to send: 'default terminal width
2018-03-29 18:58:41,982 DEBUG [QuartzScheduler_Worker-1] Cli: Received data 'default terminal width
'.
2018-03-29 18:58:42,078 DEBUG [QuartzScheduler_Worker-1] Cli: Received data 'khs-mdf-sw-4(config)#'.
'.18-03-29 18:58:42,088 DEBUG [QuartzScheduler_Worker-1] Cli: Command to send: 'terminal width 132
2018-03-29 18:58:42,205 DEBUG [QuartzScheduler_Worker-1] Cli: Received data 'terminal width 132
'.
2018-03-29 18:58:42,312 DEBUG [QuartzScheduler_Worker-1] Cli: Received data 'khs-mdf-sw-4(config)#'.
'.18-03-29 18:58:42,314 DEBUG [QuartzScheduler_Worker-1] Cli: Command to send: 'default terminal length
2018-03-29 18:58:42,432 DEBUG [QuartzScheduler_Worker-1] Cli: Received data 'default terminal length
'.
2018-03-29 18:58:42,538 DEBUG [QuartzScheduler_Worker-1] Cli: Received data 'khs-mdf-sw-4(config)#'.
'.18-03-29 18:58:42,539 DEBUG [QuartzScheduler_Worker-1] Cli: Command to send: 'terminal length 35
2018-03-29 18:58:42,656 DEBUG [QuartzScheduler_Worker-1] Cli: Received data 'terminal length 35
'.
2018-03-29 18:58:42,758 DEBUG [QuartzScheduler_Worker-1] Cli: Received data 'khs-mdf-sw-4(config)#'.
'.18-03-29 18:58:42,760 DEBUG [QuartzScheduler_Worker-1] Cli: Command to send: 'end
2018-03-29 18:58:42,880 DEBUG [QuartzScheduler_Worker-1] Cli: Received data 'end
'.
2018-03-29 18:58:42,979 DEBUG [QuartzScheduler_Worker-1] Cli: Received data 'khs-mdf-sw-4#'.
'.18-03-29 18:58:43,009 DEBUG [QuartzScheduler_Worker-1] Cli: Command to send: 'terminal length 0
2018-03-29 18:58:43,129 DEBUG [QuartzScheduler_Worker-1] Cli: Received data 'terminal length 0
'.
2018-03-29 18:58:43,228 DEBUG [QuartzScheduler_Worker-1] Cli: Received data 'khs-mdf-sw-4#'.
'.18-03-29 18:58:43,231 DEBUG [QuartzScheduler_Worker-1] Cli: Command to send: 'write memory
2018-03-29 18:58:43,352 DEBUG [QuartzScheduler_Worker-1] Cli: Received data 'write memory
'.
2018-03-29 18:59:07,210 DEBUG [QuartzScheduler_Worker-1] Cli: Received data 'khs-mdf-sw-4#'.
'.18-03-29 18:59:07,214 DEBUG [QuartzScheduler_Worker-1] Cli: Command to send: 'terminal length 0
2018-03-29 18:59:07,332 DEBUG [QuartzScheduler_Worker-1] Cli: Received data 'terminal length 0
'.
2018-03-29 18:59:07,435 DEBUG [QuartzScheduler_Worker-1] Cli: Received data 'khs-mdf-sw-4#'.
$
SCadilhac commented 6 years ago

Hello,

The Avaya driver in Netshot automatically sends terminal length 0 to the device each time it goes to exec enable mode. I suspect terminal length typed in exec mode (not in config mode) still changes the configuration... I don't have an Avaya device accessible right now, can you double-check? If this is the case, just move your cli.command("terminal length 35"); after cli.macro("end");.

orgitnized commented 6 years ago

I'm sorry for the delay in responding. Here's what I ran as a task:

function run(cli, device) {
    cli.macro("configure");
    cli.command("default terminal length");
    cli.command("default terminal width");
    cli.macro("end");
        cli.command("terminal length 35");
        cli.command("terminal width 132");
    cli.macro("save");
}

The task runs as a SUCCESS When I connect to the stack, the configuration is still wrong. Here's what it shows:

khs-idf1-stk-1#show terminal
Terminal speed: 9600
Terminal width: 132
Terminal length: 0 (pagination disabled)
SCadilhac commented 6 years ago

Netshot will disable the pager (terminal length 0) again after running the macro. You can try to move cli.command("terminal length 35"); after cli.macro("save");.

orgitnized commented 6 years ago

Got it - that does the trick, thanks!