From 8bed6ab6254380a9b324657116a225636c3283f2 Mon Sep 17 00:00:00 2001 From: Warren Usui Date: Thu, 1 May 2014 12:52:45 -0700 Subject: [PATCH] FIx mktemp dir and redundant Paramiko connecting. Use previously initialized connection for sftp_get calls. Use local directory for tarball temp file location. --- teuthology/misc.py | 2 +- teuthology/orchestra/remote.py | 10 +--------- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/teuthology/misc.py b/teuthology/misc.py index bef136429af..afe58e0129d 100644 --- a/teuthology/misc.py +++ b/teuthology/misc.py @@ -625,7 +625,7 @@ def pull_directory(remote, remotedir, localdir): remote.shortname, remotedir, localdir) if not os.path.exists(localdir): os.mkdir(localdir) - _, local_tarfile = tempfile.mkstemp() + _, local_tarfile = tempfile.mkstemp(dir=localdir) remote.get_tar(remotedir, local_tarfile, sudo=True) with open(local_tarfile, 'r+') as fb1: tar = tarfile.open(mode='r|', fileobj=fb1) diff --git a/teuthology/orchestra/remote.py b/teuthology/orchestra/remote.py index 5e8be0c843c..a72e40eb9e3 100644 --- a/teuthology/orchestra/remote.py +++ b/teuthology/orchestra/remote.py @@ -73,10 +73,6 @@ class Remote(object): def hostname(self): return self.name.split('@')[1] - @property - def username(self): - return self.name.split('@')[0] - @property def is_online(self): if self.ssh is None: @@ -159,11 +155,7 @@ class Remote(object): return result def _sftp_copy_file(self, file_path, to_path): - client = paramiko.SSHClient() - client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) - client.load_system_host_keys() - client.connect(self.hostname, username=self.username) - sftp = client.open_sftp() + sftp = self.ssh.open_sftp() sftp.get(file_path, to_path) def remove(self, path):