From: Rishabh Dave Date: Fri, 26 Mar 2021 09:26:11 +0000 (+0530) Subject: orchestra/remote: extend mktemp() to accept data X-Git-Tag: 1.2.0~263^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F1634%2Fhead;p=teuthology.git orchestra/remote: extend mktemp() to accept data Extend remote.Remote.mktemp() to accept data as a parameter and write the data to the temporary file after it is created. Signed-off-by: Rishabh Dave --- diff --git a/teuthology/orchestra/remote.py b/teuthology/orchestra/remote.py index a9c4c0fd1..bedfcc6f4 100644 --- a/teuthology/orchestra/remote.py +++ b/teuthology/orchestra/remote.py @@ -229,20 +229,28 @@ class Remote(object): return self.sh(args).strip() - def mktemp(self, suffix=None, parentdir=None): + def mktemp(self, suffix=None, parentdir=None, data=None): """ - Make a remote temporary file + Make a remote temporary file. + + :param suffix: suffix for the temporary file + :param parentdir: parent dir where temp file should be created + :param data: write data to the file if provided Returns: the path of the temp file created. """ args = ['mktemp'] - if suffix: args.append('--suffix=%s' % suffix) if parentdir: args.append('--tmpdir=%s' % parentdir) - return self.sh(args).strip() + path = self.sh(args).strip() + + if data: + self.write_file(path=path, data=data) + + return path def sh(self, script, **kwargs): """