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