From: Kyr Shatskyy Date: Sat, 13 Nov 2021 12:07:20 +0000 (+0100) Subject: orchestra/cluster: drop teuthology.misc X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=2c8364818fe0bc1ae790a8d6d673262f730d1597;p=teuthology.git orchestra/cluster: drop teuthology.misc Use sudo_write_file and write_file directly from remote. Signed-off-by: Kyr Shatskyy --- diff --git a/teuthology/orchestra/cluster.py b/teuthology/orchestra/cluster.py index 45e4c1eb45..17b5d5b0ca 100644 --- a/teuthology/orchestra/cluster.py +++ b/teuthology/orchestra/cluster.py @@ -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): """ diff --git a/teuthology/orchestra/test/test_cluster.py b/teuthology/orchestra/test/test_cluster.py index 46e3d4c7b4..6e25700881 100644 --- a/teuthology/orchestra/test/test_cluster.py +++ b/teuthology/orchestra/test/test_cluster.py @@ -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)