From: Xiubo Li Date: Wed, 2 Nov 2022 01:45:57 +0000 (+0800) Subject: qa: add sudo paramter for read_file() X-Git-Tag: v18.2.4~114^2~7 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=7547e8a207a7ef7eb1ba60b6af36c470626b6469;p=ceph.git qa: add sudo paramter for read_file() Fixes: https://tracker.ceph.com/issues/57154 Signed-off-by: Xiubo Li (cherry picked from commit 4af6a3f7441345766fddcf2a9086d3b777c9717a) --- diff --git a/qa/tasks/cephfs/mount.py b/qa/tasks/cephfs/mount.py index 4a81874068f..8bd966fd075 100644 --- a/qa/tasks/cephfs/mount.py +++ b/qa/tasks/cephfs/mount.py @@ -740,15 +740,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())