ByteThresh - After thresh, cap node to (maxbyte - bytes)/(time left in period)
ExemptByteMax - Same as above, but for i2.
ExemptByteThresh - i2 ByteThresh
- #last_maxexemptrate - last recorded maxexemptrate from NM. Slice attribute.
- #last_maxrate - last recorded maxrate from NM. Slice attribute.
- #last_ByteMax - Last recorded from NM. total volume of data allowed.
- #last_ByteThresh - Last recorded from NM. After thresh, cap node to (maxbyte - bytes)/(period - t)
- #last_ExemptByteMax - Last recorded from NM. Same as above, but for i2.
- #last_ExemptByteThresh - Last recorded from NM. i2 ByteThresh
"""
self.ExemptByteThresh = default_ExemptByteThresh
self.maxrate = default_maxrate
self.maxexemptrate = default_maxexemptrate
- #self.last_maxrate = default_maxrate
- #self.last_maxexemptrate = default_maxexemptrate
- #self.last_ByteMax = default_ByteMax
- #self.last_ByteThresh = default_ByteThresh
- #self.last_ExemptByteMax = default_ExemptByteMax
- #self.last_ExemptByteThresh = default_ExemptByteThresh
# Get real values where applicable
self.reset(maxrate, maxexemptrate, bytes, exemptbytes)
def update(self, maxrate, maxexemptrate, bytes, exemptbytes):
"""
- Update byte counts and check if average rates have been
- exceeded. In the worst case (instantaneous usage of the entire
- average daily byte limit at the beginning of the recording
- period), the slice will be immediately capped and will get to
- send twice the average daily byte limit. In the common case,
- it will get to send slightly more than the average daily byte
- limit.
+ Update byte counts and check if byte limits have been
+ exceeded.
"""
# Query Node Manager for max rate overrides
'date': time.asctime(time.gmtime()) + " GMT",
'period': format_period(period)}
+ print("byts %s self.bytes %s ByteThresh %s" %(bytes, self.bytes, self.ByteThresh))
if bytes >= (self.bytes + self.ByteThresh):
- new_maxrate = (self.ByteMax - self.ByteThresh)/(period - (time.time() - self.time))
+ new_maxrate = int(self.ByteMax - self.ByteThresh)/(period - (time.time() - self.time))
else:
new_maxrate = maxrate
if verbose:
print "%(slice)s %(class)s " \
- "%(bytes)s, %(limit)s (%(new_maxrate)s avg)" % \
+ "%(bytes)s, %(limit)s (%(new_maxrate)s maxrate)" % \
params
# Cap low bandwidth burst rate
if exemptbytes >= (self.exemptbytes + self.ExemptByteThresh):
new_maxexemptrate = \
- (self.ExemptByteMax - self.ExemptByteThresh)/(period - (time.time() - self.time))
+ int((self.ExemptByteMax - self.ExemptByteThresh)/(period - (time.time() - self.time)))
else:
new_maxexemptrate = maxexemptrate
else:
slicemail(self.name, subject, message + (footer % params))
+
+
def usage():
print """
Usage: %s [OPTIONS]...
bytes, exemptbytes) = params
live.append(xid)
- # Delete Me
- print("name %s , minrate %s, maxrate %s, minexemptrate %s, maxexemptrate %s, bytes %s, exemptbytes %s" % (bwlimit.get_slice(xid), minrate, maxrate, minexemptrate, maxexemptrate, bytes, exemptbytes))
+ if verbose:
+ print("\n%s, minrate %s, maxrate %s, minexemptrate %s,"\
+ " maxexemptrate %s, bytes %s, exemptbytes %s" % \
+ (bwlimit.get_slice(xid),
+ bwlimit.format_tc_rate(minrate),
+ bwlimit.format_tc_rate(maxrate),
+ bwlimit.format_tc_rate(minexemptrate),
+ bwlimit.format_tc_rate(maxexemptrate),
+ bytes,
+ exemptbytes))
# Ignore root and default buckets
if xid == root_xid or xid == default_xid: