diff --git a/nodepool/sshclient.py b/nodepool/sshclient.py index 51faca093..8be0c0089 100644 --- a/nodepool/sshclient.py +++ b/nodepool/sshclient.py @@ -25,14 +25,17 @@ class SSHClient(object): def __init__(self, ip, username, password=None, pkey=None, key_filename=None, log=None, look_for_keys=False, allow_agent=False): - client = paramiko.SSHClient() - client.set_missing_host_key_policy(paramiko.WarningPolicy()) - client.connect(ip, username=username, password=password, pkey=pkey, - key_filename=key_filename, look_for_keys=look_for_keys, - allow_agent=allow_agent) - self.client = client + self.client = paramiko.SSHClient() + self.client.set_missing_host_key_policy(paramiko.WarningPolicy()) + self.client.connect(ip, username=username, password=password, + pkey=pkey, key_filename=key_filename, + look_for_keys=look_for_keys, + allow_agent=allow_agent) self.log = log + def __del__(self): + self.client.close() + def ssh(self, action, command, get_pty=True, output=False): if self.log: self.log.debug("*** START to %s" % action)