From cb262323bca60d7e63b40dc5235fc34afb8ad705 Mon Sep 17 00:00:00 2001 From: Rishabh Dave Date: Thu, 21 Feb 2019 21:52:35 +0530 Subject: [PATCH] qa: add a method to run given command as root user Signed-off-by: Rishabh Dave --- qa/tasks/vstart_runner.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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 -- 2.39.5