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