- def update(self):
- # Count down for next check of reset slice.
- if self.resettimeleft > 0:
- self.resettimeleft -= 1
- if debug and verbose: print "%s has %s seconds in probation" \
- %(self.name, self.killtimeleft)
- if self.killtimeleft > 0:
- # Count down kill probation timer (killtimeleft)
- self.killtimeleft -= 1
- if self.killtimeleft == 1:
- print "%s is out of probation" % self.name
- else:
- # Once out of probation period (killtimeleft), remove strikes
- self.resetcount = 0
-
-
- # Check to see if a slice needs to be killed. If it has been killed more
- # than kill_thresh in the probation period (kill_timeout) send an email, kill the slice.
- def checkkill(self,params):
- if self.killtimeleft > 0 and self.resetcount >= kill_thresh:
- if debug:
- print kill_subject % params
- print kill_body % params
- try:
- pid = os.fork()
- if pid == 0:
- print "Slice %s is being killed." % self.name
- vserver = VServer(self.name)
- vserver.stop()
- # ignore initscripts. Don't run anything at start.
- vserver.INITSCRIPTS = []
- vserver.start()
- os._exit(0)
- else:
- os.waitpid(pid,0)
- except Exception, err:
- print "Warning: Exception received while killing slice %s: %s" \
- % (self.name, err)
- if (time.time() - self.killmail) > email_timeout:
- slicemail(self.name, kill_subject % params, kill_body % params)
- print "Sending KILL email for slice %s" % self.name
- self.killmail = time.time()
- return True
- return False
-
- # Reset slice after checking to see if slice is out of timeout.
- # Increment resetcount, check to see if larger than kill_thresh.