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 links to the RSpec. " +
10 "This command reads in an RSpec and outputs a modified " +
11 "RSpec. Use this to add links to your slivers")
12 command.add_linkfile_option()
15 if not command.opts.linkfile:
16 print "Missing link 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 ad_rspec = RSpec(infile)
29 links = file(command.opts.linkfile).read().split('\n')
30 link_tuples = map(lambda x: tuple(x.split()), links)
32 version_manager = VersionManager()
34 type = ad_rspec.version.type
35 version_num = ad_rspec.version.version
36 request_version = version_manager._get_version(type, version_num, 'request')
37 request_rspec = RSpec(version=request_version)
38 request_rspec.version.merge(ad_rspec)
39 request_rspec.version.add_link_requests(link_tuples)
41 print >> sys.stderr, "FAILED: %s" % links
44 print >>outfile, request_rspec.toxml()