From: rread Date: Tue, 10 Sep 2002 06:34:55 +0000 (+0000) Subject: new --batch option X-Git-Tag: 0.5.8~70 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=a52fcaf4fe048c1f7ac8a24ec327b895f44643b5;p=fs%2Flustre-release.git new --batch option File contains a series of lmc command lines. All commands are run and then xml file is saved. --- diff --git a/lustre/utils/lmc b/lustre/utils/lmc index c53a210..d490166 100755 --- a/lustre/utils/lmc +++ b/lustre/utils/lmc @@ -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)