-
Notifications
You must be signed in to change notification settings - Fork 556
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
Fixes #1512 - Adds Commit Confirm support to IOS #1538
Conversation
I will try to review and test this in the next 2 to 3 weeks. |
I see there are some black errors, I can go ahead and fix those up. |
Perhaps @Kircheneer could you give this a once over? |
napalm/ios/ios.py
Outdated
"For Cisco devices revert_in between {} and {} seconds, this will round " | ||
"down to the nearest minute".format( | ||
CISCO_TIMER_MIN * 60, CISCO_TIMER_MAX * 60 | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could it be a little clearer to say "For Cisco IOS devices revert_in is rounded down to the nearest minute, pass revert_in as a multiple of 60"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would be okay with that
Sorry if this is obvious, but where exactly are we calling |
Line 648 |
If there is anything I can contribute to move this forward, please let me know. I would love to see this get merged. Many thanks! |
My bad on this. I didn't get to reviewing this earlier. Let me see if I can work on it in June. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need to do some more review and testing, but this is a start.
napalm/ios/ios.py
Outdated
|
||
def _check_archive_feature(self): | ||
cmd = "show archive" | ||
output = self.device.send_command_expect(cmd) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change to send_command
and not send_command_expect
(as that is the more proper way in Netmiko to call this method and consistent with the other NAPALM code).
napalm/ios/ios.py
Outdated
def _get_pending_commits(self): | ||
if self._check_archive_feature(): | ||
cmd = "show archive config rollback timer" | ||
output = self.device.send_command_expect(cmd) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use send_command
and not send_command_expect
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also _get_pending_commits() should return timer
in seconds (as opposed to a string). This will make it more consistent with the behavior of the junos
and eos
driver.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Never mind...we can just leave the timer as-is. That should be fine.
napalm/ios/ios.py
Outdated
) | ||
raise CommitConfirmException(msg) | ||
else: | ||
revert_in = int(revert_in / 60) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would call this revert_in_min
or something that clearly differentiates it from the passed in argument. I say this as it would be easy to miss that the standard revert_in
argument which is in seconds, has been converted to a different argument which is now in minutes form. Consequently, I think it makes sense to have a different name for this variable.
napalm/ios/ios.py
Outdated
@@ -534,14 +566,25 @@ def commit_config(self, message="", revert_in=None): | |||
msg = "Candidate config could not be applied\n{}".format(output) | |||
raise ReplaceConfigException(msg) | |||
elif "%Please turn config archive on" in output: | |||
msg = "napalm-ios replace() requires Cisco 'archive' feature to be enabled." | |||
raise ReplaceConfigException(msg) | |||
raise CommitConfirmException(ARCHIVE_DISABLED_MESSAGE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need a check for if revert_in
here. In other words, probably should look something like:
elif "%Please turn config archive on" in output:
if revert_in:
raise CommitConfirmException(ARCHIVE_DISABLED_MESSAGE)
else:
msg = "napalm-ios replace() requires Cisco 'archive' feature to be enabled."
raise ReplaceConfigException(msg)
NAPALM needs archive to be enabled regardless of whether you are using commit-confirm.
We need to update NAPALM documentation table also that indicates commit_confirm is now supported on Cisco IOS. |
Thanks, I will work on this this coming week. |
Okay, I ran these three tests in
|
@DanSheps Just let me know when you are done making updates and we can see if we can finish this PR off. |
I think this is everything you requested. |
Okay, sounds good...let me try to do final review and testing. |
Also ran the following test:
And it worked fine. |
Superseded by: |
I believe this is now ready for review.
Both merge and replace both support the functionality