question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

timing issue with find_prompt on Palo Alto - netmiko 1.0.0

See original GitHub issue

[Summary: in netmiko v1.0.0 need to set delay_factor in paloalto_panos_ssh.py to 7 from the current value of 3 to get it to work with Palo Altos as it did with netmiko v0.5.6]

All was fine connecting to my Palo Alto 5060 with 0.5.6, but with 1.0.0 I get:

Traceback (most recent call last):
  File "/home/fav/get_arp_tables.py", line 241, in <module>
    net_connect = ConnectHandler(**dev)
  File "/home/fav/anaconda3/lib/python3.5/site-packages/netmiko/ssh_dispatcher.py", line 94, in ConnectHandler
    return ConnectionClass(*args, **kwargs)
  File "/home/fav/anaconda3/lib/python3.5/site-packages/netmiko/base_connection.py", line 89, in __init__
    self.session_preparation()
  File "/home/fav/anaconda3/lib/python3.5/site-packages/netmiko/paloalto/paloalto_panos_ssh.py", line 21, in session_preparation
    self.set_base_prompt(delay_factor=3)
  File "/home/fav/anaconda3/lib/python3.5/site-packages/netmiko/base_connection.py", line 478, in set_base_prompt
    raise ValueError("Router prompt not found: {0}".format(prompt))
ValueError: Router prompt not found: Welcome root.

The Palo Alto returns the following on login:

Last login: Thu Oct  6 11:58:08 2016 from x.y.z
Welcome root.

root@fw(active)> 

Turning on debugging in find_prompt() in base_connection.py (extra debugging prompt4 and “end of prompt” added by me - prompt4 is the result after processing multi-line response) I get:

prompt1: 
^^^^^ end of prompt1 ^^^^^
prompt2a: 'Welcome root.'
^^^^^ end of prompt2a ^^^^^
prompt2b: Welcome root.
^^^^^ end of prompt2b ^^^^^
prompt3: Welcome root.
^^^^^ end of prompt3 ^^^^^
prompt4: Welcome root. 
^^^^^ end of prompt4 ^^^^^
Traceback (most recent call last):
  File "test_netmiko.py", line 7, in <module>
    net_connect = ConnectHandler(**dev)
  File "/home/fav/anaconda3/lib/python3.5/site-packages/netmiko/ssh_dispatcher.py", line 94, in ConnectHandler
    return ConnectionClass(*args, **kwargs)
  File "/home/fav/anaconda3/lib/python3.5/site-packages/netmiko/base_connection.py", line 89, in __init__
    self.session_preparation()
  File "/home/fav/anaconda3/lib/python3.5/site-packages/netmiko/paloalto/paloalto_panos_ssh.py", line 23, in session_preparation
    self.set_base_prompt(delay_factor=3)
  File "/home/fav/anaconda3/lib/python3.5/site-packages/netmiko/base_connection.py", line 478, in set_base_prompt
    raise ValueError("Router prompt not found: {0}".format(prompt))
ValueError: Router prompt not found: Welcome root.

So despite sending a newline in find_prompt(), it doesn’t get past seeing “Welcome root” as the response.

If I change the value of delay_factor in paloalto_panos_ssh.py from 3 to 4 it works, but only by sending multiple newlines in find_prompt:

prompt1: 
^^^^^ end of prompt1 ^^^^^
prompt2a: 'Welcome root.\r\n\r\nroot@fw(active)> \r\nroot@fw(active)> \r\nroot@fw(active)>'
^^^^^ end of prompt2a ^^^^^
prompt2b: Welcome root.

root@fw(active)> 
root@fw(active)> 
root@fw(active)>
^^^^^ end of prompt2b ^^^^^
prompt3: Welcome root.

root@fw(active)> 
root@fw(active)> 
root@fw(active)>
^^^^^ end of prompt3 ^^^^^
prompt4: root@fw(active)>
^^^^^ end of prompt4 ^^^^^

If I increase delay_factor to 7, then it works as expected (and as similar debugging shows it does with netmiko v0.5.6), getting all of the initial prompt lines without having to send more than one newline in find_prompt():

prompt1: Welcome root.

root@fw(active)> 
root@fw(active)>
^^^^^ end of prompt1 ^^^^^
prompt3: Welcome root.

root@fw(active)> 
root@fw(active)>
^^^^^ end of prompt3 ^^^^^
prompt4: root@fw(active)>
^^^^^ end of prompt4 ^^^^^

Hope this helps, and many thanks for the module,

Mark

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
ktbyerscommented, Oct 16, 2016

Okay, made this change in dev_1_1 branch:

https://github.com/ktbyers/netmiko/commit/891fc42f1d7f1ca51d8790a617bdd80dd71b0a56

That results in a 2 second delay which isn’t that long.

Can either of you test the dev_1_1 branch and see if this fixes it? @mcfone @GGabriele

0reactions
ktbyerscommented, Oct 17, 2016

Okay, I am going to close this issue.

If you see problems in the future, just open a new issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Netmiko output blank - LIVEcommunity - 509264
Solved: Hi, I run Netmiko for bulk packet captures in AWS. It works well but there is never output when using the Palo...
Read more >
netmiko.paloalto.paloalto_panos API documentation
Implement methods for interacting with PaloAlto devices. ... :param global_delay_factor: Multiplication factor affecting Netmiko delays (default: 1).
Read more >
netmiko -> PAN OS - stops at config mode - Stack Overflow
send_config_set() is expecting a Python list of commands, not a single string. The command is entering configuration mode, and sending each ...
Read more >
Netmiko - Cortex Marketplace
Palo Alto Networks is not liable for and does not warrant or support any content pack produced by a third-party Publisher, whether or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found