From: Kyr Shatskyy Date: Thu, 16 Jul 2020 16:17:18 +0000 (+0200) Subject: misc: deprecate (sudo_)write_file methods X-Git-Tag: 1.1.0~48^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=45aba9cf8d72fd30ca607200694c638cfd240fd8;p=teuthology.git misc: deprecate (sudo_)write_file methods Deprecate misc.write_file() and misc.sudo_write_file() in favor of the orchestra.remote package methods. The code of the misc's methods is now calling the remote's ones. Signed-off-by: Kyr Shatskyy --- diff --git a/teuthology/misc.py b/teuthology/misc.py index 0ddd2e836..e6041d702 100644 --- a/teuthology/misc.py +++ b/teuthology/misc.py @@ -521,14 +521,7 @@ def write_file(remote, path, data): :param path: Path on the remote being written to. :param data: Data to be written. """ - remote.run( - args=[ - 'cat', - run.Raw('>'), - path, - ], - stdin=data, - ) + remote.write_file(path, data) def sudo_write_file(remote, path, data, perms=None, owner=None): @@ -543,21 +536,7 @@ def sudo_write_file(remote, path, data, perms=None, owner=None): Both perms and owner are passed directly to chmod. """ - permargs = [] - if perms: - permargs = [run.Raw('&&'), 'sudo', 'chmod', perms, path] - owner_args = [] - if owner: - owner_args = [run.Raw('&&'), 'sudo', 'chown', owner, path] - remote.run( - args=[ - 'sudo', - 'sh', - '-c', - 'cat > ' + path, - ] + owner_args + permargs, - stdin=data, - ) + remote.sudo_write_file(path, data, mode=perms, owner=owner) def copy_file(from_remote, from_path, to_remote, to_path=None):