Skip to content
This repository was archived by the owner on Sep 17, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion napalm_base/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,17 @@ def compare_config(self):
"""
raise NotImplementedError

def commit_config(self):
def commit_config(self, revert_in=0):
"""
Commits the changes requested by the method load_replace_candidate or load_merge_candidate.

:param revert_in: Number of seconds until rollback. Don't revert if 0.
"""
raise NotImplementedError

def commit_confirm(self):
"""
Confirm pending commit.
"""
raise NotImplementedError

Expand Down
17 changes: 17 additions & 0 deletions napalm_base/test/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,23 @@ def test_replacing_and_committing_config(self):

self.assertEqual(len(diff), 0)

def test_replacing_and_committing_config_with_confirm(self):
try:
self.device.load_replace_candidate(filename='%s/new_good.conf' % self.vendor)
self.device.commit_config(revert_in=60)
self.device.commit_confirm()
except NotImplementedError:
raise SkipTest()

# The diff should be empty as the configuration has been committed already
diff = self.device.compare_config()

# Reverting changes
self.device.load_replace_candidate(filename='%s/initial.conf' % self.vendor)
self.device.commit_config()

self.assertEqual(len(diff), 0)

def test_replacing_config_with_typo(self):
result = False
try:
Expand Down