Open nathaniel-mills opened 2 years ago
Can you capture the log output and post it here:
You can obscure anything in the log that is confidential to your environment.
Thanks,
Please see attached file: test.log
@nathaniel-mills Does it work if you do?
from netmiko import ConnectHandler
print("Connecting to Palo Alto to show clock")
virtual_palo = {
'device_type': 'paloalto_panos',
'host': '192.168.1.100',
'username': 'automationadmin',
'password': 'ciscothenpalo123',
}
net_connect = ConnectHandler(**virtual_palo)
output = net_connect.send_command('show clock', expect_string=r"#")
print(output)
print("Connecting to Cisco Switch to show clock")
Note, I added the expect_string argument to the send_command()
call.
So 😄 ... It didn't work as per your tweak, however it does work with:
output = net_connect.send_command('show clock', expect_string=r">")
print(output)
Or:
output = net_connect.send_command_timing('show clock')
print(output)
My colleague just pointed out a gap of lines before and after the actual time when jumping in on the CLI:
automationadmin@ip-192-168-1-100> show clock
Thu Jul 21 00:57:10 PDT 2022
automationadmin@ip-192-168-1-100> exit
I think the expect string is a good "fix". I guess I just misunderstood the exact workings of the command. By the way last question if I may. What would be the ideal expect string to look out for in my case?
The expect_string should probably be the trailing character for the prompt:
So in the log file you posted earlier:
LON-CGH-SWA-041#
You would use a r"#"
.
In the device above, you would use a r">"
.
If you have a mix of devices that use either a #
or >
then probably a regex like: r"[>#]"
would work.
This really shouldn't have been required i.e. it means there is something still going wrong in Netmiko, but the above will potentially work as a workaround.
Thanks a bunch for this. The switch was Cisco which ends with the #
, however above that in the logs the Palo Alto ends with the >
. I'll definitely settle with the workaround and I suppose a future release may address this long term.
Thanks again!
Current workarounds:
output = net_connect.send_command('show clock', expect_string=r">")
print(output)
Or:
output = net_connect.send_command_timing('show clock')
print(output)
I am going to re-open this issue (as it does indicate there is an underlying Netmiko bug which should be fixed).
Hi for me also below one worked
output = net_connect.send_command('show clock', expect_string=r">") print(output)
expect_string=r">"
seem to solve everything in regards to palo alto issues and netmiko
Hello ! I've tried the workaround on our PaloAlto while in config mode, but it does not seem to work. current_peer_address = net_connect.send_command("show network ike gateway GW-Test peer-address", expect_string=r"#")
Any idea on it? In the Logs I see that the command has sucessfully run but my variable current_peer_address keeps being empty. The trailing character for the prompt while in config mode is "#".
@SecretSkills01 You probably need to post your Netmiko session_log and a broader section of your code.
Hi,
I run Netmiko for bulk packet captures in AWS. It works well but there is never output when using the Palo Alto (paloalto_panos) device type. Output for Cisco works well. An example would be:
This is just an example by the way, I don't run the scripts to show the clock :-). The output would be:
You see the issue. By the way this is my Netmiko version:
PAN-OS:
Any help would be great thanks.