diff options
author | Peter Mikus <pmikus@cisco.com> | 2018-04-05 13:07:02 +0200 |
---|---|---|
committer | Peter Mikus <pmikus@cisco.com> | 2018-04-06 10:25:34 +0000 |
commit | 84e2999a1b8847e4ae43cc2b0faf901ac8575bc1 (patch) | |
tree | 0b0c7e1f0523b3a90295a465afa8c06e6e1a5922 /resources/libraries/python/ssh.py | |
parent | 995ac8540182cecb151298a61633c202150020ce (diff) |
FIX: VAT SSH timeout
Currently when VAT cannot connect to VPP via direct API call, there is
inner timeout of ~100s until it quits and returns RC. In our code we are
setting outer timeout to 10/15s to detect if VAT is not responding. If
VAT does not respond quickly enough due to e.g VPP crash, we are
incorrectly reporting SSHTimout exception.
This fix is suppose to set correct timeout values and also to set some
of the calls like show run|hard|err / clear to detect whether they were
successfull or not.
+ Various small library cleanup.
Change-Id: I787c4baecd7e086705a4076643e255a875ea8438
Signed-off-by: Peter Mikus <pmikus@cisco.com>
Diffstat (limited to 'resources/libraries/python/ssh.py')
-rw-r--r-- | resources/libraries/python/ssh.py | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/resources/libraries/python/ssh.py b/resources/libraries/python/ssh.py index 11b05837bf..7fa10bcb51 100644 --- a/resources/libraries/python/ssh.py +++ b/resources/libraries/python/ssh.py @@ -132,7 +132,6 @@ class SSH(object): :rtype: tuple(int, str, str) :raise SSHTimeout: If command is not finished in timeout time. """ - start = time() stdout = StringIO.StringIO() stderr = StringIO.StringIO() try: @@ -147,6 +146,7 @@ class SSH(object): logger.trace('exec_command on {0}: {1}' .format(self._ssh.get_transport().getpeername(), cmd)) + start = time() chan.exec_command(cmd) while not chan.exit_status_ready() and timeout is not None: if chan.recv_ready(): @@ -176,8 +176,6 @@ class SSH(object): logger.trace('exec_command on {0} took {1} seconds'.format( self._ssh.get_transport().getpeername(), end-start)) - logger.trace('chan_recv/_stderr took {} seconds'.format(time()-end)) - logger.trace('return RC {}'.format(return_code)) logger.trace('return STDOUT {}'.format(stdout.getvalue())) logger.trace('return STDERR {}'.format(stderr.getvalue())) |