summaryrefslogtreecommitdiffstats
path: root/libs/connect
diff options
context:
space:
mode:
authorVijaykumar <vkoppad@redhat.com>2012-01-20 16:52:40 +0530
committerVijaykumar <vkoppad@redhat.com>2012-01-20 17:05:49 +0530
commit51d21cdc228103119773ed228c0d5242e8b7449b (patch)
tree31b12552d98403803ec7ccbf42f95c94c4cbb5cc /libs/connect
parentce6211d93a420a1251978c5551cae25c87a2d4aa (diff)
Gluster installation through tar,git,rpm.
Signed-off-by: Vijaykumar <vkoppad@redhat.com> Change-Id: I10cf998ff87dabfbc3cd4abd5762dba255e53042 Signed-off-by: Vijaykumar <vkoppad@redhat.com>
Diffstat (limited to 'libs/connect')
-rwxr-xr-xlibs/connect/ssh.py35
1 files changed, 21 insertions, 14 deletions
diff --git a/libs/connect/ssh.py b/libs/connect/ssh.py
index a419c31..e4540d5 100755
--- a/libs/connect/ssh.py
+++ b/libs/connect/ssh.py
@@ -7,8 +7,8 @@ import time
from atfglobals import GlobalObj
class SshConnection():
-
- def __init__(self):
+
+ def __init__(self):
self._connection = paramiko.SSHClient()
def connect(self, host, user, password):
@@ -17,14 +17,14 @@ class SshConnection():
SSH to Server "host" as User "user"
Parameter:
- host: Server IP Address
+ host: Server IP Address
user: Login Username
password: Login password
Return:
Success: 0
Failure: 1
- """
+ """
logger = GlobalObj.getLoggerObj()
self._connection.set_missing_host_key_policy(paramiko.AutoAddPolicy())
@@ -43,22 +43,22 @@ class SshConnection():
except paramiko.SSHException:
logger.error("SSHException: Unknown server " + host)
- return 1
+ return 1
return 0
def close(self):
"""
Objective:
- Close SSH Connections
+ Close SSH Connections
"""
self._connection.close()
- return
+ return
def executecommand(self, command, commandInput=None):
"""
Objective:
- Execute Command "comamnd"
+ Execute Command "comamnd"
Parameters:
command: command to execute
@@ -73,14 +73,23 @@ class SshConnection():
output["stdoutdata"] = None
output["stderrdata"] = None
exit_status_ready_flag = True
-
+
try:
transport = self._connection.get_transport()
channel = transport.open_session()
channel.exec_command(command)
# Adding sleep to get the correct exit_status.
- time.sleep(5)
- exit_status_ready_flag = channel.exit_status_ready()
+ timeout = 60
+ sleeptime = 5
+ while timeout:
+ time.sleep(sleeptime)
+ exit_status_ready_flag = channel.exit_status_ready()
+ if not exit_status_ready_flag:
+ timeout -=1
+ continue
+ else:
+ break
+
if not exit_status_ready_flag:
stdin = channel.makefile("wb")
@@ -91,7 +100,7 @@ class SshConnection():
after executing comamnd for command completion")
stdin.write("\n")
return output
-
+
stdout = channel.makefile("rb")
stderr = channel.makefile_stderr("rb")
exit_status = channel.recv_exit_status()
@@ -104,5 +113,3 @@ class SshConnection():
logger.error("Unable to Execute Command: " + command)
return output
-
-