]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
qa: add sudo paramter for read_file()
authorXiubo Li <xiubli@redhat.com>
Wed, 2 Nov 2022 01:45:57 +0000 (09:45 +0800)
committerXiubo Li <xiubli@redhat.com>
Mon, 11 Sep 2023 01:29:46 +0000 (09:29 +0800)
Fixes: https://tracker.ceph.com/issues/57154
Signed-off-by: Xiubo Li <xiubli@redhat.com>
qa/tasks/cephfs/mount.py

index 528a2f4f3a1a7c6c0d50493ef011d1f6117c7269..be1ef6ea428e2ff94557de1a07aafba3c84f8d3e 100644 (file)
@@ -734,15 +734,19 @@ class CephFSMount(object):
         if perms:
             self.run_shell(args=f'chmod {perms} {path}')
 
-    def read_file(self, path):
+    def read_file(self, path, sudo=False):
         """
         Return the data from the file on given path.
         """
         if path.find(self.hostfs_mntpt) == -1:
             path = os.path.join(self.hostfs_mntpt, path)
 
-        return self.run_shell(args=['cat', path]).\
-            stdout.getvalue().strip()
+        args = []
+        if sudo:
+            args.append('sudo')
+        args += ['cat', path]
+
+        return self.run_shell(args=args, omit_sudo=False).stdout.getvalue().strip()
 
     def create_destroy(self):
         assert(self.is_mounted())