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="Delete sliver attributes from the RSpec. " +
12 "This command reads in an RSpec and outputs a modified " +
13 "RSpec. Use this to remove attributes from nodes " +
14 "in your slice. If no nodes are specified, the " +
15 "attributes will be removed from 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.remove_default_sliver_attribute(name, value)
39 logger.log_exc("sfiDeleteAttribute FAILED on all nodes: %s=%s" % (name, value))
43 rspec.version.remove_sliver_attribute(node, name, value)
45 logger.log_exc("sfiDeleteAttribute FAILED on node %s: %s=%s" % (node, name, value))