# 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.5 2006/07/10 15:19:35 faiyaza Exp $
#
import os
os.unlink("/var/run/%s.pid" % prog)
def slicemail(slice, subject, body):
- sendmail = os.popen("/usr/sbin/sendmail -t -f%s" % PLC_MAIL_SUPPORT_ADDRESS, "w")
+ sendmail = os.popen("/usr/sbin/sendmail -N never -t -f%s" % PLC_MAIL_SUPPORT_ADDRESS, "w")
# PLC has a separate list for pl_mom messages
if PLC_MAIL_SUPPORT_ADDRESS == "support@planet-lab.org":
Simple interface to local Node Manager API
"""
- def __init__(self, url = "http://localhost:812/", timeout = 10):
+ def __init__(self, url = "http://localhost:812/", timeout = 30):
"""
Open a new connection to the local Node Manager
"""
-
socket.setdefaulttimeout(timeout)
try:
self.nm = xmlrpclib.ServerProxy(url)
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:
- # Read rspec (the NM hash code for the slice)
+ # Read rspec (the NM hash code for the slice)
rcap = open("/var/run/pl_nm/%s.vm_rcap" % slice, "r")
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
- except Exception, err:
- print "Warning: Exception received while querying Node Manager:", err
- self.nm = None
-
+ (rc, result) = self.nm.nm_inspect(rspec, attributes)
+ if rc == 0 and type(result) == list and len(result) == len(values):
+ values = result
return values