* tried to put some sense in the way things get logged, at least on server-side for now
[sfa.git] / sfa / client / sfiAddAttribute.py
1 #! /usr/bin/env python
2
3 import sys
4 from sfa.util.rspecHelper import RSpec, Commands
5
6 command = Commands(usage="%prog [options] [node1 node2...]",
7                    description="Add sliver attributes to the RSpec. " +
8                    "This command reads in an RSpec and outputs a modified " +
9                    "RSpec. Use this to add attributes to individual nodes " +
10                    "in your slice.  If no nodes are specified, the " +
11                    "attributes will be added to ALL nodes.",
12                    epilog="NOTE: Only admins can actually set these " +
13                    "attributes, with the exception of --delegations")
14 command.add_nodefile_option()
15 command.add_attribute_options()
16 command.prep()
17
18 attrs = command.get_attribute_dict()
19 for name in attrs:
20     for value in attrs[name]:
21         if not command.nodes:
22             try:
23                 command.rspec.add_default_sliver_attribute(name, value)
24             except:
25                 print >> sys.stderr, "FAILED: on all nodes: %s=%s" % (name, value)
26         else:
27             for node in command.nodes:
28                 try:
29                     command.rspec.add_sliver_attribute(node, name, value)
30                 except:
31                     print >> sys.stderr, "FAILED: on node %s: %s=%s" % (node, name, value)
32
33 print command.rspec