Skip to content

Commit

Permalink
Merge 0316d58 into 1b06ad0
Browse files Browse the repository at this point in the history
  • Loading branch information
ganeshrn committed Jun 16, 2018
2 parents 1b06ad0 + 0316d58 commit f4995c2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
12 changes: 8 additions & 4 deletions ncclient/operations/third_party/juniper/rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,23 +64,25 @@ class Commit(RPC):

DEPENDS = [':candidate']

def request(self, confirmed=False, timeout=None, comment=None, synchronize=False, at_time=None):
def request(self, confirmed=False, timeout=None, comment=None, synchronize=False, at_time=None, check=False):
"""Commit the candidate configuration as the device's new current configuration. Depends on the `:candidate` capability.
A confirmed commit (i.e. if *confirmed* is `True`) is reverted if there is no followup commit within the *timeout* interval. If no timeout is specified the confirm timeout defaults to 600 seconds (10 minutes). A confirming commit may have the *confirmed* parameter but this is not required. Depends on the `:confirmed-commit` capability.
*confirmed* whether this is a confirmed commit. Mutually exclusive with at_time.
*timeout* specifies the confirm timeout in seconds
*timeout* specifies the confirm timeout in minutes
*comment* a string to comment the commit with. Review on the device using 'show system commit'
*synchronize* Whether we should synch this commit across both Routing Engines
*at_time* Mutually exclusive with confirmed. The time at which the commit should happen. Junos expects either of these two formats:
A time value of the form hh:mm[:ss] (hours, minutes, and, optionally, seconds)
A date and time value of the form yyyy-mm-dd hh:mm[:ss] (year, month, date, hours, minutes, and, optionally, seconds)"""
node = new_ele("commit")
A date and time value of the form yyyy-mm-dd hh:mm[:ss] (year, month, date, hours, minutes, and, optionally, seconds)
*check* Verify the syntactic correctness of the candidate configuration"""
node = new_ele("commit-configuration")
if confirmed and at_time is not None:
raise NCClientError("'Commit confirmed' and 'commit at' are mutually exclusive.")
if confirmed:
Expand All @@ -94,6 +96,8 @@ def request(self, confirmed=False, timeout=None, comment=None, synchronize=False
sub_ele(node, "log").text = comment
if synchronize:
sub_ele(node, "synchronize")
if check:
sub_ele(node, "check")
return self._request(node)

class Rollback(RPC):
Expand Down
6 changes: 3 additions & 3 deletions test/unit/operations/third_party/juniper/test_rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def test_commit_confirmed(self, mock_assert, mock_request, mock_session):
session = ncclient.transport.SSHSession(device_handler)
obj = Commit(session, device_handler, raise_mode=RaiseMode.ALL)
obj.request(confirmed=True, comment="message", timeout="50")
node = new_ele("commit")
node = new_ele("commit-configuration")
sub_ele(node, "confirmed")
sub_ele(node, "confirm-timeout").text = "50"
sub_ele(node, "log").text = "message"
Expand All @@ -221,7 +221,7 @@ def test_commit(self, mock_assert, mock_request, mock_session):
session = ncclient.transport.SSHSession(device_handler)
obj = Commit(session, device_handler, raise_mode=RaiseMode.ALL)
obj.request()
node = new_ele("commit")
node = new_ele("commit-configuration")
xml = ElementTree.tostring(node)
call = mock_request.call_args_list[0][0][0]
call = ElementTree.tostring(call)
Expand All @@ -236,7 +236,7 @@ def test_commit_at_time(self, mock_assert, mock_request, mock_session):
session = ncclient.transport.SSHSession(device_handler)
obj = Commit(session, device_handler, raise_mode=RaiseMode.ALL)
obj.request(at_time="1111-11-11 00:00:00", synchronize=True)
node = new_ele("commit")
node = new_ele("commit-configuration")
sub_ele(node, "at-time").text = "1111-11-11 00:00:00"
sub_ele(node, "synchronize")
xml = ElementTree.tostring(node)
Expand Down

0 comments on commit f4995c2

Please sign in to comment.