387f9df250ac1868d93ed5220ed4bcdc7728c9ac
[sfa.git] / sfa / client / sfiAddSliver.py
1 #! /usr/bin/env python
2
3 import sys
4 from sfa.client.sfi_commands import Commands
5 from sfa.rspecs.rspec_parser import parse_rspec
6
7 command = Commands(usage="%prog [options] node1 node2...",
8                    description="Add slivers to the RSpec. " +
9                    "This command reads in an RSpec and outputs a modified " +
10                    "RSpec. Use this to add nodes to your slice.")
11 command.add_nodefile_option()
12 command.prep()
13
14 if command.opts.infile:
15     rspec = parse_rspec(command.opts.infile)
16     nodes = []
17     if command.opts.nodefile:
18         f = open(command.opts.nodefile, "r")
19         nodes = f.read().split()
20         f.close()
21
22     try:
23         rspec.add_slivers(nodes)
24     except:
25         print >> sys.stderr, "FAILED: %s" % node
26
27     print rspec.toxml()
28     
29
30