* tried to put some sense in the way things get logged, at least on server-side for now
[sfa.git] / sfa / client / sfiDeleteAttribute.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="Delete sliver attributes from the RSpec. " +
8                    "This command reads in an RSpec and outputs a modified " +
9                    "RSpec. Use this to remove attributes from nodes " +
10                    "in your slice.  If no nodes are specified, the " +
11                    "attributes will be removed from 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     print >> sys.stderr, name, attrs[name]
21     for value in attrs[name]:
22         if not command.nodes:
23             try:
24                 command.rspec.remove_default_sliver_attribute(name, value)
25             except:
26                 print >> sys.stderr, "FAILED: on all nodes: %s=%s" % (name, value)
27             else:
28                 for node in command.nodes:
29                     try:
30                         command.rspec.remove_sliver_attribute(node, name, value)
31                     except:
32                         print >> sys.stderr, "FAILED: on node %s: %s=%s" % (node, name, value)
33
34 print command.rspec