Juniper switch: Netmiko not sending "commit" while device has "commit confirmed" configured #3676
-
I've developed a juniper configuration tool using Netmiko that allows remediation to happen in 4 stages: staging, commit confirmed, device reachability checks and finally a commit option. I'm having issues with "net_connect.commit()" when a device has a commit confirmed set. When I send the net_connect.commit() I get the following output:
When I send the "net_connect.commit()" the script doesn't actually end up sending a commit, instead it reports "Commit failed with the following errors:
Every time 'enter' is sent the first line (what netmiko interprets as the base prompt) is "# commit confirmed will be rolled back in {x} minute(s)". I've tried sending a commit via net_connect.send_command("commit") and net_connect.send_command("commit", expect_string=r".# commit confirmed will be rolled back in \d+ minute(s)? ." but that doesn't work because of the amount of time it takes to commit a juniper stack. I also tried "net_connect.base_prompt = r".# commit confirmed will be rolled back in \d+ minute(s)? ." then a net_connect.commit() with no luck. Anyone have any ideas on how to get around this? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Probably something like: # Clear out any data in the SSH channel
net_connect.read_channel()
# Set read_timeout to be long enough for the commit to complete plus some buffer
net_connect.send_command("commit", expect_string=r"switch11#", read_timeout=180) Let me know if that works or if you are still seeing issues. |
Beta Was this translation helpful? Give feedback.
-
That worked! I ended up using the hostname of the device as the expect string, worked great. Thank you!
|
Beta Was this translation helpful? Give feedback.
Probably something like:
Let me know if that works or if you are still seeing issues.