command.add_nodefile_option()
command.prep()
-if command.opts.infile:
- rspec = parse_rspec(command.opts.infile)
- nodes = []
- if command.opts.nodefile:
- f = open(command.opts.nodefile, "r")
- nodes = f.read().split()
- f.close()
-
- try:
- rspec.add_slivers(nodes)
- except:
- print >> sys.stderr, "FAILED: %s" % node
-
- print rspec.toxml()
+if not command.opts.nodefile:
+ print "Missing node list -- exiting"
+ command.parser.print_help()
+ sys.exit(1)
+if command.opts.infile:
+ infile=file(command.opts.infile)
+else:
+ infile=sys.stdin
+if command.opts.outfile:
+ outfile=file(command.opts.outfile,"w")
+else:
+ outfile=sys.stdout
-
+rspec = parse_rspec(infile)
+nodes = file(command.opts.nodefile).read().split()
+try:
+ rspec.add_slivers(nodes)
+except:
+ print >> sys.stderr, "FAILED: %s" % node
+print >>outfile, rspec.toxml()