]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
test_volume_client: use sudo_write_file() form teuthology
authorRishabh Dave <ridave@redhat.com>
Tue, 9 Jul 2019 14:26:40 +0000 (19:56 +0530)
committerNathan Cutler <ncutler@suse.com>
Sat, 7 Sep 2019 08:43:14 +0000 (10:43 +0200)
Instead of defining another method to write a file as root user in
test_volume_client.py, use the method from teuthology/misc.py.

Signed-off-by: Rishabh Dave <ridave@redhat.com>
(cherry picked from commit 878c34c701965b8231e0bcaa19956cb89d9db395)

qa/tasks/cephfs/test_volume_client.py

index 8a17b9b5cb5d6204ec5eefa9bb36b91ef00348b1..6df6bf5ab27f8d474c8142d311d6a80539c4eefc 100644 (file)
@@ -6,6 +6,7 @@ from textwrap import dedent
 from tasks.cephfs.cephfs_test_case import CephFSTestCase
 from tasks.cephfs.fuse_mount import FuseMount
 from teuthology.exceptions import CommandFailedError
+from teuthology.misc import sudo_write_file
 
 log = logging.getLogger(__name__)
 
@@ -46,27 +47,6 @@ vc.disconnect()
                    vol_prefix=vol_prefix, ns_prefix=ns_prefix),
         self.py_version)
 
-    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_vc_auth(self, mount, id_name):
         """
         Set up auth credentials for the VolumeClient user
@@ -78,7 +58,7 @@ vc.disconnect()
             "mon", "allow *"
         )
         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 _configure_guest_auth(self, volumeclient_mount, guest_mount,
@@ -141,9 +121,8 @@ vc.disconnect()
             key=key
         ))
         guest_mount.client_id = guest_entity
-        self._sudo_write_file(guest_mount.client_remote,
-                              guest_mount.get_keyring_path(),
-                              keyring_txt)
+        sudo_write_file(guest_mount.client_remote,
+                        guest_mount.get_keyring_path(), keyring_txt)
 
         # Add a guest client section to the ceph config file.
         self.set_conf("client.{0}".format(guest_entity), "client quota", "True")