marvin: remoteSSHClient logger handler send the logs to the console stream
Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/ceea53cd Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/ceea53cd Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/ceea53cd Branch: refs/heads/ui-plugins Commit: ceea53cd8ffb0b69043acfd1a3ef2cd220cf667c Parents: fb5ea25 Author: Prasanna Santhanam <[email protected]> Authored: Thu Dec 13 19:22:49 2012 -0800 Committer: Prasanna Santhanam <[email protected]> Committed: Thu Dec 13 19:22:49 2012 -0800 ---------------------------------------------------------------------- tools/marvin/marvin/remoteSSHClient.py | 10 +++++++--- 1 files changed, 7 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ceea53cd/tools/marvin/marvin/remoteSSHClient.py ---------------------------------------------------------------------- diff --git a/tools/marvin/marvin/remoteSSHClient.py b/tools/marvin/marvin/remoteSSHClient.py index 24ba0fe..95a9ada 100644 --- a/tools/marvin/marvin/remoteSSHClient.py +++ b/tools/marvin/marvin/remoteSSHClient.py @@ -30,12 +30,16 @@ class remoteSSHClient(object): self.passwd = passwd self.ssh = paramiko.SSHClient() 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 while True: try: 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: if retry_count == 0: raise cloudstackException.InvalidParameterException(repr(sshex)) @@ -48,7 +52,7 @@ class remoteSSHClient(object): def execute(self, 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() errors = stderr.readlines() results = [] @@ -60,7 +64,7 @@ class remoteSSHClient(object): else: for strOut in output: results.append(strOut.rstrip()) - logging.debug("[SSHClient] command %s returned %s"%(command, results)) + self.logger.debug("command %s returned %s"%(command, results)) return results def scp(self, srcFile, destPath):
