From 2e4f25c995f44fe9ab5c48ea057582196bf6074d Mon Sep 17 00:00:00 2001 From: David Zafman Date: Fri, 15 Aug 2014 12:38:07 -0700 Subject: [PATCH] remote: Add ability to push a file to a remote machine Add put_file() and _sftp_put_file() without sudo support Signed-off-by: David Zafman --- teuthology/orchestra/remote.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/teuthology/orchestra/remote.py b/teuthology/orchestra/remote.py index 0c147e9a8a..02c1800c88 100644 --- a/teuthology/orchestra/remote.py +++ b/teuthology/orchestra/remote.py @@ -153,6 +153,14 @@ class Remote(object): args=args, ) + def _sftp_put_file(self, local_path, remote_path): + """ + Use the paramiko.SFTPClient to put a file. Returns the remote filename. + """ + sftp = self.ssh.open_sftp() + sftp.put(local_path, remote_path) + return + def _sftp_get_file(self, remote_path, local_path): """ Use the paramiko.SFTPClient to get a file. Returns the local filename. @@ -172,6 +180,16 @@ class Remote(object): def remove(self, path): self.run(args=['rm', '-fr', path]) + def put_file(self, path, dest_path, sudo=False): + """ + Copy a local filename to a remote file + """ + if sudo: + raise NotImplementedError("sudo not supported") + + self._sftp_put_file(path, dest_path) + return + def get_file(self, path, sudo=False, dest_dir='/tmp'): """ Fetch a remote file, and return its local filename. -- 2.39.5