5 from sfa.util.sfalogging import logger
6 from sfa.client.sfi_commands import Commands
7 from sfa.rspecs.rspec import RSpec
9 logger.enable_console()
10 command = Commands(usage="%prog [options] [node1 node2...]",
11 description="Add sliver attributes to the RSpec. " +
12 "This command reads in an RSpec and outputs a modified " +
13 "RSpec. Use this to add attributes to individual nodes " +
14 "in your slice. If no nodes are specified, the " +
15 "attributes will be added to ALL nodes.",
16 epilog="NOTE: Only admins can actually set these " +
17 "attributes, with the exception of --delegations")
18 command.add_nodefile_option()
19 command.add_attribute_options()
22 if command.opts.infile:
23 attrs = command.get_attribute_dict()
24 rspec = RSpec(command.opts.infile)
26 if command.opts.nodefile:
27 f = open(command.opts.nodefile, "r")
28 nodes = f.read().split()
33 print >> sys.stderr, name, attrs[name]
34 for value in attrs[name]:
37 rspec.version.add_default_sliver_attribute(name, value)
39 logger.log_exc("sfiAddAttribute FAILED on all nodes: %s=%s" % (name, value))
43 rspec.version.add_sliver_attribute(node, name, value)
45 logger.log_exc ("sfiAddAttribute FAILED on node %s: %s=%s" % (node, name, value))