+ def updateSliceAttributes(self):
+ # Query Node Manager for max rate overrides
+ try:
+ vals = nm.query(self.name,
+ [('nm_net_max_rate', self.maxrate),
+ ('nm_net_max_exempt_rate', self.maxexemptrate),
+ ("nm_net_max_byte", int(self.ByteMax / 1024)),
+ ("nm_net_max_exempt_byte", int(self.ExemptByteMax / 1024)),
+ ("nm_net_max_thresh_byte", int( .8 * self.ByteMax / 1024)),
+ ("nm_net_max_thresh_exempt_byte", int(.8 * self.ExemptByteMax / 1024)),
+ ("nm_net_avg_rate", 0),
+ ("nm_net_avg_exempt_rate", 0)])
+
+ (self.maxrate,
+ self.maxexemptrate,
+ ByteMax,
+ ExemptByteMax,
+ ByteThresh,
+ ExemptByteThresh,
+ avgrate,
+ avgexemptrate) = vals
+
+ # The shitty bit. Gotta bias the limits so as not to overflow xmlrpc
+ self.ByteMax = ByteMax * 1024
+ self.ByteThresh = ByteThresh * 1024
+ self.ExemptByteMax = ExemptByteMax * 1024
+ self.ExemptByteThresh = ExemptByteThresh * 1024
+
+ # The hack here is that when i pass 0 to the xmlrpc request to NM,
+ # for rate limits and it comes back non zero, then screw the byte limits.
+ # Mult by the period and recompute the byte limits. The thought is
+ # If/when PLC switches to byte limits, the avgrates wont be used as
+ # slice attributes and will return as 0
+ if (avgrate != 0):
+ self.ByteMax = int(avgrate * period / 8)
+ self.ByteThresh = int(self.ByteMax * .8)
+
+ if (avgexemptrate != 0):
+ self.ExemptByteMax = int(avgexemptrate * period / 8)
+ self.ExemptByteThresh = int(self.ExemptByteMax * .8)
+
+ except Exception, err:
+ print "Warning: Exception received while querying NM:", err
+