From: David Zafman Date: Fri, 15 Aug 2014 19:38:07 +0000 (-0700) Subject: remote: Add ability to push a file to a remote machine X-Git-Tag: 1.1.0~1193^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F319%2Fhead;p=teuthology.git 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 --- diff --git a/teuthology/orchestra/remote.py b/teuthology/orchestra/remote.py index 0c147e9a8..02c1800c8 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.