honor -i and -o as advertised
[sfa.git] / sfa / client / sfiAddSliver.py
index be1c51c..2b9668b 100755 (executable)
@@ -1,7 +1,8 @@
 #! /usr/bin/env python
 
 import sys
-from sfa.util.rspecHelper import RSpec, Commands
+from sfa.client.sfi_commands import Commands
+from sfa.rspecs.rspec_parser import parse_rspec
 
 command = Commands(usage="%prog [options] node1 node2...",
                    description="Add slivers to the RSpec. " +
@@ -10,13 +11,24 @@ command = Commands(usage="%prog [options] node1 node2...",
 command.add_nodefile_option()
 command.prep()
 
-for node in command.nodes:
-    try:
-        command.rspec.add_sliver(node)
-    except:
-        print >> sys.stderr, "FAILED: %s" % node
-
-print command.rspec
+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()