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 links to the RSpec. " +
13 "This command reads in an RSpec and outputs a modified " +
14 "RSpec. Use this to add links to your slivers")
15 command.add_linkfile_option()
18 if not command.opts.linkfile:
19 print "Missing link 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 links = file(command.opts.linkfile).read().split('\n')
33 link_tuples = map(lambda x: tuple(x.split()), links)
35 version_manager = VersionManager()
37 type = ad_rspec.version.type
38 version_num = ad_rspec.version.version
39 request_version = version_manager._get_version(type, version_num, 'request')
40 request_rspec = RSpec(version=request_version)
41 request_rspec.version.merge(ad_rspec)
42 request_rspec.version.add_link_requests(link_tuples)
44 logger.log_exc("sfiAddLinks FAILED with links %s" % links)
46 print >>outfile, request_rspec.toxml()