From: Xiubo Li Date: Wed, 2 Nov 2022 01:45:57 +0000 (+0800) Subject: qa: add sudo paramter for read_file() X-Git-Tag: v19.0.0~433^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=4af6a3f7441345766fddcf2a9086d3b777c9717a;p=ceph.git qa: add sudo paramter for read_file() Fixes: https://tracker.ceph.com/issues/57154 Signed-off-by: Xiubo Li --- diff --git a/qa/tasks/cephfs/mount.py b/qa/tasks/cephfs/mount.py index 528a2f4f3a1a..be1ef6ea428e 100644 --- a/qa/tasks/cephfs/mount.py +++ b/qa/tasks/cephfs/mount.py @@ -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())