]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
misc: deprecate (sudo_)write_file methods
authorKyr Shatskyy <kyrylo.shatskyy@suse.com>
Thu, 16 Jul 2020 16:17:18 +0000 (18:17 +0200)
committerKyr Shatskyy <kyrylo.shatskyy@suse.com>
Thu, 3 Sep 2020 21:43:40 +0000 (23:43 +0200)
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 <kyrylo.shatskyy@suse.com>
teuthology/misc.py

index 0ddd2e8368aa61ecd334329c2672bdc110ed54ae..e6041d7025649a77b2aeee4acac4c112936fa0bc 100644 (file)
@@ -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):