Whamcloud - gitweb
new --batch <file> option
authorrread <rread>
Tue, 10 Sep 2002 06:34:55 +0000 (06:34 +0000)
committerrread <rread>
Tue, 10 Sep 2002 06:34:55 +0000 (06:34 +0000)
File contains a series of lmc command lines.  All commands are run and
then xml file is saved.

lustre/utils/lmc

index c53a210..d490166 100755 (executable)
@@ -645,7 +645,7 @@ def parse_cmdline(argv):
     short_opts = "ho:i:m:"
     long_opts = ["ost", "osc", "mtpt", "lov=", "node=", "mds=", "net", "tcpbuf=",
                  "route", "router", "merge=", "format", "reformat", "output=",
-                 "obdtype=", "in=", "help"]
+                 "obdtype=", "in=", "help", "batch="]
     opts = []
     args = []
     options = {}
@@ -688,6 +688,8 @@ def parse_cmdline(argv):
             options['format'] = 1
         if o  == "--reformat":
             options['reformat'] = 1
+        if o  == "--batch":
+            options['batch'] = a
         if o  in ("--in" , "-i"):
             options['in'] = a
             
@@ -716,6 +718,27 @@ class chrono:
 ############################################################
 # Main
 #
+def do_command(gen, lustre, options, args):
+    if options.has_key('ost'):
+        add_ost(gen, lustre, options, args)
+    elif options.has_key('osc'):
+        add_osc(gen, lustre, options, args)
+    elif options.has_key('mtpt'):
+        add_mtpt(gen, lustre, options, args)
+    elif options.has_key('mds'):
+        add_mds(gen, lustre, options, args)
+    elif options.has_key('net'):
+        add_net(gen, lustre, options, args)
+    elif options.has_key('lov'):
+        add_lov(gen, lustre, options, args)
+    elif options.has_key('route'):
+        add_route(gen, lustre, options, args)
+    elif options.has_key('node'):
+        add_node(gen, lustre, options, args)
+    else:
+        print "Missing command"
+        usage()
+
 def main():
     options, args = parse_cmdline(sys.argv[1:])
     outFile = '-'
@@ -741,25 +764,16 @@ def main():
         sys.exit(1)
 
     gen = GenConfig(doc)
-    if options.has_key('ost'):
-        add_ost(gen, lustre, options, args)
-    elif options.has_key('osc'):
-        add_osc(gen, lustre, options, args)
-    elif options.has_key('mtpt'):
-        add_mtpt(gen, lustre, options, args)
-    elif options.has_key('mds'):
-        add_mds(gen, lustre, options, args)
-    elif options.has_key('net'):
-        add_net(gen, lustre, options, args)
-    elif options.has_key('lov'):
-        add_lov(gen, lustre, options, args)
-    elif options.has_key('route'):
-        add_route(gen, lustre, options, args)
-    elif options.has_key('node'):
-        add_node(gen, lustre, options, args)
+
+    if options.has_key('batch'):
+        fp = open(options['batch'])
+        batchCommands = fp.readlines()
+        fp.close()
+        for cmd in batchCommands:
+            options, args = parse_cmdline(string.split(cmd))
+            do_command(gen, lustre, options, args)
     else:
-        print "Missing command"
-        usage()
+        do_command(gen, lustre, options, args)
 
     if outFile == '-':
         PrettyPrint(doc)