ktbyers / netmiko

Multi-vendor library to simplify Paramiko SSH connections to network devices
MIT License
3.59k stars 1.3k forks source link

prompt not stripped on some hp procurve switches #1699

Closed sliddjur closed 4 years ago

sliddjur commented 4 years ago

For instance, the show lldp info remote device does not strip the prompt from the command. This causes some headache when using textfsm.

Here is log from lldp = con_procurve.send_command("show lldp info remote-device")

DEBUG:netmiko:In strip_ansi_escape_codes
DEBUG:netmiko:repr = ''
DEBUG:netmiko:Stripping ANSI escape codes
DEBUG:netmiko:new_output = 
DEBUG:netmiko:repr = ''
DEBUG:netmiko:read_channel: 
DEBUG:netmiko:write_channel: b'\n'
DEBUG:netmiko:In strip_ansi_escape_codes
DEBUG:netmiko:repr = '\x1b[1;0H\x1b[1M\x1b[24;1H\x1b[1L\x1b[24;31H\x1b[24;1H\x1b[2K\x1b[24;1H\x1b[?25h\x1b[24;1H\x1b[1;24r\x1b[24;1H\x1b[1;24r\x1b[24;1H\x1b[24;1H\x1b[2K\x1b[24;1H\x1b[?25h\x1b[24;1H\x1b[24;1H65432p-swi009-warehouse-1etg# \x1b[24;1H\x1b[24;31H\x1b[24;1H\x1b[?25h\x1b[24;31H'
DEBUG:netmiko:Stripping ANSI escape codes
DEBUG:netmiko:new_output = 65432p-swi009-warehouse-1etg# 
DEBUG:netmiko:repr = '65432p-swi009-warehouse-1etg# '
DEBUG:netmiko:read_channel: 65432p-swi009-warehouse-1etg# 
DEBUG:netmiko:In strip_ansi_escape_codes
DEBUG:netmiko:repr = ''
DEBUG:netmiko:Stripping ANSI escape codes
DEBUG:netmiko:new_output = 
DEBUG:netmiko:repr = ''
DEBUG:netmiko:read_channel: 
DEBUG:netmiko:[find_prompt()]: prompt is 65432p-swi009-warehouse-1etg#
DEBUG:netmiko:In strip_ansi_escape_codes
DEBUG:netmiko:repr = ''
DEBUG:netmiko:Stripping ANSI escape codes
DEBUG:netmiko:new_output = 
DEBUG:netmiko:repr = ''
DEBUG:netmiko:read_channel: 
DEBUG:netmiko:write_channel: b'show lldp info remote-device\n'
DEBUG:netmiko:Pattern is: show\ lldp\ info\ remote\-device
DEBUG:netmiko:In strip_ansi_escape_codes
DEBUG:netmiko:repr = '\x1b[24;31Hshow lldp \x1b[24;31H\x1b[?25h\x1b[24;41H\x1b[24;41Hinfo remot\x1b[24;41H\x1b[?25h\x1b[24;51H\x1b[24;51He-device\x1b[24;51H\x1b[?25h\x1b[24;59H\x1b[1;0H\x1b[1M\x1b[24;1H\x1b[1L\x1b[24;59H\x1b[24;1H\x1b[2K\x1b[24;1H\x1b[?25h\x1b[24;1H\x1b[1;24r\x1b[24;1H\r\n LLDP Remote Devices Information\r\n\r\n'
DEBUG:netmiko:Stripping ANSI escape codes
DEBUG:netmiko:new_output = show lldp info remote-device
 LLDP Remote Devices Information

DEBUG:netmiko:repr = 'show lldp info remote-device\r\n LLDP Remote Devices Information\r\n\r\n'
DEBUG:netmiko:_read_channel_expect read_data: show lldp info remote-device
 LLDP Remote Devices Information

DEBUG:netmiko:Pattern found: show\ lldp\ info\ remote\-device show lldp info remote-device
 LLDP Remote Devices Information

DEBUG:netmiko:In strip_ansi_escape_codes
DEBUG:netmiko:repr = '  LocalPort | ChassisId          PortId             PortDescr SysName           \r\n  --------- + ------------------ ------------------ --------- ------------------\r\n  24        | 3821c7-c13940      36                 36        65432p-swi001     \r\n \r\n\r\n\x1b[1;24r\x1b[24;1H\x1b[24;1H\x1b[2K\x1b[24;1H\x1b[?25h\x1b[24;1H\x1b[24;1H65432p-swi009-warehouse-1etg# \x1b[24;1H\x1b[24;31H\x1b[24;1H\x1b[?25h\x1b[24;31H'
DEBUG:netmiko:Stripping ANSI escape codes
DEBUG:netmiko:new_output =   LocalPort | ChassisId          PortId             PortDescr SysName           
  --------- + ------------------ ------------------ --------- ------------------
  24        | 3821c7-c13940      36                 36        65432p-swi001     

65432p-swi009-warehouse-1etg# 
DEBUG:netmiko:repr = '  LocalPort | ChassisId          PortId             PortDescr SysName           \r\n  --------- + ------------------ ------------------ --------- ------------------\r\n  24        | 3821c7-c13940      36                 36        65432p-swi001     \r\n \r\n\r\n65432p-swi009-warehouse-1etg# '
DEBUG:netmiko:read_channel:   LocalPort | ChassisId          PortId             PortDescr SysName           
  --------- + ------------------ ------------------ --------- ------------------
  24        | 3821c7-c13940      36                 36        65432p-swi001     

65432p-swi009-warehouse-1etg# 

And the output:

pprint(lldp)                                                                                                                                                     
('LLDP Remote Devices Information\n'
 '\n'
 '  LocalPort | ChassisId          PortId             PortDescr '
 'SysName           \n'
 '  --------- + ------------------ ------------------ --------- '
 '------------------\n'
 '  20        | b00cd1-c69b02      b0 0c d1 c6 9b '
 '02                              \n'
 '  24        | 3821c7-c13940      36                 36        '
 '65432-swi001     \n'
 ' \n')
ktbyers commented 4 years ago

@sliddjur What is the issue? Your output looks correct:


  LocalPort | ChassisId          PortId             PortDescr SysName           
  --------- + ------------------ ------------------ --------- ------------------
  20        | b00cd1-c69b02      b0 0c d1 c6 9b 02                              
  24        | 3821c7-c13940      36                 36        65432-swi001     

Note, you are pretty printing the output (on a string) which makes it harder to read.

sliddjur commented 4 years ago

Yes I missed it on that log. It seems it only happens on some cases. I was able to reproduce it once, but that time I didn't have logging on. I restart my session with logging on, and then the prompt was stripped. Same device, same commands.

ktbyers commented 4 years ago

Okay, yeah would need to capture a log-file for me to help much. You could try increasing global_delay_factor and set it 2 or 4 (in case it is a timing issue). This sounds possible/likely given what you have described.

sliddjur commented 4 years ago

I dont know if this perhaps is related to stripping prompts. But occasionally when running a script on my devices I get error.

DEBUG:netmiko:new_output = logoutDo you want to log out (y/n)? 
DEBUG:netmiko:repr = 'logoutDo you want to log out (y/n)? '
DEBUG:netmiko:read_channel: logoutDo you want to log out (y/n)? 
DEBUG:netmiko:write_channel: b'y\n'
DEBUG:netmiko:In strip_ansi_escape_codes
DEBUG:netmiko:repr = '\x1b[24;31Hy\x1b[24;31H\x1b[?25h\x1b[24;32H\x1b[1;0H\x1b[1M\x1b[24;1H\x1b[1L\x1b[24;32H\x1b[24;1H\x1b[2K\x1b[24;1H\x1b[?25h\x1b[24;1H\x1b[1;24r\x1b[24;1H\x1b[2J\x1b[?7h\x1b[1;24r\x1b[?6l\x1b[24;1H\x1b[?25h\x1b[24;1H\x1b[?6l\x1b[1;0r\x1b[?7h\x1b[2J\x1b[24;1H\x1b[1;1H\x1b[2K\x1b[24;1H'
DEBUG:netmiko:Stripping ANSI escape codes
DEBUG:netmiko:new_output = y[?7h[?7h
DEBUG:netmiko:repr = 'y\x1b[2J\x1b[?7h\x1b[?7h\x1b[2J'
DEBUG:netmiko:read_channel: y[?7h[?7h
DEBUG:netmiko:write_channel: b'\n'
DEBUG:paramiko.transport:[chan 0] EOF received (0)
DEBUG:paramiko.transport:[chan 0] EOF sent (0)
DEBUG:netmiko:In strip_ansi_escape_codes
DEBUG:netmiko:repr = ''
DEBUG:netmiko:Stripping ANSI escape codes
DEBUG:netmiko:new_output = 
DEBUG:netmiko:repr = ''
DEBUG:netmiko:read_channel: 
DEBUG:paramiko.transport:starting thread (client mode): 0x94690460
DEBUG:paramiko.transport:Local version/idstring: SSH-2.0-paramiko_2.7.1
DEBUG:paramiko.transport:EOF in transport thread
DEBUG:paramiko.transport:Remote version/idstring: SSH-2.0-Mocana SSH 6.3
INFO:paramiko.transport:Connected (version 2.0, client Mocana)
DEBUG:paramiko.transport:kex algos:['diffie-hellman-group14-sha1'] server key:['ssh-rsa'] client encrypt:['aes256-ctr', 'aes256-cbc', 'rijndael-cbc@lysator.liu.se', 'aes192-ctr', 'aes192-cbc', 'aes128-ctr', 'aes128-cbc', '3des-cbc'] server encrypt:['aes256-ctr', 'aes256-cbc', 'rijndael-cbc@lysator.liu.se', 'aes192-ctr', 'aes192-cbc', 'aes128-ctr', 'aes128-cbc', '3des-cbc'] client mac:['hmac-sha1-96', 'hmac-md5', 'hmac-sha1', 'hmac-md5-96'] server mac:['hmac-sha1-96', 'hmac-md5', 'hmac-sha1', 'hmac-md5-96'] client compress:['none'] server compress:['none'] client lang:[''] server lang:[''] kex follows?False
DEBUG:paramiko.transport:Kex agreed: diffie-hellman-group14-sha1
DEBUG:paramiko.transport:HostKey agreed: ssh-rsa
DEBUG:paramiko.transport:Cipher agreed: aes128-ctr
DEBUG:paramiko.transport:MAC agreed: hmac-sha1
DEBUG:paramiko.transport:Compression agreed: none
DEBUG:paramiko.transport:kex engine KexGroup14 specified hash_algo <built-in function openssl_sha1>
DEBUG:paramiko.transport:Switch to new keys ...
DEBUG:paramiko.transport:Adding ssh-rsa host key for 65432p-swi004.custghjprovan.lan: b'8a009f5f27e6f8bc0a0741533299daf4'
DEBUG:paramiko.transport:userauth is OK
INFO:paramiko.transport:Auth banner: b"We'd like to keep you up to date about:\n  * Software feature updates\n  * New product announcements\n  * Special events\nPlease register your products now at:  www.hpe.com/networking/register\n\n\n"
INFO:paramiko.transport:Authentication (password) successful!
DEBUG:paramiko.transport:[chan 0] Max packet in: 32768 bytes
DEBUG:paramiko.transport:[chan 0] Max packet out: 32768 bytes
DEBUG:paramiko.transport:Secsh channel 0 opened.
DEBUG:paramiko.transport:[chan 0] Sesch channel 0 request ok
DEBUG:paramiko.transport:[chan 0] Sesch channel 0 request ok
DEBUG:netmiko:read_channel: 
DEBUG:netmiko:read_channel: Aruba JL357A 2540-48G-PoE+-4SFP+ Switch

Software revision YC.16.07.0003

 (C) Copyright 2018 Hewlett Packard Enterprise Development LP

                      RESTRICTED RIGHTS LEGEND
 Confidential computer software. Valid license from Hewlett Packard Enterprise
 Development LP required for possession, use or copying. Consistent with FAR
 12.211 and 12.212, Commercial Computer Software, Computer Software
 Documentation, and Technical Data for Commercial Items are licensed to the
 U.S. Government under vendor's standard commercial license.


DEBUG:netmiko:read_channel: Press any key to continue[?25h
DEBUG:netmiko:write_channel: b'\n'
DEBUG:netmiko:write_channel: b'\n'
DEBUG:netmiko:In strip_ansi_escape_codes
DEBUG:netmiko:repr = '\x1b[?6l\x1b[1;24r\x1b[?7h\x1b[2J\x1b[1;1H\x1b[1920;1920H\x1b[6n\x1b[1;1HYour previous successful login (as manager) was on 1990-08-05 21:04:14     \r\n from 123.123.123.194\r\n\x1b[1;24r\x1b[24;1H\x1b[24;1H\x1b[2K\x1b[24;1H\x1b[?25h\x1b[24;1H\x1b[24;1H65432p-swi004-new-office-2etg# \x1b[24;1H\x1b[24;32H\x1b[24;1H\x1b[?25h\x1b[24;32H'
DEBUG:netmiko:Stripping ANSI escape codes
DEBUG:netmiko:new_output = [?7hYour previous successful login (as manager) was on 1990-08-05 21:04:14     
 from 123.123.123.194
65432p-swi004-new-office-2etg# 
DEBUG:netmiko:repr = '\x1b[?7h\x1b[2JYour previous successful login (as manager) was on 1990-08-05 21:04:14     \r\n from 123.123.123.194\r\n65432p-swi004-new-office-2etg# '
DEBUG:netmiko:read_channel: [?7hYour previous successful login (as manager) was on 1990-08-05 21:04:14     
 from 123.123.123.194
65432p-swi004-new-office-2etg# 
DEBUG:netmiko:In strip_ansi_escape_codes
DEBUG:netmiko:repr = ''
DEBUG:netmiko:Stripping ANSI escape codes
DEBUG:netmiko:new_output = 
DEBUG:netmiko:repr = ''
DEBUG:netmiko:read_channel: 
DEBUG:netmiko:In strip_ansi_escape_codes
DEBUG:netmiko:repr = ''
DEBUG:netmiko:Stripping ANSI escape codes
DEBUG:netmiko:new_output = 
DEBUG:netmiko:repr = ''
DEBUG:netmiko:read_channel: 
DEBUG:netmiko:In strip_ansi_escape_codes
DEBUG:netmiko:repr = ''
DEBUG:netmiko:Stripping ANSI escape codes
DEBUG:netmiko:new_output = 
DEBUG:netmiko:repr = ''
DEBUG:netmiko:read_channel: 
DEBUG:netmiko:write_channel: b'\n'
DEBUG:netmiko:In strip_ansi_escape_codes
DEBUG:netmiko:repr = '\x1b[1;0H\x1b[1M\x1b[24;1H\x1b[1L\x1b[24;32H\x1b[24;1H\x1b[2K\x1b[24;1H\x1b[?25h\x1b[24;1H\x1b[1;24r\x1b[24;1H\x1b[1;24r\x1b[24;1H\x1b[24;1H\x1b[2K\x1b[24;1H\x1b[?25h\x1b[24;1H\x1b[24;1H65432p-swi004-new-office-2etg# \x1b[24;1H\x1b[24;32H\x1b[24;1H\x1b[?25h\x1b[24;32H\x1b[1;0H\x1b[1M\x1b[24;1H\x1b[1L\x1b[24;32H\x1b[24;1H\x1b[2K\x1b[24;1H\x1b[?25h\x1b[24;1H\x1b[1;24r\x1b[24;1H\x1b[1;24r\x1b[24;1H\x1b[24;1H\x1b[2K\x1b[24;1H\x1b[?25h\x1b[24;1H\x1b[24;1H65432p-swi004-new-office-2etg# \x1b[24;1H\x1b[24;32H\x1b[24;1H\x1b[?25h\x1b[24;32H'
DEBUG:netmiko:Stripping ANSI escape codes
DEBUG:netmiko:new_output = 65432p-swi004-new-office-2etg# 65432p-swi004-new-office-2etg# 
DEBUG:netmiko:repr = '65432p-swi004-new-office-2etg# 65432p-swi004-new-office-2etg# '
DEBUG:netmiko:read_channel: 65432p-swi004-new-office-2etg# 65432p-swi004-new-office-2etg# 
DEBUG:netmiko:In strip_ansi_escape_codes
DEBUG:netmiko:repr = ''
DEBUG:netmiko:Stripping ANSI escape codes
DEBUG:netmiko:new_output = 
DEBUG:netmiko:repr = ''
DEBUG:netmiko:read_channel: 
DEBUG:netmiko:[find_prompt()]: prompt is 65432p-swi004-new-office-2etg# 65432p-swi004-new-office-2etg#
DEBUG:netmiko:In strip_ansi_escape_codes
DEBUG:netmiko:repr = ''
DEBUG:netmiko:Stripping ANSI escape codes
DEBUG:netmiko:new_output = 
DEBUG:netmiko:repr = ''
DEBUG:netmiko:read_channel: 
DEBUG:netmiko:In disable_paging
DEBUG:netmiko:Command: 
no page

DEBUG:netmiko:write_channel: b'\nno page\n'
DEBUG:netmiko:Pattern is: no\ page
DEBUG:netmiko:In strip_ansi_escape_codes
DEBUG:netmiko:repr = '\x1b[1;0H\x1b[1M\x1b[24;1H\x1b[1L\x1b[24;32H\x1b[24;1H\x1b[2K\x1b[24;1H\x1b[?25h\x1b[24;1H\x1b[1;24r\x1b[24;1H\x1b[1;24r\x1b[24;1H\x1b[24;1H\x1b[2K\x1b[24;1H\x1b[?25h\x1b[24;1H\x1b[24;1H65432p-swi004-new-office-2etg# \x1b[24;1H\x1b[24;32H\x1b[24;1H\x1b[?25h\x1b[24;32H\x1b[24;32Hno page\x1b[24;32H\x1b[?25h\x1b[24;39H\x1b[1;0H\x1b[1M\x1b[24;1H\x1b[1L\x1b[24;39H\x1b[24;1H\x1b[2K\x1b[24;1H\x1b[?25h\x1b[24;1H\x1b[1;24r\x1b[24;1H\x1b[1;24r\x1b[24;1H\x1b[24;1H\x1b[2K\x1b[24;1H\x1b[?25h\x1b[24;1H\x1b[24;1H65432p-swi004-new-office-2etg# \x1b[24;1H\x1b[24;32H\x1b[24;1H\x1b[?25h\x1b[24;32H'
DEBUG:netmiko:Stripping ANSI escape codes
DEBUG:netmiko:new_output = 65432p-swi004-new-office-2etg# no page65432p-swi004-new-office-2etg# 
DEBUG:netmiko:repr = '65432p-swi004-new-office-2etg# no page65432p-swi004-new-office-2etg# '
DEBUG:netmiko:_read_channel_expect read_data: 65432p-swi004-new-office-2etg# no page65432p-swi004-new-office-2etg# 
DEBUG:netmiko:Pattern found: no\ page 65432p-swi004-new-office-2etg# no page65432p-swi004-new-office-2etg# 
DEBUG:netmiko:65432p-swi004-new-office-2etg# no page65432p-swi004-new-office-2etg# 
DEBUG:netmiko:Exiting disable_paging
DEBUG:netmiko:write_channel: b'terminal width 511\n'
DEBUG:netmiko:Pattern is: terminal\ width\ 511
DEBUG:netmiko:In strip_ansi_escape_codes
DEBUG:netmiko:repr = '\x1b[24;32Hterminal w\x1b[24;32H\x1b[?25h\x1b[24;42H\x1b[24;42Hidth 511\x1b[24;42H\x1b[?25h\x1b[24;50H\x1b[1;0H\x1b[1M\x1b[24;1H\x1b[1L\x1b[24;50H\x1b[24;1H\x1b[2K\x1b[24;1H\x1b[?25h\x1b[24;1H\x1b[1;24r\x1b[24;1H\x1b[2J\x1b[?7h\x1b[1;24r\x1b[?6l\x1b[24;1H\x1b[?25h\x1b[24;1H\x1b[?6l\x1b[1;24r\x1b[?7h\x1b[2J\x1b[24;1H\x1b[1;24r\x1b[24;1H\x1b[24;1H\x1b[2K\x1b[24;1H\x1b[?25h\x1b[24;1H\x1b[24;1H65432p-swi004-new-office-2etg# \x1b[24;1H\x1b[24;32H\x1b[24;1H\x1b[?25h\x1b[24;32H'
DEBUG:netmiko:Stripping ANSI escape codes
DEBUG:netmiko:new_output = terminal width 511[?7h[?7h65432p-swi004-new-office-2etg# 
DEBUG:netmiko:repr = 'terminal width 511\x1b[2J\x1b[?7h\x1b[?7h\x1b[2J65432p-swi004-new-office-2etg# '
DEBUG:netmiko:_read_channel_expect read_data: terminal width 511[?7h[?7h65432p-swi004-new-office-2etg# 
DEBUG:netmiko:Pattern found: terminal\ width\ 511 terminal width 511[?7h[?7h65432p-swi004-new-office-2etg# 
DEBUG:netmiko:In strip_ansi_escape_codes
DEBUG:netmiko:repr = ''
DEBUG:netmiko:Stripping ANSI escape codes
DEBUG:netmiko:new_output = 
DEBUG:netmiko:repr = ''
DEBUG:netmiko:read_channel: 
DEBUG:netmiko:In strip_ansi_escape_codes
DEBUG:netmiko:repr = ''
DEBUG:netmiko:Stripping ANSI escape codes
DEBUG:netmiko:new_output = 
DEBUG:netmiko:repr = ''
DEBUG:netmiko:read_channel: 
DEBUG:netmiko:write_channel: b'\n'
DEBUG:netmiko:In strip_ansi_escape_codes
DEBUG:netmiko:repr = ''
DEBUG:netmiko:Stripping ANSI escape codes
DEBUG:netmiko:new_output = 
DEBUG:netmiko:repr = ''
DEBUG:netmiko:read_channel: 
DEBUG:netmiko:In strip_ansi_escape_codes
DEBUG:netmiko:repr = ''
DEBUG:netmiko:Stripping ANSI escape codes
DEBUG:netmiko:new_output = 
DEBUG:netmiko:repr = ''
DEBUG:netmiko:read_channel: 
DEBUG:netmiko:write_channel: b'\n'
DEBUG:netmiko:In strip_ansi_escape_codes
DEBUG:netmiko:repr = '\x1b[1;0H\x1b[1M\x1b[24;1H\x1b[1L\x1b[24;32H\x1b[24;1H\x1b[2K\x1b[24;1H\x1b[?25h\x1b[24;1H\x1b[1;24r\x1b[24;1H\x1b[1;24r\x1b[24;1H\x1b[24;1H\x1b[2K\x1b[24;1H\x1b[?25h\x1b[24;1H\x1b[24;1H65432p-swi004-new-office-2etg# \x1b[24;1H\x1b[24;32H\x1b[24;1H\x1b[?25h\x1b[24;32H\x1b[1;0H\x1b[1M\x1b[24;1H\x1b[1L\x1b[24;32H\x1b[24;1H\x1b[2K\x1b[24;1H\x1b[?25h\x1b[24;1H\x1b[1;24r\x1b[24;1H\x1b[1;24r\x1b[24;1H\x1b[24;1H\x1b[2K\x1b[24;1H\x1b[?25h\x1b[24;1H\x1b[24;1H65432p-swi004-new-office-2etg# \x1b[24;1H\x1b[24;32H\x1b[24;1H\x1b[?25h\x1b[24;32H'
DEBUG:netmiko:Stripping ANSI escape codes
DEBUG:netmiko:new_output = 65432p-swi004-new-office-2etg# 65432p-swi004-new-office-2etg# 
DEBUG:netmiko:repr = '65432p-swi004-new-office-2etg# 65432p-swi004-new-office-2etg# '
DEBUG:netmiko:read_channel: 65432p-swi004-new-office-2etg# 65432p-swi004-new-office-2etg# 
DEBUG:netmiko:In strip_ansi_escape_codes
DEBUG:netmiko:repr = ''
DEBUG:netmiko:Stripping ANSI escape codes
DEBUG:netmiko:new_output = 
DEBUG:netmiko:repr = ''
DEBUG:netmiko:read_channel: 
DEBUG:netmiko:[find_prompt()]: prompt is 65432p-swi004-new-office-2etg# 65432p-swi004-new-office-2etg#
DEBUG:netmiko:In strip_ansi_escape_codes
DEBUG:netmiko:repr = ''
DEBUG:netmiko:Stripping ANSI escape codes
DEBUG:netmiko:new_output = 
DEBUG:netmiko:repr = ''
DEBUG:netmiko:read_channel: 
DEBUG:netmiko:write_channel: b'show lldp info remote-device\n'
DEBUG:netmiko:Pattern is: show\ lldp\ info\ remote\-device
DEBUG:netmiko:In strip_ansi_escape_codes
DEBUG:netmiko:repr = '\x1b[24;32Hshow lldp \x1b[24;32H\x1b[?25h\x1b[24;42H\x1b[24;42Hinfo remot\x1b[24;42H\x1b[?25h\x1b[24;52H\x1b[24;52He-device\x1b[24;52H\x1b[?25h\x1b[24;60H\x1b[1;0H\x1b[1M\x1b[24;1H\x1b[1L\x1b[24;60H\x1b[24;1H\x1b[2K\x1b[24;1H\x1b[?25h\x1b[24;1H\x1b[1;24r\x1b[24;1H\r\n LLDP Remote Devices Information\r\n\r\n'
DEBUG:netmiko:Stripping ANSI escape codes
DEBUG:netmiko:new_output = show lldp info remote-device
 LLDP Remote Devices Information

DEBUG:netmiko:repr = 'show lldp info remote-device\r\n LLDP Remote Devices Information\r\n\r\n'
DEBUG:netmiko:_read_channel_expect read_data: show lldp info remote-device
 LLDP Remote Devices Information

DEBUG:netmiko:Pattern found: show\ lldp\ info\ remote\-device show lldp info remote-device
 LLDP Remote Devices Information

DEBUG:netmiko:In strip_ansi_escape_codes
DEBUG:netmiko:repr = '  LocalPort | ChassisId          PortId             PortDescr SysName           \r\n  --------- + ------------------ ------------------ --------- ------------------\r\n  3         | bcf310-21d980      mgt0                         AH-cust-AP37      \r\n  5         | bcf310-21b640      mgt0                         AH-cust-AP32      \r\n  12        | a81e84-503d61      a8 1e 84 50 3d 61                              \r\n  25        | 9829a6-813eb7      98 29 a6 81 3e b7                              \r\n  26        | 192.168.130.98     50 67 ae ec 69 eb  Port 1    Cisco IP Phone ...\r\n  27        | 6c0b84-244ce9      6c 0b 84 24 4c e9                              \r\n  31        | 6c0b84-b61a66      6c 0b 84 b6 1a 66                              \r\n  52        | 3821c7-bf5380      52                 52        65432p-swi003-l...\r\n \r\n\r\n\x1b[1;24r\x1b[24;1H\x1b[24;1H\x1b[2K\x1b[24;1H\x1b[?25h\x1b[24;1H\x1b[24;1H65432p-swi004-new-office-2etg# \x1b[24;1H\x1b[24;32H\x1b[24;1H\x1b[?25h\x1b[24;32H'
DEBUG:netmiko:Stripping ANSI escape codes
DEBUG:netmiko:new_output =   LocalPort | ChassisId          PortId             PortDescr SysName           
  --------- + ------------------ ------------------ --------- ------------------
  3         | bcf310-21d980      mgt0                         AH-cust-AP37      
  5         | bcf310-21b640      mgt0                         AH-cust-AP32      
  12        | a81e84-503d61      a8 1e 84 50 3d 61                              
  25        | 9829a6-813eb7      98 29 a6 81 3e b7                              
  26        | 192.168.130.98     50 67 ae ec 69 eb  Port 1    Cisco IP Phone ...
  27        | 6c0b84-244ce9      6c 0b 84 24 4c e9                              
  31        | 6c0b84-b61a66      6c 0b 84 b6 1a 66                              
  52        | 3821c7-bf5380      52                 52        65432p-swi003-l...

65432p-swi004-new-office-2etg# 
DEBUG:netmiko:repr = '  LocalPort | ChassisId          PortId             PortDescr SysName           \r\n  --------- + ------------------ ------------------ --------- ------------------\r\n  3         | bcf310-21d980      mgt0                         AH-cust-AP37      \r\n  5         | bcf310-21b640      mgt0                         AH-cust-AP32      \r\n  12        | a81e84-503d61      a8 1e 84 50 3d 61                              \r\n  25        | 9829a6-813eb7      98 29 a6 81 3e b7                              \r\n  26        | 192.168.130.98     50 67 ae ec 69 eb  Port 1    Cisco IP Phone ...\r\n  27        | 6c0b84-244ce9      6c 0b 84 24 4c e9                              \r\n  31        | 6c0b84-b61a66      6c 0b 84 b6 1a 66                              \r\n  52        | 3821c7-bf5380      52                 52        65432p-swi003-l...\r\n \r\n\r\n65432p-swi004-new-office-2etg# '
DEBUG:netmiko:read_channel:   LocalPort | ChassisId          PortId             PortDescr SysName           
  --------- + ------------------ ------------------ --------- ------------------
  3         | bcf310-21d980      mgt0                         AH-cust-AP37      
  5         | bcf310-21b640      mgt0                         AH-cust-AP32      
  12        | a81e84-503d61      a8 1e 84 50 3d 61                              
  25        | 9829a6-813eb7      98 29 a6 81 3e b7                              
  26        | 192.168.130.98     50 67 ae ec 69 eb  Port 1    Cisco IP Phone ...
  27        | 6c0b84-244ce9      6c 0b 84 24 4c e9                              
  31        | 6c0b84-b61a66      6c 0b 84 b6 1a 66                              
  52        | 3821c7-bf5380      52                 52        65432p-swi003-l...

65432p-swi004-new-office-2etg# 
DEBUG:netmiko:In strip_ansi_escape_codes
DEBUG:netmiko:repr = ''
DEBUG:netmiko:Stripping ANSI escape codes
DEBUG:netmiko:new_output = 
DEBUG:netmiko:repr = ''
DEBUG:netmiko:read_channel: 
DEBUG:netmiko:In strip_ansi_escape_codes
DEBUG:netmiko:repr = ''
DEBUG:netmiko:Stripping ANSI escape codes
DEBUG:netmiko:new_output = 
DEBUG:netmiko:repr = ''
DEBUG:netmiko:read_channel: 
DEBUG:netmiko:In strip_ansi_escape_codes
DEBUG:netmiko:repr = ''
DEBUG:netmiko:Stripping ANSI escape codes
DEBUG:netmiko:new_output = 
DEBUG:netmiko:repr = ''
DEBUG:netmiko:read_channel: 
DEBUG:netmiko:In strip_ansi_escape_codes
DEBUG:netmiko:repr = ''
DEBUG:netmiko:Stripping ANSI escape codes
DEBUG:netmiko:new_output = 
DEBUG:netmiko:repr = ''
DEBUG:netmiko:read_channel: 
DEBUG:netmiko:In strip_ansi_escape_codes
DEBUG:netmiko:repr = ''
DEBUG:netmiko:Stripping ANSI escape codes
DEBUG:netmiko:new_output = 
DEBUG:netmiko:repr = ''
DEBUG:netmiko:read_channel: 
DEBUG:netmiko:In strip_ansi_escape_codes
DEBUG:netmiko:repr = ''
DEBUG:netmiko:Stripping ANSI escape codes
DEBUG:netmiko:new_output = 
DEBUG:netmiko:repr = ''
DEBUG:netmiko:read_channel: 
DEBUG:netmiko:In strip_ansi_escape_codes
DEBUG:netmiko:repr = ''
DEBUG:netmiko:Stripping ANSI escape codes
DEBUG:netmiko:new_output = 
DEBUG:netmiko:repr = ''
DEBUG:netmiko:read_channel: 
DEBUG:netmiko:In strip_ansi_escape_codes
DEBUG:netmiko:repr = ''
DEBUG:netmiko:Stripping ANSI escape codes
DEBUG:netmiko:new_output = 
DEBUG:netmiko:repr = ''
DEBUG:netmiko:read_channel: 
DEBUG:netmiko:In strip_ansi_escape_codes
DEBUG:netmiko:repr = ''
DEBUG:netmiko:Stripping ANSI escape codes
DEBUG:netmiko:new_output = 
DEBUG:netmiko:repr = ''
DEBUG:netmiko:read_channel: 
DEBUG:netmiko:In strip_ansi_escape_codes
DEBUG:netmiko:repr = ''
DEBUG:netmiko:Stripping ANSI escape codes
DEBUG:netmiko:new_output = 
DEBUG:netmiko:repr = ''
DEBUG:netmiko:read_channel: 
DEBUG:netmiko:In strip_ansi_escape_codes
DEBUG:netmiko:repr = ''
DEBUG:netmiko:Stripping ANSI escape codes
DEBUG:netmiko:new_output = 
DEBUG:netmiko:repr = ''
DEBUG:netmiko:read_channel: 
DEBUG:netmiko:In strip_ansi_escape_codes
DEBUG:netmiko:repr = ''
DEBUG:netmiko:Stripping ANSI escape codes
DEBUG:netmiko:new_output = 
DEBUG:netmiko:repr = ''
DEBUG:netmiko:read_channel: 
DEBUG:netmiko:In strip_ansi_escape_codes
DEBUG:netmiko:repr = ''
DEBUG:netmiko:Stripping ANSI escape codes
DEBUG:netmiko:new_output = 
DEBUG:netmiko:repr = ''
DEBUG:netmiko:read_channel: 
DEBUG:netmiko:In strip_ansi_escape_codes
DEBUG:netmiko:repr = ''
DEBUG:netmiko:Stripping ANSI escape codes
DEBUG:netmiko:new_output = 
DEBUG:netmiko:repr = ''
DEBUG:netmiko:read_channel: 
DEBUG:netmiko:In strip_ansi_escape_codes
DEBUG:netmiko:repr = ''
DEBUG:netmiko:Stripping ANSI escape codes
DEBUG:netmiko:new_output = 
DEBUG:netmiko:repr = ''
DEBUG:netmiko:read_channel: 
DEBUG:netmiko:In strip_ansi_escape_codes
DEBUG:netmiko:repr = ''
DEBUG:netmiko:Stripping ANSI escape codes
DEBUG:netmiko:new_output = 
DEBUG:netmiko:repr = ''
DEBUG:netmiko:read_channel: 
DEBUG:netmiko:In strip_ansi_escape_codes
DEBUG:netmiko:repr = ''
sliddjur commented 4 years ago

This is the error code I got in ipython3.8

I suppose it was from this part of my script. Which sometimes failed, but mostly succeeded. lldp = con_procurve.send_command("show lldp info remote-device", use_textfsm=True)

---------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
~/python-scripts/procurve/cust_tag_wifi_vlan.py in <module>
     36     # LLDP information in structured textfsm data dictionary.
     37     print(f"Getting LLDP and TRUNKS status")
---> 38     lldp = con_procurve.send_command("show lldp info remote-device", use_textfsm=True)
     39     #trunks = con_procurve.send_command("show trunks", use_textfsm=True)
     40     wifi_ints = []

~/.local/lib/python3.8/site-packages/netmiko/utilities.py in wrapper_decorator(self, *args, **kwargs)
    345         if self.global_cmd_verify is not None:
    346             kwargs["cmd_verify"] = self.global_cmd_verify
--> 347         return func(self, *args, **kwargs)
    348 
    349     return wrapper_decorator

~/.local/lib/python3.8/site-packages/netmiko/base_connection.py in send_command(self, command_string, expect_string, delay_factor, max_loops, auto_find_prompt, strip_prompt, strip_command, normalize, use_textfsm, textfsm_template, use_genie, cmd_verify)
   1426             new_data = self.read_channel()
   1427         else:  # nobreak
-> 1428             raise IOError(
   1429                 "Search pattern never detected in send_command_expect: {}".format(
   1430                     search_pattern

OSError: Search pattern never detected in send_command_expect: 65432p\-swi004\-new\-office\-2etg\#\ 65432p\-swi004\-new\-office\-2etg\#
ktbyers commented 4 years ago

So the issue here is this:

DEBUG:netmiko:[find_prompt()]: prompt is 65432p-swi004-new-office-2etg# 65432p-swi004-new-office-2etg#

It came back with the prompt twice instead of once (on the find_prompt call)

And strangely with no newline/enter between the prompts.

Probably easiest fix is to explicitly terminate the command using expect_string:

lldp = con_procurve.send_command("show lldp info remote-device", expect_string=r"#")

It is going to be hard to fix if HP doesn't put an enter between the prompt. I guess we could also try global_delay_factor=2 (or 4) and slowing down the SSH session.

ktbyers commented 4 years ago

Updated fix here:

https://github.com/ktbyers/netmiko/pull/1827

Most of the work done by @brasswood (as it is based on his original PR)

ktbyers commented 4 years ago

Should be fixed in #1827