Juniper/py-junos-eznc — pull request #304 by tamihiro (2014-10-22 10:28:42+00:00)
Title: Just trying to catch an error when a commit execution times out.

Hi developers -
While I was testing your modules, the following exception was caught when my test script failed to complete a commit execution:

File "/Users/tamil/just_testing/cm_sess/netconf_sess.py", line 124, in save_exit_config
self.cu.commit()
File "/Library/Python/2.7/site-packages/jnpr/junos/utils/config.py", line 85, in commit
JXML.remove_namespaces(err.xml)
AttributeError: 'exceptions.AttributeError' object has no attribute 'xml'

After a bit of digging the source, I found out that it was an ncclient error due to a short timeout value of a Device object. With the suggested changes, I can see that it was a timeout:

File "/Users/tamil/just_testing/cm_sess/netconf_sess.py", line 124, in save_exit_config
self.cu.commit()
File "/Library/Python/2.7/site-packages/jnpr/junos/utils/config.py", line 75, in commit
self.rpc.commit_configuration(**rpc_args)
File "/Library/Python/2.7/site-packages/jnpr/junos/rpcmeta.py", line 132, in _exec_rpc
return self._junos.execute(rpc)
File "/Library/Python/2.7/site-packages/jnpr/junos/device.py", line 501, in execute
raise EzErrors.ConnectTimeoutError(self)
ConnectTimeoutError: ConnectTimeoutError(192.168.11.101)

Admittedly it's not elegant at all, but at least a little nicer than otherwise.