Updated Branches: refs/heads/marvin-parallel fc61ef9cd -> cb48468c1
Summary: Close the ssh transport from paramiko Detail: SSH Transport to be explicitly closed in marvin.remoteSSHClient Signed-off-by: Prasanna Santhanam <[email protected]> 1351002168 +0530 Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/cb48468c Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/cb48468c Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/cb48468c Branch: refs/heads/marvin-parallel Commit: cb48468c18987f75daa7a19aa4743703c494e9c9 Parents: fc61ef9 Author: Prasanna Santhanam <[email protected]> Authored: Tue Oct 23 19:52:48 2012 +0530 Committer: Prasanna Santhanam <[email protected]> Committed: Tue Oct 23 19:53:44 2012 +0530 ---------------------------------------------------------------------- tools/marvin/marvin/remoteSSHClient.py | 11 ++++++++--- 1 files changed, 8 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/cb48468c/tools/marvin/marvin/remoteSSHClient.py ---------------------------------------------------------------------- diff --git a/tools/marvin/marvin/remoteSSHClient.py b/tools/marvin/marvin/remoteSSHClient.py index 60df2a7..036e1c3 100644 --- a/tools/marvin/marvin/remoteSSHClient.py +++ b/tools/marvin/marvin/remoteSSHClient.py @@ -18,6 +18,8 @@ import paramiko import time import cloudstackException +import contextlib +from contextlib import closing class remoteSSHClient(object): def __init__(self, host, port, user, passwd, retries = 10): @@ -67,8 +69,11 @@ class remoteSSHClient(object): except IOError, e: raise e + def close(self): + self.ssh.close() + if __name__ == "__main__": - ssh = remoteSSHClient("192.168.137.2", 22, "root", "password") - print ssh.execute("ls -l") - print ssh.execute("rm x") + with contextlib.closing(remoteSSHClient("10.223.75.10", 22, "root", + "password")) as ssh: + print ssh.execute("ls -l")
