# Mark Huang <mlhuang@cs.princeton.edu>
# Copyright (C) 2006 The Trustees of Princeton University
#
-# $Id: pl_mom.py,v 1.1 2006/04/28 19:27:43 mlhuang Exp $
+# $Id: pl_mom.py,v 1.3 2006/05/09 03:22:25 mlhuang Exp $
#
import os
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:
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