5 from sfa.util.sfalogging import logger
6 from sfa.client.sfi_commands import Commands
7 from sfa.rspecs.rspec import RSpec
8 from sfa.rspecs.version_manager import VersionManager
10 logger.enable_console()
11 command = Commands(usage="%prog [options] node1 node2...",
12 description="Add slivers to the RSpec. " +
13 "This command reads in an RSpec and outputs a modified " +
14 "RSpec. Use this to add nodes to your slice.")
15 command.add_nodefile_option()
18 if not command.opts.nodefile:
19 print "Missing node list -- exiting"
20 command.parser.print_help()
23 if command.opts.infile:
24 infile=file(command.opts.infile)
27 if command.opts.outfile:
28 outfile=file(command.opts.outfile,"w")
31 ad_rspec = RSpec(infile)
32 nodes = file(command.opts.nodefile).read().split()
33 version_manager = VersionManager()
35 type = ad_rspec.version.type
36 version_num = ad_rspec.version.version
37 request_version = version_manager._get_version(type, version_num, 'request')
38 request_rspec = RSpec(version=request_version)
39 request_rspec.version.merge(ad_rspec)
40 request_rspec.version.add_slivers(nodes)
42 logger.log_exc("sfiAddSliver failed with nodes %s" % nodes)
44 print >>outfile, request_rspec.toxml()