]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
Add orchestra.remote.get_tar_stream(); like get_tar but no tmpfile
authorDan Mick <dan.mick@redhat.com>
Wed, 2 Nov 2016 04:21:16 +0000 (21:21 -0700)
committerDan Mick <dan.mick@redhat.com>
Wed, 2 Nov 2016 05:00:16 +0000 (22:00 -0700)
Avoid creating a temporary file either on the remote or on the
local host; just open a connection to a remote tar and let 'er
rip.  Intended to be used by get_directory to avoid temp files
and local read/write hammering.

Signed-off-by: Dan Mick <dan.mick@redhat.com>
teuthology/orchestra/remote.py

index 276de88a67dbd557ecd69e910c937de044507981..ed840d253385d61b0ad3f28480b6b2e4fb70069e 100644 (file)
@@ -369,6 +369,24 @@ class Remote(object):
         self._sftp_get_file(remote_temp_path, to_path)
         self.remove(remote_temp_path)
 
+    def get_tar_stream(self, path, sudo=False):
+        """
+        Tar-compress a remote directory and return the RemoteProcess
+        for streaming
+        """
+        args = []
+        if sudo:
+            args.append('sudo')
+        args.extend([
+            'tar',
+            'cz',
+            '-f', '-',
+            '-C', path,
+            '--',
+            '.',
+            ])
+        return self.run(args=args, wait=False, stdout=run.PIPE)
+
     @property
     def os(self):
         if not hasattr(self, '_os'):