mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
marvin: remoteSSHClient logger handler
send the logs to the console stream
This commit is contained in:
parent
fb5ea25a4d
commit
ceea53cd8f
@ -30,12 +30,16 @@ class remoteSSHClient(object):
|
|||||||
self.passwd = passwd
|
self.passwd = passwd
|
||||||
self.ssh = paramiko.SSHClient()
|
self.ssh = paramiko.SSHClient()
|
||||||
self.ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
self.ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||||
|
self.logger = logging.getLogger('sshClient')
|
||||||
|
ch = logging.StreamHandler()
|
||||||
|
ch.setLevel(logging.DEBUG)
|
||||||
|
self.logger.addHandler(ch)
|
||||||
|
|
||||||
retry_count = retries
|
retry_count = retries
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
self.ssh.connect(str(host),int(port), user, passwd)
|
self.ssh.connect(str(host),int(port), user, passwd)
|
||||||
logging.debug("[SSHClient] connecting to server %s @ port % with user:passwd %s:%s"%(str(host), port, user, passwd))
|
self.logger.debug("connecting to server %s with user %s passwd %s"%(str(host), user, passwd))
|
||||||
except paramiko.SSHException, sshex:
|
except paramiko.SSHException, sshex:
|
||||||
if retry_count == 0:
|
if retry_count == 0:
|
||||||
raise cloudstackException.InvalidParameterException(repr(sshex))
|
raise cloudstackException.InvalidParameterException(repr(sshex))
|
||||||
@ -48,7 +52,7 @@ class remoteSSHClient(object):
|
|||||||
|
|
||||||
def execute(self, command):
|
def execute(self, command):
|
||||||
stdin, stdout, stderr = self.ssh.exec_command(command)
|
stdin, stdout, stderr = self.ssh.exec_command(command)
|
||||||
logging.debug("[SSHClient] sending command %s to host"%(command, str(self.host)))
|
self.logger.debug("sending command %s to host %s"%(command, str(self.host)))
|
||||||
output = stdout.readlines()
|
output = stdout.readlines()
|
||||||
errors = stderr.readlines()
|
errors = stderr.readlines()
|
||||||
results = []
|
results = []
|
||||||
@ -60,7 +64,7 @@ class remoteSSHClient(object):
|
|||||||
else:
|
else:
|
||||||
for strOut in output:
|
for strOut in output:
|
||||||
results.append(strOut.rstrip())
|
results.append(strOut.rstrip())
|
||||||
logging.debug("[SSHClient] command %s returned %s"%(command, results))
|
self.logger.debug("command %s returned %s"%(command, results))
|
||||||
return results
|
return results
|
||||||
|
|
||||||
def scp(self, srcFile, destPath):
|
def scp(self, srcFile, destPath):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user