Skip to content

Commit

Permalink
Merge pull request #46 from DENICeG/master
Browse files Browse the repository at this point in the history
Thanks @thorko
  • Loading branch information
mirceaulinic authored Jun 4, 2017
2 parents 4153f13 + cde3a96 commit 80c9c8d
Show file tree
Hide file tree
Showing 12 changed files with 44 additions and 10 deletions.
20 changes: 10 additions & 10 deletions pyIOSXR/iosxr.py
Original file line number Diff line number Diff line change
Expand Up @@ -582,17 +582,17 @@ def commit_config(self, label=None, comment=None, confirmed=None):
:param comment: Commit label, displayed instead of the commit ID on the device.
:param confirmed: Commit with auto-rollback if new commit is not made in 30 to 300 sec
"""
rpc_command = '<Commit'
rpc_command = '<CLI><Configuration>commit'
if label:
rpc_command += ' Label="%s"' % label
rpc_command += ' label %s' % label
if comment:
rpc_command += ' Comment="%s"' % comment
rpc_command += ' comment %s' % comment
if confirmed:
if 30 <= int(confirmed) <= 300:
rpc_command += ' Confirmed="%d"' % int(confirmed)
rpc_command += ' confirmed %d' % int(confirmed)
else:
raise InvalidInputError('confirmed needs to be between 30 and 300 seconds', self)
rpc_command += '/>'
rpc_command += '</Configuration></CLI>'

self._execute_rpc(rpc_command)

Expand All @@ -604,17 +604,17 @@ def commit_replace_config(self, label=None, comment=None, confirmed=None):
:param label: User label saved on this commit on the device
:param confirmed: Commit with auto-rollback if new commit is not made in 30 to 300 sec
"""
rpc_command = '<Commit Replace="true"'
rpc_command = '<CLI><Configuration>commit replace'
if label:
rpc_command += ' Label="%s"' % label
rpc_command += ' label %s' % label
if comment:
rpc_command += ' Comment="%s"' % comment
rpc_command += ' comment %s' % comment
if confirmed:
if 30 <= int(confirmed) <= 300:
rpc_command += ' Confirmed="%d"' % int(confirmed)
rpc_command += ' confirmed %d' % int(confirmed)
else:
raise InvalidInputError('confirmed needs to be between 30 and 300 seconds', self)
rpc_command += '/>'
rpc_command += '</Configuration></CLI>'
self._execute_rpc(rpc_command)

def discard_config(self):
Expand Down
3 changes: 3 additions & 0 deletions test/mock/CLI_Configuration_commitConfiguration_CLI_.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<Response MajorVersion="1" MinorVersion="0"><Commit/><ResultSummary ErrorCount="0"/></Response>
XML>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<Response MajorVersion="1" MinorVersion="0"><Commit Comment="good" ErrorCode="0x41864e00" ErrorMsg="&apos;CfgMgr&apos; detected the &apos;warning&apos; condition &apos;The target configuration buffer is empty.&apos;"/><ResultSummary ErrorCount="1"/></Response>
XML>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<Response MajorVersion="1" MinorVersion="0"><Commit Comment="good" CommitID="1000000713"/><ResultSummary ErrorCount="0"/></Response>
XML>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<Response MajorVersion="1" MinorVersion="0"><Commit Comment="remove" ErrorCode="0x41866c00" ErrorMsg="&apos;CfgMgr&apos; detected the &apos;warning&apos; condition &apos;One or more commits have occurred from other configuration sessions since this session started or since the last commit was made from this session.&apos;"/><ResultSummary ErrorCount="1"/></Response>
XML>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<Response MajorVersion="1" MinorVersion="0"><Commit Comment="pyIOSXR-test_xml-agent-iteration-on" CommitID="1000000096"/><ResultSummary ErrorCount="0"/></Response>
XML>

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<Response MajorVersion="1" MinorVersion="0"><Commit Confirmed="60"/><ResultSummary ErrorCount="0"/></Response>
XML>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<Response MajorVersion="1" MinorVersion="0"><Commit Label="test"/><ResultSummary ErrorCount="0"/></Response>
XML>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<Response MajorVersion="1" MinorVersion="0"><Commit Replace="true"/><ResultSummary ErrorCount="0"/></Response>
XML>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<Response MajorVersion="1" MinorVersion="0"><Commit Comment="good" CommitID="1000000713"/><ResultSummary ErrorCount="0"/></Response>
XML>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<Response MajorVersion="1" MinorVersion="0"><Commit Confirmed="60"/><ResultSummary ErrorCount="0"/></Response>
XML>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<Response MajorVersion="1" MinorVersion="0"><Commit Label="test"/><ResultSummary ErrorCount="0"/></Response>
XML>

0 comments on commit 80c9c8d

Please sign in to comment.