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")
28 request_rspec = RSpec(infile)
29 nodes = file(command.opts.nodefile).read().split()
30 version_manager = VersionManager()
32 type = request_rspec.version.type
33 version_num = request_rspec.version.version
34 manifest_version = version_manager._get_version(type, version_num, 'manifest')
35 manifest_rspec = RSpec(version=manifest_version)
36 slivers = [{'hostname': node} for node in nodes]
37 manifest_rspec.version.merge(request_rspec)
38 manifest_rspec.version.add_slivers(slivers)
40 print >> sys.stderr, "FAILED: %s" % nodes
42 print >>outfile, manifest_rspec.toxml()