]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
tools/cephfs-shell: added support for batch file processing and to execute commands...
authorPavani Rajula <rpavani1998@gmail.com>
Sun, 12 Aug 2018 14:55:54 +0000 (20:25 +0530)
committerPavani Rajula <rpavani1998@gmail.com>
Sun, 12 Aug 2018 16:38:38 +0000 (22:08 +0530)
Fixes:http://tracker.ceph.com/issues/26853
Fixes:http://tracker.ceph.com/issues/26855

Signed-off-by: Pavani Rajula <rpavani1998@gmail.com>
doc/cephfs/cephfs-shell.rst
src/tools/cephfs/cephfs-shell

index 5474b4ffb013c01a31312a389bec152ad3a3761a..48cfc104f06fa26dccbf55616672a951238b9356 100644 (file)
@@ -5,6 +5,15 @@ Ceph FS Shell
 
 The File System (FS) shell includes various shell-like commands that directly interact with the Ceph File System.
 
+Usage :
+
+    cephfs-shell [-options] -- [command, command,...]
+
+Options :
+    -c, --config FILE     Set Configuration file.
+    -b, --batch FILE      Process a batch file.
+    -t, --test FILE       Test against transcript(s) in FILE
+
 Commands
 ========
 
index c553aa2f4f4cb6fa83cd374465a86e2d86e82875..bb23263f73819c365b4e57a3666d9a210d15895c 100644 (file)
@@ -911,9 +911,23 @@ sub-directories, files')
 
 if __name__ == '__main__':
     config_file = ''
-    if sys.argv[1] == '-c':
-        config_file = sys.argv[2]
+    exe = sys.argv[0]
+    main_parser = argparse.ArgumentParser(description = '')
+    main_parser.add_argument('-c', '--config', action = 'store', help = 'Configuration file_path', type = str)
+    main_parser.add_argument('-b', '--batch', action = 'store', help = 'Batch File path.', type = str)
+    main_parser.add_argument('-t', '--test', action='store', help='Test against transcript(s) in FILE', nargs = '+')
+    main_parser.add_argument('commands', nargs='*', help='comma delimited commands')  
+    args = main_parser.parse_args()
+    if args.config:
+        config_file = args.config
+        sys.argv = [sys.argv[0]] + sys.argv[3:]  
+    if args.batch:
+        sys.argv[1] = 'load ' + args.batch
+        sys.argv[2] = 'quit'
+        sys.argv = sys.argv[:3]   
+    sys.argv.clear()
+    sys.argv.append(exe)
+    sys.argv.extend(' '.join(args.commands).split(','))
     setup_cephfs(config_file)
-    sys.argv = [sys.argv[0]]
     c = CephFSShell()
     c.cmdloop()