]> git-server-git.apps.pok.os.sepia.ceph.com Git - teuthology.git/commitdiff
remote: Add ability to push a file to a remote machine 319/head
authorDavid Zafman <dzafman@redhat.com>
Fri, 15 Aug 2014 19:38:07 +0000 (12:38 -0700)
committerDavid Zafman <dzafman@redhat.com>
Wed, 27 Aug 2014 19:44:13 +0000 (12:44 -0700)
Add put_file() and _sftp_put_file() without sudo support

Signed-off-by: David Zafman <dzafman@redhat.com>
teuthology/orchestra/remote.py

index 0c147e9a8ac985237796d1d446137d277b9778b3..02c1800c88c49a6299c856c1bf5d3a7d86790bd4 100644 (file)
@@ -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.