X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Fclient%2FsfiAddAttribute.py;h=6fa51b40c9e1b3cc56f03f2f91caf0d9f32c25c8;hb=1a4812982ba0979c9cb2ce0b0e6275b910befb4b;hp=33b94a3aa4a844c901c0901c7aa39f715e711816;hpb=b625e2bd933f5e2a4faf4513c1be0069d88e7521;p=sfa.git diff --git a/sfa/client/sfiAddAttribute.py b/sfa/client/sfiAddAttribute.py index 33b94a3a..6fa51b40 100755 --- a/sfa/client/sfiAddAttribute.py +++ b/sfa/client/sfiAddAttribute.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="Add sliver attributes to the RSpec. " + "This command reads in an RSpec and outputs a modified " + @@ -15,22 +19,29 @@ command.add_nodefile_option() command.add_attribute_options() command.prep() -attrs = command.get_attribute_dict() -for name in attrs: - for value in attrs[name]: - if not command.nodes: - try: - command.rspec.add_default_sliver_attribute(name, value) - except: - print >> sys.stderr, "FAILED: on all nodes: %s=%s" % (name, value) - else: - for node in command.nodes: +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: - command.rspec.add_sliver_attribute(node, name, value) + rspec.version.add_default_sliver_attribute(name, value) except: - print >> sys.stderr, "FAILED: on node %s: %s=%s" % (node, name, value) - -print command.rspec - + logger.log_exc("sfiAddAttribute FAILED on all nodes: %s=%s" % (name, value)) + else: + for node in nodes: + try: + rspec.version.add_sliver_attribute(node, name, value) + except: + logger.log_exc ("sfiAddAttribute FAILED on node %s: %s=%s" % (node, name, value)) - + print rspec.toxml()