Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pipe breaking the output from A10 Thunder #3493

Open
andreirapuru opened this issue Sep 2, 2024 · 4 comments
Open

Pipe breaking the output from A10 Thunder #3493

andreirapuru opened this issue Sep 2, 2024 · 4 comments

Comments

@andreirapuru
Copy link

Hello,
I am sending commands (send_command_timing) to an A10 Thunder to collect some information, using ConnectHandler and the device template below.

device_template = {
'device_type': 'a10',
'host': '172.16.0.8',
'username': UN,
'password': PW,
'port':22,
'secret': EN,
'blocking_timeout': 3 #Default = 8, if timeout problem increase to 16
}

When I use the command "show run slb virtual-server | in port", it works as expected.
However, when I use the command "show run slb virtual-server IP_ADDRESS | in port", the output becomes messy.

Logs from the example that is working:
DEBUG:netmiko:write_channel: b'sh run slb virtual-server | in port\n'
DEBUG:netmiko:read_channel: sh run slb virtual-server | in port
port 22 tcp
port 80 tcp
port 443 tcp

Logs from the example that is NOT working:
DEBUG:netmiko:write_channel: b'sh run slb virtual-server 201.151.135.7 | in port\n'
DEBUG:netmiko:read_channel: sh run slb virtual-server 201.151.135.7���������������������������������������$ virtual-server 201.151.135.7 �����������������������������������������$ virtual-server 201.151.135.7 | �����������������������������������������$ virtual-server 201.151.135.7 | �����������������������������������������$ virtual-server 201.151.135.7 | i �����������������������������������������$ virtual-server 201.151.135.7 | in �����������������������������������������$ virtual-server 201.151.135.7 | in �����������������������������������������$ virtual-server 201.151.135.7 | in p �����������������������������������������$ virtual-server 201.151.135.7 | in po �����������������������������������������$ virtual-server 201.151.135.7 | in por �����������������������������������������$ virtual-server 201.151.135.7 | in port �
port 22 tcp
port 80 tcp
port 443 tcp
port 8080 tcp

Netmiko version

netmiko==4.1.2

Netmiko device_type (if relevant to the issue)

a10

Steps to Reproduce the Issue

Using net_connect.send_command_timing('sh run slb virtual-server 201.151.135.7 | in port').

Error Traceback

DEBUG:netmiko:write_channel: b'sh run slb virtual-server 201.151.135.7 | in port\n'
DEBUG:netmiko:read_channel: sh run slb virtual-server 201.151.135.7���������������������������������������$ virtual-server 201.151.135.7           �����������������������������������������$ virtual-server 201.151.135.7 |         �����������������������������������������$ virtual-server 201.151.135.7 |         �����������������������������������������$ virtual-server 201.151.135.7 | i       �����������������������������������������$ virtual-server 201.151.135.7 | in      �����������������������������������������$ virtual-server 201.151.135.7 | in      �����������������������������������������$ virtual-server 201.151.135.7 | in p    �����������������������������������������$ virtual-server 201.151.135.7 | in po   �����������������������������������������$ virtual-server 201.151.135.7 | in por  �����������������������������������������$ virtual-server 201.151.135.7 | in port �
  port 22 tcp 
  port 80 tcp 
  port 443 tcp 
  port 8080 tcp 

Relevant Python code

(Please try to essentialize your Python code to the minimum code needed to reproduce the issue)
(Paste the code between the quotes below)

show_vserver = net_connect.send_command_timing('sh run slb virtual-server ' + vserver + ' | in port')
print('Portas configuradas no IP Público ' + vserver + '\n')
@ktbyers
Copy link
Owner

ktbyers commented Sep 17, 2024

Try setting ansi_escape_codes = True

net_connect.ansi_escape_codes = True

After you have established the Netmiko connection.

Also you probably need to upgrade to a newer version of Netmiko (at least to regression test and see if you see the same problem there).

@andreirapuru
Copy link
Author

Thanks Kirk, but same result with escape codes = true and netmiko version 4.4

@ktbyers
Copy link
Owner

ktbyers commented Sep 18, 2024

@andreirapuru Okay, strange...

Try not using the | in port and just parse the output in Python (i.e. search for the "port" string on the Python side).

It looks to me like some sort of terminal width issue is going on which is causing the output to get distorted (which is then causing you problems).

@andreirapuru
Copy link
Author

Yes, thanks @ktbyers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants