X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=pl_mom.py;h=51cb34e28fbd8b416c5269c1fc7d70c75de07af7;hb=cc74f4314f465de81a5e9a0bc6b31bb19b13346a;hp=532dfd54bf5f443816d94a1bcfde589024ed8b83;hpb=ecd1bafa033312db81872294a5bf099177952821;p=mom.git diff --git a/pl_mom.py b/pl_mom.py index 532dfd5..51cb34e 100644 --- a/pl_mom.py +++ b/pl_mom.py @@ -5,7 +5,7 @@ # Mark Huang # Copyright (C) 2006 The Trustees of Princeton University # -# $Id$ +# $Id: pl_mom.py,v 1.3 2006/05/09 03:22:25 mlhuang Exp $ # import os @@ -179,23 +179,15 @@ class NM: print "Warning: Exception received while opening connection to Node Manager:", err self.nm = None - def close(self): - """ - Close connection to the local Node Manager - """ - - if self.nm is not None: - self.nm.close() - def query(self, slice, attributes): """ Get values of various slice attributes from the local Node Manager slice - slice name - attributes - [attribute_name, (attribute_name, return_value_if_not_set), ...] + attributes - [(attribute_name, return_value_if_not_set), ...] """ - values = [None for attribute in attributes] + values = [attribute[1] for attribute in attributes] if self.nm is not None: try: @@ -204,16 +196,9 @@ class NM: rspec = rcap.readline().strip() rcap.close() - for i, attribute in enumerate(attributes): - # NM interface allows you to pass in a tuple - # (attribute, default) instead of just an - # attribute name. default is returned if the - # attribute is not set. - if type(attribute) != tuple: - attribute = (attribute, 0) - (rc, (value,)) = self.nm.nm_inspect(rspec, [attribute]) - if rc == 0 and value != attribute[1]: - values[i] = value + (rc, result) = self.nm.nm_inspect(rspec, attributes) + if rc == 0 and type(result) == list and len(result) == len(values): + values = result except Exception, err: print "Warning: Exception received while querying Node Manager:", err