Skip to content

Commit 6f2792e

Browse files
author
Prasanna Santhanam
committed
Summary: Close the ssh transport from paramiko
Detail: SSH Transport to be explicitly closed in marvin.remoteSSHClient Signed-off-by: Prasanna Santhanam <tsp@apache.org> 1351002168 +0530
1 parent d01bbb9 commit 6f2792e

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

‎tools/marvin/marvin/remoteSSHClient.py‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
import paramiko
1919
import time
2020
import cloudstackException
21+
import contextlib
22+
from contextlib import closing
2123

2224
class remoteSSHClient(object):
2325
def __init__(self, host, port, user, passwd, retries = 10):
@@ -67,8 +69,11 @@ def scp(self, srcFile, destPath):
6769
except IOError, e:
6870
raise e
6971

72+
def close(self):
73+
self.ssh.close()
74+
7075

7176
if __name__ == "__main__":
72-
ssh = remoteSSHClient("192.168.137.2", 22, "root", "password")
73-
print ssh.execute("ls -l")
74-
print ssh.execute("rm x")
77+
with contextlib.closing(remoteSSHClient("10.223.75.10", 22, "root",
78+
"password")) as ssh:
79+
print ssh.execute("ls -l")

0 commit comments

Comments
 (0)