Skip to content

Commit ceea53c

Browse files
author
Prasanna Santhanam
committed
marvin: remoteSSHClient logger handler
send the logs to the console stream
1 parent fb5ea25 commit ceea53c

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

tools/marvin/marvin/remoteSSHClient.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,16 @@ def __init__(self, host, port, user, passwd, retries = 10):
3030
self.passwd = passwd
3131
self.ssh = paramiko.SSHClient()
3232
self.ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
33+
self.logger = logging.getLogger('sshClient')
34+
ch = logging.StreamHandler()
35+
ch.setLevel(logging.DEBUG)
36+
self.logger.addHandler(ch)
3337

3438
retry_count = retries
3539
while True:
3640
try:
3741
self.ssh.connect(str(host),int(port), user, passwd)
38-
logging.debug("[SSHClient] connecting to server %s @ port % with user:passwd %s:%s"%(str(host), port, user, passwd))
42+
self.logger.debug("connecting to server %s with user %s passwd %s"%(str(host), user, passwd))
3943
except paramiko.SSHException, sshex:
4044
if retry_count == 0:
4145
raise cloudstackException.InvalidParameterException(repr(sshex))
@@ -48,7 +52,7 @@ def __init__(self, host, port, user, passwd, retries = 10):
4852

4953
def execute(self, command):
5054
stdin, stdout, stderr = self.ssh.exec_command(command)
51-
logging.debug("[SSHClient] sending command %s to host"%(command, str(self.host)))
55+
self.logger.debug("sending command %s to host %s"%(command, str(self.host)))
5256
output = stdout.readlines()
5357
errors = stderr.readlines()
5458
results = []
@@ -60,7 +64,7 @@ def execute(self, command):
6064
else:
6165
for strOut in output:
6266
results.append(strOut.rstrip())
63-
logging.debug("[SSHClient] command %s returned %s"%(command, results))
67+
self.logger.debug("command %s returned %s"%(command, results))
6468
return results
6569

6670
def scp(self, srcFile, destPath):

0 commit comments

Comments
 (0)