X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Fclient%2FsfiDeleteAttribute.py;h=7e6a5aeba208661bedfa0c9d16e1a981b5545b8b;hb=69fb221c274eb0b6e9f6ff6f895e5e6f90b17230;hp=f248e495f125719a7575a5d5da4ba3570a7dd10d;hpb=0cf0d31c313a366e3f272f830bdb4f2a7308e11f;p=sfa.git diff --git a/sfa/client/sfiDeleteAttribute.py b/sfa/client/sfiDeleteAttribute.py index f248e495..7e6a5aeb 100755 --- a/sfa/client/sfiDeleteAttribute.py +++ b/sfa/client/sfiDeleteAttribute.py @@ -1,8 +1,12 @@ #! /usr/bin/env python import sys -from sfa.util.rspecHelper import RSpec, Commands +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 " + @@ -15,20 +19,29 @@ command.add_nodefile_option() command.add_attribute_options() command.prep() -attrs = command.get_attribute_dict() -for name in attrs: - print >> sys.stderr, name, attrs[name] - for value in attrs[name]: - if not command.nodes: - try: - command.rspec.remove_default_sliver_attribute(name, value) - except: - print >> sys.stderr, "FAILED: on all nodes: %s=%s" % (name, value) +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 command.nodes: + for node in nodes: try: - command.rspec.remove_sliver_attribute(node, name, value) + rspec.version.remove_sliver_attribute(node, name, value) except: - print >> sys.stderr, "FAILED: on node %s: %s=%s" % (node, name, value) + logger.log_exc("sfiDeleteAttribute FAILED on node %s: %s=%s" % (node, name, value)) -print command.rspec + print rspec.toxml()