]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
qa: add a method to run given command as root user
authorRishabh Dave <ridave@redhat.com>
Thu, 21 Feb 2019 16:22:35 +0000 (21:52 +0530)
committerRishabh Dave <ridave@redhat.com>
Fri, 12 Apr 2019 09:30:58 +0000 (15:00 +0530)
Signed-off-by: Rishabh Dave <ridave@redhat.com>
qa/tasks/vstart_runner.py

index d1c628df72241815e2abb4ba96c71ea4574fe2f1..b63e62965c0bb153010375e005f68ad88964474a 100644 (file)
@@ -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