From: Rishabh Dave Date: Thu, 21 Feb 2019 16:22:35 +0000 (+0530) Subject: qa: add a method to run given command as root user X-Git-Tag: v15.1.0~2911^2~8 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=cb262323bca60d7e63b40dc5235fc34afb8ad705;p=ceph-ci.git qa: add a method to run given command as root user Signed-off-by: Rishabh Dave --- diff --git a/qa/tasks/vstart_runner.py b/qa/tasks/vstart_runner.py index d1c628df722..b63e62965c0 100644 --- a/qa/tasks/vstart_runner.py +++ b/qa/tasks/vstart_runner.py @@ -450,6 +450,19 @@ class LocalFuseMount(FuseMount): check_status=check_status, stdin=stdin, omit_sudo=False) + def run_as_root(self, args, wait=True, stdin=None, check_status=True): + # FIXME maybe should add a pwd arg to teuthology.orchestra so that + # the "cd foo && bar" shenanigans isn't needed to begin with and + # then we wouldn't have to special case this + if isinstance(args, str): + args = 'sudo ' + args + if isinstance(args, list): + args.insert(0, 'sudo') + + return self.client_remote.run(args, wait=wait, cwd=self.mountpoint, + check_status=check_status, + omit_sudo=False) + def setupfs(self, name=None): if name is None and self.fs is not None: # Previous mount existed, reuse the old name