py-junos-eznc
py-junos-eznc copied to clipboard
Cannot set Device.open timeout
jnpr/junos/device.py Device.open
does not allow passing a timeout
parameter that would properly propagate all the way down to ncclient/transport.ssh.py:connect
. A possible workaround can be implemented in ncclient (https://github.com/ncclient/ncclient/pull/312), but it's not a proper fix.
When calling open on a Device that is unreachable, ssh will timeout after ~2 minutes (Linux platform). This is not an acceptable working condition when managing a network that has hundreds of Juniper devices.
Also, the following documentation for jnpr/junos/device.py Device.open(self, *vargs, **kwargs)
:
is wrong:
:raises ConnectTimeoutError:
When the the :meth:`Device.timeout` value is exceeded
during the attempt to connect to the remote device
This exception is raised when the ncclient cannot perform the ssh connection and the Device.timeout has no effect on this. Device.timeout can only be set once a valid Device._conn exists, and says how long it should wait for an aswer on an already established connection.
Suggested fix in https://github.com/Juniper/py-junos-eznc/pull/928 .
@dmontagner
This problem is also relevant to me. There are several thousand Juniper devices on the network. I can't use scripts to collect information from each of them.
Seems to be same issue as #780
Device.open() has an optional variable conn_open_timeout which can used to specify timeout in seconds and used while opening a SSH connection to the device.
:param int conn_open_timeout:
*OPTIONAL* To specify the timeout in seconds, which will
be used while opening SSH connection to the device
Please check If this variable can be used in your case
as per @apurvaraghu comments , PyEZ support conn_open_timeout argument.