Mercurial > srxproxy
changeset 29:321d12efed3d
Check for errors in the commit reply
| author | Radomir Dopieralski <sheep-devel@sheep.art.pl> |
|---|---|
| date | Wed, 13 Feb 2013 12:36:33 +0100 |
| parents | f96559a7e9b6 |
| children | 3261a356ce18 |
| files | srxproxy.py |
| diffstat | 1 files changed, 14 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/srxproxy.py Tue Feb 12 16:50:59 2013 +0100 +++ b/srxproxy.py Wed Feb 13 12:36:33 2013 +0100 @@ -114,13 +114,22 @@ LOG.debug('Commiting') for retry in xrange(netconf_retries): try: - m.commit(confirmed=False) + reply = m.commit(confirmed=False) except operations.rpc.RPCError as e: - LOG.debug('Failed to commit, try %d', retry) - eventlet.sleep(2**retry + 1) + pass else: - LOG.debug('Commited') - break + for child in reply._root.getchildren(): + error = child.find( + '{urn:ietf:params:xml:ns:netconf:base:1.0}rpc-error', + ) + if error: + LOG.warning('Commit error (%s)', error.text) + break + else: + LOG.debug('Commited') + break + LOG.warning('Failed to commit, try %d', retry) + eventlet.sleep(2**retry + 1) else: LOG.error('Failed configuring network device %r.', netconf_ip) raise Exception("Failed configuring network device")
