Example #1
0
    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")
Example #2
0
    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)
Example #3
0
 def run(self):
     bw_main.getManager().updateCounters()
Example #4
0
 def remove(self):
     bw_main.getManager().removeBwLimit(self.getIP())
Example #5
0
 def run(self):
     bw_main.getManager().updateCounters()
Example #6
0
 def apply(self):
     bw_main.getManager().applyBwLimit(self.getIP(), self.getTxLeafID(), self.getRxLeafID())
Example #7
0
 def getActiveLeaves(self, request):
     request.needAuthType(request.ADMIN)
     request.getAuthNameObj().canDo("CHANGE BANDWIDTH MANGER")
     return bw_main.getManager().getAllUserLeavesInfo()
Example #8
0
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"]
Example #9
0
 def __getCountersForID(self, _id):
     return bw_main.getManager().getCounters(self.getInterfaceName(), _id)
Example #10
0
    def __getCountersForID(self,_id):
	return bw_main.getManager().getCounters(self.getInterfaceName(),_id)
Example #11
0
 def remove(self):
     bw_main.getManager().removeBwLimit(self.getIP())
Example #12
0
 def apply(self):
     bw_main.getManager().applyBwLimit(self.getIP(), self.getTxLeafID(),
                                       self.getRxLeafID())
Example #13
0
    def getActiveLeaves(self,request):
	request.needAuthType(request.ADMIN)
	request.getAuthNameObj().canDo("CHANGE BANDWIDTH MANGER")
	return bw_main.getManager().getAllUserLeavesInfo()