Skip to content

Commit

Permalink
Add new methods for immediate revert and checking if pending commit c…
Browse files Browse the repository at this point in the history
…onfirms exist (#628)
  • Loading branch information
ktbyers committed Jan 21, 2018
1 parent eb80297 commit b923e6f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
16 changes: 11 additions & 5 deletions napalm/base/base.py
Expand Up @@ -188,16 +188,22 @@ def commit_confirm(self):
"""Confirm pending commit."""
raise NotImplementedError

def discard_config(self):
def commit_confirm_revert(self):
"""Abort pending commit confirm immediately and rollback to previous state"""
raise NotImplementedError

def has_pending_commit(self):
"""
Discards the configuration loaded into the candidate.
:return A boolean indicating whether any pending commit confirms exist.
"""
raise NotImplementedError

def discard_config(self):
"""Discards the configuration loaded into the candidate."""
raise NotImplementedError

def rollback(self):
"""
If changes were made, revert changes to the original state.
"""
"""If changes were made, revert changes to the original state."""
raise NotImplementedError

def get_facts(self):
Expand Down
11 changes: 10 additions & 1 deletion napalm/ios/ios.py
Expand Up @@ -425,11 +425,20 @@ def commit_confirm(self):
cmd = "configure confirm"
self.device.send_command_expect(cmd)

def _commit_abort(self):
def commit_confirm_revert(self):
"""Immediately revert pending commit confirm."""
cmd = "configure revert now"
self.device.send_command_expect(cmd)

def has_pending_commit(self):
"""
:return A boolean indicating whether any pending commit confirms exist.
"""
cmd = "show archive config rollback timer"
search_pattern = r"No Rollback Confirmed Change pending"
output = self.device.send_command_expect(cmd)
return not bool(re.search(search_pattern, output, flags=re.I))

def commit_config(self, confirmed=None, message=None):
"""If replacement operation, perform 'configure replace' for the entire config.
Expand Down

0 comments on commit b923e6f

Please sign in to comment.