- deal with error results from NM correctly, and don't give up after a single error
[mom.git] / pl_mom.py
index d889e88..51cb34e 100644 (file)
--- a/pl_mom.py
+++ b/pl_mom.py
@@ -5,7 +5,7 @@
 # Mark Huang <mlhuang@cs.princeton.edu>
 # Copyright (C) 2006 The Trustees of Princeton University
 #
-# $Id: pl_mom.py,v 1.2 2006/05/08 17:37:28 mlhuang Exp $
+# $Id: pl_mom.py,v 1.3 2006/05/09 03:22:25 mlhuang Exp $
 #
 
 import os
@@ -184,10 +184,10 @@ class NM:
         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:
@@ -196,18 +196,10 @@ 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
-                self.nm = None
 
         return values