new_maxrate = self.MaxRate * 1000
self.capped = False
- ## Format template parameters for low bandwidth message
- #params['class'] = "low bandwidth"
- #params['bytes'] = format_bytes(usedbytes - self.bytes)
- #params['limit'] = format_bytes(self.MaxKByte * 1024)
- #params['thresh'] = format_bytes(self.ThreshKByte * 1024)
- #params['new_maxrate'] = bwlimit.format_tc_rate(new_maxrate)
-
- # Cap low bandwidth burst rate
- #if new_maxrate != runningmaxrate:
- # message += template % params
- # logger.log("bwmon: ** %(slice)s %(class)s capped at %(new_maxrate)s/s " % params)
-
+
if usedi2bytes >= (self.i2bytes + (self.Threshi2KByte * 1024)):
maxi2byte = self.Maxi2KByte * 1024
i2bytesused = usedi2bytes - self.i2bytes
new_maxi2rate = self.Maxi2Rate * 1000
self.capped = False
- # Format template parameters for high bandwidth message
- #params['class'] = "high bandwidth"
- #params['bytes'] = format_bytes(usedi2bytes - self.i2bytes)
- #params['limit'] = format_bytes(self.Maxi2KByte * 1024)
- #params['new_maxexemptrate'] = bwlimit.format_tc_rate(new_maxi2rate)
-
- # Cap high bandwidth burst rate
- #if new_maxi2rate != runningmaxi2rate:
- # message += template % params
- # logger.log("bwmon: %(slice)s %(class)s capped at %(new_maxexemptrate)s/s" % params)
-
# Apply parameters
if new_maxrate != runningmaxrate or new_maxi2rate != runningmaxi2rate:
bwlimit.set(xid = self.xid, maxrate = new_maxrate, maxexemptrate = new_maxi2rate)
# Notify slice
if self.capped == True and self.emailed == False:
self.notify(newmaxrate, newmaxexemptrate, usedbytes, usedi2bytes)
- # subject = "pl_mom capped bandwidth of slice %(slice)s on %(hostname)s" % params
- # if debug:
- # logger.log("bwmon: "+ subject)
- # logger.log("bwmon: "+ message + (footer % params))
- # else:
- # self.emailed = True
- # slicemail(self.name, subject, message + (footer % params))
+
def gethtbs(root_xid, default_xid):
"""
# default
default=file("/etc/planetlab/slicefamily").read().strip()
(pldistro,fcdistro,arch) = default.split("-")
+
+ known_archs = [ 'i386', 'x86_64' ]
+ known_fcdistros = [ 'f8', 'f9', 'centos5' ]
# from the slice attribute: cut dashes and try to figure the meaning
slice_wishes = vref.split("-")
for wish in slice_wishes:
- if wish == "i386" or wish == "x86_64":
+ if wish in known_archs:
arch=wish
- elif wish == "f8" or wish == "centos5" :
+ elif wish in known_fcdistros:
fcdistro=wish
else:
pldistro=wish
if self.rspec['enabled'] > 0:
logger.log('%s: starting in %d seconds' % (self.name, delay))
time.sleep(delay)
- # VServer.start calls fork() internally
- vserver.VServer.start(self)
-
+ child_pid = os.fork()
+ if child_pid == 0:
+ # VServer.start calls fork() internally,
+ # so just close the nonstandard fds and fork once to avoid creating zombies
+ tools.close_nonstandard_fds()
+ vserver.VServer.start(self)
+ os._exit(0)
+ else: os.waitpid(child_pid, 0)
else: logger.log('%s: not starting, is not enabled' % self.name)
self.initscriptchanged = False