From 9dff8577bc4322354c098c5ff4df57b0d2d444bb Mon Sep 17 00:00:00 2001 From: Dan Mick Date: Tue, 1 Nov 2016 21:21:16 -0700 Subject: [PATCH] Add orchestra.remote.get_tar_stream(); like get_tar but no tmpfile 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 --- teuthology/orchestra/remote.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/teuthology/orchestra/remote.py b/teuthology/orchestra/remote.py index 276de88a67..ed840d2533 100644 --- a/teuthology/orchestra/remote.py +++ b/teuthology/orchestra/remote.py @@ -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'): -- 2.39.5