]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume: main: changes to sys.argv handling for better testing
authorAlfredo Deza <adeza@redhat.com>
Wed, 12 Jul 2017 20:39:58 +0000 (16:39 -0400)
committerAlfredo Deza <adeza@redhat.com>
Fri, 4 Aug 2017 14:25:58 +0000 (10:25 -0400)
Signed-off-by: Alfredo Deza <adeza@redhat.com>
src/ceph-volume/ceph_volume/main.py

index 0a269ebd7ac56bc782e9e7fa7140d7381703216b..ca819bbe2364944c1855de977a530ee42cfced57 100644 (file)
@@ -29,9 +29,11 @@ Ceph Conf: {ceph_path}
         self.mapper = {'lvm': devices.lvm.LVM}
         self.plugin_help = "No plugins found/loaded"
         if argv is None:
-            argv = sys.argv
+            self.argv = sys.argv
+        else:
+            self.argv = argv
         if parse:
-            self.main(argv)
+            self.main(self.argv)
 
     def help(self, warning=False):
         warning = 'See "ceph-volume --help" for full list of options.' if warning else ''
@@ -87,13 +89,13 @@ Ceph Conf: {ceph_path}
 
     def _get_sanitized_args(self):
         subcommands = self.mapper.keys()
-        slice_on_index = len(sys.argv) + 1
-        pruned_args = sys.argv[1:]
+        slice_on_index = len(self.argv) + 1
+        pruned_args = self.argv[1:]
         for count, arg in enumerate(pruned_args):
             if arg in subcommands:
                 slice_on_index = count
                 break
-        return sys.argv[:slice_on_index]
+        return self.argv[:slice_on_index]
 
     @catches()
     def main(self, argv):
@@ -105,7 +107,7 @@ Ceph Conf: {ceph_path}
         sanitized_args = self._get_sanitized_args()
         # no flags where passed in, return the help menu instead of waiting for
         # argparse which will end up complaning that there are no args
-        if len(sys.argv) <= 1:
+        if len(argv) <= 1:
             print self.help(warning=True)
             return
         parser = argparse.ArgumentParser(