]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
qa: move checks on command arguments to a different method
authorRishabh Dave <ridave@redhat.com>
Thu, 11 Apr 2019 17:16:47 +0000 (22:46 +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 ece01701baf7f79065aebbc25ef096e36dfa2a87..5555eae9c52163f227faa8bca30b30d4c315bca5 100644 (file)
@@ -234,22 +234,30 @@ class LocalRemote(object):
     def put_file(self, src, dst, sudo=False):
         shutil.copy(src, dst)
 
-    def run(self, args, check_status=True, wait=True,
-            stdout=None, stderr=None, cwd=None, stdin=None,
-            logger=None, label=None, env=None, timeout=None, omit_sudo=True):
-        if str(type(args)).find('str') != -1:
+    def _perform_checks_and_return_list_of_args(self, args, omit_sudo):
+        # Since Python's shell simulation can only work when commands are
+        # provided as a list of argumensts...
+        if isinstance(args, str):
             args = args.split()
 
+        # We'll let sudo be a part of command even omit flag says otherwise in
+        # cases of commands which can normally be ran only by root.
         try:
             if args[args.index('sudo') + 1] in ['-u', 'passwd', 'chown']:
                 omit_sudo = False
         except ValueError:
             pass
 
-        # We don't need no stinkin' sudo
         if omit_sudo:
             args = [a for a in args if a != "sudo"]
 
+        return args
+
+    def run(self, args, check_status=True, wait=True,
+            stdout=None, stderr=None, cwd=None, stdin=None,
+            logger=None, label=None, env=None, timeout=None, omit_sudo=True):
+        args = self._perform_checks_and_return_list_of_args(args, omit_sudo)
+
         # We have to use shell=True if any run.Raw was present, e.g. &&
         shell = any([a for a in args if isinstance(a, Raw)])