4 from sfa.client.sfi_commands import Commands
5 from sfa.rspecs.rspec import RSpec
6 from sfa.rspecs.version_manager import VersionManager
8 command = Commands(usage="%prog [options] node1 node2...",
9 description="Add slivers to the RSpec. " +
10 "This command reads in an RSpec and outputs a modified " +
11 "RSpec. Use this to add nodes to your slice.")
12 command.add_nodefile_option()
15 if not command.opts.nodefile:
16 print "Missing node list -- exiting"
17 command.parser.print_help()
20 if command.opts.infile:
21 infile=file(command.opts.infile)
24 if command.opts.outfile:
25 outfile=file(command.opts.outfile,"w")
29 request_rspec = RSpec(infile)
30 nodes = file(command.opts.nodefile).read().split()
31 version_manager = VersionManager()
33 type = request_rspec.version.type
34 version_num = request_rspec.version.version
35 manifest_version = version_manager._get_version(type, version_num, 'manifest')
36 manifest_rspec = RSpec(version=manifest_version)
37 slivers = [{'hostname': node} for node in nodes]
38 manifest_rspec.version.merge(request_rspec)
39 manifest_rspec.version.add_slivers(slivers)
41 print >> sys.stderr, "FAILED: %s" % nodes
43 print >>outfile, manifest_rspec.toxml(cleanup=True)