From 45aba9cf8d72fd30ca607200694c638cfd240fd8 Mon Sep 17 00:00:00 2001 From: Kyr Shatskyy Date: Thu, 16 Jul 2020 18:17:18 +0200 Subject: [PATCH] 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 --- teuthology/misc.py | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/teuthology/misc.py b/teuthology/misc.py index 0ddd2e8368..e6041d7025 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): -- 2.39.5