py-junos-eznc icon indicating copy to clipboard operation
py-junos-eznc copied to clipboard

Cannot set Device.open timeout

Open sstancu opened this issue 5 years ago • 4 comments

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.

sstancu avatar Apr 15 '19 13:04 sstancu

Suggested fix in https://github.com/Juniper/py-junos-eznc/pull/928 .

sstancu avatar Apr 15 '19 15:04 sstancu

@dmontagner

dmontagner avatar Oct 29 '19 21:10 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.

kirillmasanov avatar Jan 27 '21 18:01 kirillmasanov

Seems to be same issue as #780

rahkumar651991 avatar Jun 01 '21 07:06 rahkumar651991

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

apurvaraghu avatar Feb 24 '24 04:02 apurvaraghu

as per @apurvaraghu comments , PyEZ support conn_open_timeout argument.

dineshbaburam91 avatar Feb 27 '24 04:02 dineshbaburam91