]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
orchestra/cluster: drop teuthology.misc 1695/head
authorKyr Shatskyy <kyrylo.shatskyy@suse.com>
Sat, 13 Nov 2021 12:07:20 +0000 (13:07 +0100)
committerKyr Shatskyy <kyrylo.shatskyy@suse.com>
Mon, 15 Nov 2021 21:05:36 +0000 (22:05 +0100)
Use sudo_write_file and write_file directly from remote.

Signed-off-by: Kyr Shatskyy <kyrylo.shatskyy@suse.com>
teuthology/orchestra/cluster.py
teuthology/orchestra/test/test_cluster.py

index 45e4c1eb4597ab585c90b210aee768c8423785bb..17b5d5b0ca33909372305038dbb1c1a0ba1296c4 100644 (file)
@@ -2,7 +2,6 @@
 Cluster definition
 part of context, Cluster is used to save connection information.
 """
-import teuthology.misc
 from teuthology.orchestra import run
 
 class Cluster(object):
@@ -115,11 +114,12 @@ class Cluster(object):
         remotes = sorted(self.remotes.keys(), key=lambda rem: rem.name)
         for remote in remotes:
             if sudo:
-                teuthology.misc.sudo_write_file(remote, file_name, content, perms=perms, owner=owner)
+                remote.write_file(file_name, content,
+                                  sudo=True, mode=perms, owner=owner)
             else:
                 if perms is not None or owner is not None:
                     raise ValueError("To specify perms or owner, sudo must be True")
-                teuthology.misc.write_file(remote, file_name, content)
+                remote.write_file(file_name, content)
 
     def only(self, *roles):
         """
index 46e3d4c7b4965acec5de99d71c581c93f5bd16d6..6e2570088141dbef27f8abc73e7c791f1d0dc900 100644 (file)
@@ -198,22 +198,22 @@ class TestWriteFile(object):
             ],
         )
 
-    @patch("teuthology.misc.write_file")
+    @patch("teuthology.orchestra.remote.RemoteShell.write_file")
     def test_write_file(self, m_write_file):
         self.c.write_file("filename", "content")
-        m_write_file.assert_called_with(self.r1, "filename", "content")
+        m_write_file.assert_called_with("filename", "content")
 
-    @patch("teuthology.misc.write_file")
+    @patch("teuthology.orchestra.remote.RemoteShell.write_file")
     def test_fails_with_invalid_perms(self, m_write_file):
         with pytest.raises(ValueError):
             self.c.write_file("filename", "content", sudo=False, perms="invalid")
 
-    @patch("teuthology.misc.write_file")
+    @patch("teuthology.orchestra.remote.RemoteShell.write_file")
     def test_fails_with_invalid_owner(self, m_write_file):
         with pytest.raises(ValueError):
             self.c.write_file("filename", "content", sudo=False, owner="invalid")
 
-    @patch("teuthology.misc.sudo_write_file")
-    def test_with_sudo(self, m_sudo_write_file):
+    @patch("teuthology.orchestra.remote.RemoteShell.write_file")
+    def test_with_sudo(self, m_write_file):
         self.c.write_file("filename", "content", sudo=True)
-        m_sudo_write_file.assert_called_with(self.r1, "filename", "content", owner=None, perms=None)
+        m_write_file.assert_called_with("filename", "content", sudo=True, owner=None, mode=None)