mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
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
This commit is contained in:
parent
d01bbb9417
commit
6f2792eb4b
@ -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")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user