X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=clientbin%2FsfiDeleteAttribute.py;fp=clientbin%2FsfiDeleteAttribute.py;h=7e6a5aeba208661bedfa0c9d16e1a981b5545b8b;hb=a0b08c3177b6273ad22f3882cd62495743ed404c;hp=0000000000000000000000000000000000000000;hpb=4bb9f60eb04e6e7f63f22e1e384c6a306bae05bc;p=sfa.git diff --git a/clientbin/sfiDeleteAttribute.py b/clientbin/sfiDeleteAttribute.py new file mode 100755 index 00000000..7e6a5aeb --- /dev/null +++ b/clientbin/sfiDeleteAttribute.py @@ -0,0 +1,47 @@ +#! /usr/bin/env python + +import sys + +from sfa.util.sfalogging import logger +from sfa.client.sfi_commands import Commands +from sfa.rspecs.rspec import RSpec + +logger.enable_console() +command = Commands(usage="%prog [options] [node1 node2...]", + description="Delete sliver attributes from the RSpec. " + + "This command reads in an RSpec and outputs a modified " + + "RSpec. Use this to remove attributes from nodes " + + "in your slice. If no nodes are specified, the " + + "attributes will be removed from ALL nodes.", + epilog="NOTE: Only admins can actually set these " + + "attributes, with the exception of --delegations") +command.add_nodefile_option() +command.add_attribute_options() +command.prep() + +if command.opts.infile: + attrs = command.get_attribute_dict() + rspec = RSpec(command.opts.infile) + nodes = [] + if command.opts.nodefile: + f = open(command.opts.nodefile, "r") + nodes = f.read().split() + f.close() + + + for name in attrs: + print >> sys.stderr, name, attrs[name] + for value in attrs[name]: + if not nodes: + try: + rspec.version.remove_default_sliver_attribute(name, value) + except: + logger.log_exc("sfiDeleteAttribute FAILED on all nodes: %s=%s" % (name, value)) + else: + for node in nodes: + try: + rspec.version.remove_sliver_attribute(node, name, value) + except: + logger.log_exc("sfiDeleteAttribute FAILED on node %s: %s=%s" % (node, name, value)) + + print rspec.toxml()