def __applyBwLimit(self, user_obj, instance, action): """ apply bandwidth limit on user, this is seperate from simple bandwidth limit user_obj (User.User instance): object of user that we want to apply limit on instance (integer): instance number of user action (integer): can be "apply" and "remove" """ if self.bw_tx_leaf_id == None and self.bw_rx_leaf_id == None: return try: ip_addr = user_obj.getTypeObj().getClientAddr(instance) except GeneralException: logException(LOG_ERROR, "Can't apply bandwidth limit on user") return try: if action == "apply": bw_main.getManager().applyBwLimit(ip_addr, self.bw_tx_leaf_id, self.bw_rx_leaf_id) else: bw_main.getManager().removeBwLimit(ip_addr) except: logException(LOG_ERROR, "Apply Bw Limit")
def __applyBwLimit(self,user_obj,instance,action): """ apply bandwidth limit on user, this is seperate from simple bandwidth limit user_obj (User.User instance): object of user that we want to apply limit on instance (integer): instance number of user action (integer): can be "apply" and "remove" """ if self.bw_tx_leaf_id==None and self.bw_rx_leaf_id==None: return try: ip_addr=user_obj.getTypeObj().getClientAddr(instance) except GeneralException: logException(LOG_ERROR,"Can't apply bandwidth limit on user") if action=="apply": bw_main.getManager().applyBwLimit(ip_addr,self.bw_tx_leaf_id,self.bw_rx_leaf_id) else: bw_main.getManager().removeBwLimit(ip_addr)
def run(self): bw_main.getManager().updateCounters()
def remove(self): bw_main.getManager().removeBwLimit(self.getIP())
def apply(self): bw_main.getManager().applyBwLimit(self.getIP(), self.getTxLeafID(), self.getRxLeafID())
def getActiveLeaves(self, request): request.needAuthType(request.ADMIN) request.getAuthNameObj().canDo("CHANGE BANDWIDTH MANGER") return bw_main.getManager().getAllUserLeavesInfo()
from core.bandwidth_limit import bw_main tc = bw_main.getTCRunner() print tc.getCounters("eth0") print bw_main.getManager().user_leaves["192.168.1.11/32"][1].getDefaultMinorTC_ID() print bw_main.getManager().user_leaves["192.168.1.11/32"][0].getTotalMinorTC_ID() print bw_main.getManager().getAllUserLeavesInfo()["192.168.1.11/32"]
def __getCountersForID(self, _id): return bw_main.getManager().getCounters(self.getInterfaceName(), _id)
def __getCountersForID(self,_id): return bw_main.getManager().getCounters(self.getInterfaceName(),_id)
def getActiveLeaves(self,request): request.needAuthType(request.ADMIN) request.getAuthNameObj().canDo("CHANGE BANDWIDTH MANGER") return bw_main.getManager().getAllUserLeavesInfo()