Fixed SSH exec_command timeout
[csit.git] / resources / libraries / python / ssh.py
index 2de6f4a..ad5fb27 100644 (file)
@@ -18,7 +18,6 @@ from time import time
 from robot.api import logger
 from interruptingcow import timeout
 from robot.utils.asserts import assert_equal, assert_not_equal
-from socket import timeout as socket_timeout
 
 __all__ = ["exec_cmd", "exec_cmd_no_error"]
 
@@ -56,7 +55,8 @@ class SSH(object):
             self._ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
 
             self._ssh.connect(node['host'], username=node['username'],
-                              password=node.get('password'), pkey=pkey)
+                              password=node.get('password'), pkey=pkey,
+                              port=node['port'])
 
             SSH.__existing_connections[node_hash] = self._ssh
 
@@ -85,24 +85,16 @@ class SSH(object):
 
         stdout = ""
         while True:
-            try:
-                buf = chan.recv(self.__MAX_RECV_BUF)
-                stdout += buf
-                if not buf:
-                    break
-            except socket_timeout:
-                logger.trace('Channels stdout timeout occurred')
+            buf = chan.recv(self.__MAX_RECV_BUF)
+            stdout += buf
+            if not buf:
                 break
 
         stderr = ""
         while True:
-            try:
-                buf = chan.recv_stderr(self.__MAX_RECV_BUF)
-                stderr += buf
-                if not buf:
-                    break
-            except socket_timeout:
-                logger.trace('Channels stderr timeout occurred')
+            buf = chan.recv_stderr(self.__MAX_RECV_BUF)
+            stderr += buf
+            if not buf:
                 break
 
         return_code = chan.recv_exit_status()