#
# Faiyaz Ahmed <faiyaza@cs.princeton.edu>
#
-# $Id: policy.py,v 1.4 2006/11/14 19:20:13 faiyaza Exp $
+# $Id: policy.py,v 1.7 2007/01/11 21:39:07 faiyaza Exp $
#
# Policy Engine.
POLSLEEP = 7200
# Where to email the summary
-#SUMTO = "pupadm@lists.planet-lab.org"
SUMTO = "faiyaza@cs.princeton.edu"
TECHEMAIL="tech-%s@sites.planet-lab.org"
PIEMAIL="pi-%s@sites.planet-lab.org"
#Thresholds (DAYS)
SPERDAY = 86400
-PITHRESH = 1 * SPERDAY
+PITHRESH = 2 * SPERDAY
SLICETHRESH = 5 * SPERDAY
# Days before attempting rins again
RINSTHRESH = 5 * SPERDAY
node = self.sickNoTicket.get(block = True)
# Get the login base
loginbase = plc.siteId(node)
+
+ # Princeton Backdoor
+ if loginbase == "princeton": return
# Send appropriate message for node if in appropriate bucket.
# If we know where to send a message
logger.info("POLICY: acted %s on %s days ago" % (node,
delta // SPERDAY))
+
+ # If no luck with tech, email PI
+ if (delta >= 1):
+ target.append(PIEMAIL % loginbase)
# If more than PI thresh, but less than slicethresh
if (delta >= PITHRESH) and (delta < SLICETHRESH):
- target.append(PIEMAIL % loginbase)
#remove slice creation if enough nodes arent up
if not self.enoughUp(loginbase):
+ slices = plc.slices(loginbase)
+ if len(slices) >= 1:
+ for slice in slices:
+ target.append(SLICEMAIL % slice)
logger.info("POLICY: Removing slice creation from %s" % loginbase)
+ tmp = emailTxt.mailtxt.removedSliceCreation
+ sbj = tmp[0]
+ msg = tmp[1] % {'loginbase': loginbase}
plc.removeSliceCreation(node)
+ mailer.email(sbj, msg, target)
self.squeezed[loginbase] = (time.time(), "creation")
+ self.emailed[node] = ("creation", time.time())
+ return
+
# If more than PI thresh and slicethresh
if (delta >= PITHRESH) and (delta > SLICETHRESH):
+ target.append(PIEMAIL % loginbase)
# Email slices at site.
slices = plc.slices(loginbase)
if len(slices) >= 1:
for slice in slices:
target.append(SLICEMAIL % slice)
- if not self.enoughUp(loginbase):
- plc.suspendSlices(node)
- self.squeezed[loginbase] = (time.time(),
- "freeze")
+ # If not enough up, freeze slices and email everyone.
+ if not self.enoughUp(loginbase):
+ logger.info("POLICY: Suspending %s slices." % loginbase)
+ tmp = emailTxt.mailtxt.suspendSlices
+ sbj = tmp[0]
+ msg = tmp[1] % {'loginbase': loginbase}
+ plc.suspendSlices(node)
+ self.squeezed[loginbase] = (time.time(), "freeze")
+ mailer.email(sbj, msg, target)
+ self.emailed[node] = ("freeze", time.time())
+ return
# Find the bucket the node is in and send appropriate email
# to approriate list of people.