]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
test_sessionmap: use sudo_write_file() from teuthology.misc
authorRishabh Dave <ridave@redhat.com>
Fri, 19 Jul 2019 04:35:18 +0000 (10:05 +0530)
committerRishabh Dave <ridave@redhat.com>
Fri, 19 Jul 2019 04:35:18 +0000 (10:05 +0530)
Instead of defining a method to write files within the testsuite, use
sudo_write_file() from teuthology.misc.

Signed-off-by: Rishabh Dave <ridave@redhat.com>
qa/tasks/cephfs/test_sessionmap.py

index 71d1334a4429848b25d62ebefad51a316e71abc8..5108d5d6ac854819386d251a37ba7b86763ae217 100644 (file)
@@ -6,6 +6,7 @@ import logging
 from tasks.cephfs.fuse_mount import FuseMount
 from teuthology.exceptions import CommandFailedError
 from tasks.cephfs.cephfs_test_case import CephFSTestCase
+from teuthology.misc import sudo_write_file
 
 log = logging.getLogger(__name__)
 
@@ -148,27 +149,6 @@ class TestSessionMap(CephFSTestCase):
         self.assertEqual(table_json['0']['result'], 0)
         self.assertEqual(len(table_json['0']['data']['Sessions']), 0)
 
-    def _sudo_write_file(self, remote, path, data):
-        """
-        Write data to a remote file as super user
-
-        :param remote: Remote site.
-        :param path: Path on the remote being written to.
-        :param data: Data to be written.
-
-        Both perms and owner are passed directly to chmod.
-        """
-        remote.run(
-            args=[
-                'sudo',
-                'python',
-                '-c',
-                'import shutil, sys; shutil.copyfileobj(sys.stdin, file(sys.argv[1], "wb"))',
-                path,
-            ],
-            stdin=data,
-        )
-
     def _configure_auth(self, mount, id_name, mds_caps, osd_caps=None, mon_caps=None):
         """
         Set up auth credentials for a client mount, and write out the keyring
@@ -188,7 +168,7 @@ class TestSessionMap(CephFSTestCase):
             "mon", mon_caps
         )
         mount.client_id = id_name
-        self._sudo_write_file(mount.client_remote, mount.get_keyring_path(), out)
+        sudo_write_file(mount.client_remote, mount.get_keyring_path(), out)
         self.set_conf("client.{name}".format(name=id_name), "keyring", mount.get_keyring_path())
 
     def test_session_reject(self):