def end(self,user_obj,instance): """ called when this rule ends for user_obj user_obj (User.User instance): object of user that this rule change for instance (integer): instance number of user """ ChargeRule.end(self,user_obj,instance) if self.bandwidth_limit>0: simple_bw_limit.removeLimitOnUser(user_obj,instance) self.__applyBwLimit(user_obj,instance,"remove")
def end(self, user_obj, instance): """ called when this rule ends for user_obj user_obj (User.User instance): object of user that this rule change for instance (integer): instance number of user """ ChargeRule.end(self, user_obj, instance) if self.bandwidth_limit > 0: simple_bw_limit.removeLimitOnUser(user_obj, instance) self.__applyBwLimit(user_obj, instance, "remove")
def end(self,user_obj,instance): """ called when this rule ends for user_obj user_obj (User.User instance): object of user that this rule change for instance (integer): instance number of user """ ChargeRule.end(self,user_obj,instance) rule_duration=time.time() - user_obj.charge_info.rule_start[instance-1] if rule_duration>user_obj.charge_info.remaining_free_seconds[instance-1]: user_obj.charge_info.remaining_free_seconds[instance-1]=0 else: user_obj.charge_info.remaining_free_seconds[instance-1]-=rule_duration
def start(self,user_obj,instance): """ called when this rule starts for user_obj user_obj (User.User instance): object of user that this rule change for instance (integer): instance number of user """ ChargeRule.start(self,user_obj,instance) user_obj.charge_info.rule_start_inout[instance-1]=user_obj.getTypeObj().getInOutBytes(instance) if self.bandwidth_limit>0: simple_bw_limit.applyLimitOnUser(user_obj,instance,self.bandwidth_limit) self.__applyBwLimit(user_obj,instance,"apply")
def start(self,user_obj,instance): """ called when this rule starts for user_obj user_obj (User.User instance): object of user that this rule change for instance (integer): instance number of user """ ChargeRule.start(self,user_obj,instance) prefix_obj=self.getPrefixObj(user_obj,instance,False) user_obj.charge_info.prefix_id[instance-1]=prefix_obj.getPrefixID() if user_obj.charge_info.remaining_free_seconds[instance-1]==-1:#we're the first rule of this instance user_obj.charge_info.remaining_free_seconds[instance-1]=prefix_obj.getFreeSeconds() instance_info=user_obj.getInstanceInfo(instance) instance_info["min_duration"]=prefix_obj.getMinDuration() instance_info["attrs"]["prefix_name"]=prefix_obj.getPrefixName()
def start(self, user_obj, instance): """ called when this rule starts for user_obj user_obj (User.User instance): object of user that this rule change for instance (integer): instance number of user """ ChargeRule.start(self, user_obj, instance) user_obj.charge_info.rule_start_inout[ instance - 1] = user_obj.getTypeObj().getInOutBytes(instance) if self.bandwidth_limit > 0: simple_bw_limit.applyLimitOnUser(user_obj, instance, self.bandwidth_limit) self.__applyBwLimit(user_obj, instance, "apply")
def end(self, user_obj, instance): """ called when this rule ends for user_obj user_obj (User.User instance): object of user that this rule change for instance (integer): instance number of user """ ChargeRule.end(self, user_obj, instance) rule_duration = time.time() - user_obj.charge_info.rule_start[instance - 1] if rule_duration > user_obj.charge_info.remaining_free_seconds[instance - 1]: user_obj.charge_info.remaining_free_seconds[instance - 1] = 0 else: user_obj.charge_info.remaining_free_seconds[instance - 1] -= rule_duration
def getInfo(self): dic=ChargeRule.getInfo(self) dic["type"]="VoIP" dic["tariff_id"]=self.tariff_id dic["tariff_name"]=self.getTariffObj().getTariffName() return dic
def start(self, user_obj, instance): """ called when this rule starts for user_obj user_obj (User.User instance): object of user that this rule change for instance (integer): instance number of user """ ChargeRule.start(self, user_obj, instance) prefix_obj = self.getPrefixObj(user_obj, instance, False) user_obj.charge_info.prefix_id[instance - 1] = prefix_obj.getPrefixID() if user_obj.charge_info.remaining_free_seconds[ instance - 1] == -1: #we're the first rule of this instance user_obj.charge_info.remaining_free_seconds[ instance - 1] = prefix_obj.getFreeSeconds() instance_info = user_obj.getInstanceInfo(instance) instance_info["min_duration"] = prefix_obj.getMinDuration() instance_info["attrs"]["prefix_name"] = prefix_obj.getPrefixName()
def anytimeAppliable(self, user_obj, instance): called_number = user_obj.getTypeObj().getCalledNumber(instance) if called_number != "": has_prefix = self.hasPrefixFor(called_number) else: #we didn't acquire user dialed number yet has_prefix = True return has_prefix and ChargeRule.anytimeAppliable( self, user_obj, instance)
def __init__(self, rule_id, charge_obj, cpm, cpk, day_of_weeks, start, end, bandwidth_limit, bw_tx_leaf_id, bw_rx_leaf_id, assumed_kps, ras_id, ports): """ rule_id (integer) : unique id of this rule cpm (integer): Charge Per Minute cpk (integer): Charge Per KiloByte day_of_weeks (DayOfWeekIntContainer instance): Days Of Week of this rule start (integer): Rule start time, seconds from 00:00:00 end (integer): Rule end Time, seconds from 00:00:00 bandwidth_limit (integer): bandwidth limit KiloBytes, now useful for lan (vpn) users only bw_tx_leaf_id (integer): id of leaf, used for bandwidth manager to shape user transmit, can be None that means no leaf_id specified bw_rx_leaf_id (integer): same as bw_tx_leaf_id but used for user recieve shaping assumed_kps (integer): assumed (maximum) transfer rate for this rule in KiloBytes per seconds this is used to determine maximum user transfer rate and the soonest time that user with this rule can consume a limited amount of allowed transfer ras_id (integer): ras id, this rule will apply to users that login on this ras_id , if set to self.ALL, if there wasn't any exact match for user, this rule will be used ports (list): List of ports belongs to ras_id that this rule will apply to. if ras_id matches and port not matched, the total result is not match and we look for another rule or wildcard rule(self.ALL) if Ports is an empty array, it'll be used for all not matched users """ ChargeRule.__init__(self, rule_id, charge_obj, day_of_weeks, start, end, ras_id, ports) self.bandwidth_limit = bandwidth_limit self.assumed_kps = assumed_kps self.cpm = cpm self.cpk = cpk self.bw_tx_leaf_id = bw_tx_leaf_id self.bw_rx_leaf_id = bw_rx_leaf_id
def __init__(self,rule_id,charge_obj,day_of_week,start,end,tariff_id,ras_id,ports): """ rule_id (integer) : unique id of this rule day_of_week (integer): Day Of Week of this rule start (integer): Rule start time, seconds from 00:00:00 end (integer): Rule end Time, seconds from 00:00:00 tariff_id (integer): tariff list which we try to find cpm from ras_id (integer): ras id, this rule will apply to users that login on this ras_id , if set to None, if there wasn't any exact match for user, this rule will be used ports (list): List of ports belongs to ras_id that this rule will apply to. if ras_id matches and port not matched, the total result is not match and we look for another rule or wildcard rule(None) if Ports is an empty array, it'll be used for all not matched users """ ChargeRule.__init__(self,rule_id,charge_obj,day_of_week,start,end,ras_id,ports) self.tariff_id=tariff_id
def __init__(self,rule_id,charge_obj,cpm,cpk,day_of_weeks,start,end,bandwidth_limit,bw_tx_leaf_id,bw_rx_leaf_id,assumed_kps,ras_id,ports): """ rule_id (integer) : unique id of this rule cpm (integer): Charge Per Minute cpk (integer): Charge Per KiloByte day_of_weeks (DayOfWeekIntContainer instance): Days Of Week of this rule start (integer): Rule start time, seconds from 00:00:00 end (integer): Rule end Time, seconds from 00:00:00 bandwidth_limit (integer): bandwidth limit KiloBytes, now useful for lan (vpn) users only bw_tx_leaf_id (integer): id of leaf, used for bandwidth manager to shape user transmit, can be None that means no leaf_id specified bw_rx_leaf_id (integer): same as bw_tx_leaf_id but used for user recieve shaping assumed_kps (integer): assumed (maximum) transfer rate for this rule in KiloBytes per seconds this is used to determine maximum user transfer rate and the soonest time that user with this rule can consume a limited amount of allowed transfer ras_id (integer): ras id, this rule will apply to users that login on this ras_id , if set to self.ALL, if there wasn't any exact match for user, this rule will be used ports (list): List of ports belongs to ras_id that this rule will apply to. if ras_id matches and port not matched, the total result is not match and we look for another rule or wildcard rule(self.ALL) if Ports is an empty array, it'll be used for all not matched users """ ChargeRule.__init__(self,rule_id,charge_obj,day_of_weeks,start,end,ras_id,ports) self.bandwidth_limit=bandwidth_limit self.assumed_kps=assumed_kps self.cpm=cpm self.cpk=cpk self.bw_tx_leaf_id=bw_tx_leaf_id self.bw_rx_leaf_id=bw_rx_leaf_id
def getInfo(self): dic=ChargeRule.getInfo(self) dic["type"]="Internet" dic["bandwidth_limit"]=self.bandwidth_limit dic["assumed_kps"]=self.assumed_kps dic["cpm"]=self.cpm dic["cpk"]=self.cpk if self.bw_tx_leaf_id==None: dic["bw_tx_leaf_name"]='' dic["bw_rx_leaf_name"]='' else: dic["bw_tx_leaf_name"]=bw_main.getLoader().getLeafByID(self.bw_tx_leaf_id).getLeafName() dic["bw_rx_leaf_name"]=bw_main.getLoader().getLeafByID(self.bw_rx_leaf_id).getLeafName() return dic
def __init__(self, rule_id, charge_obj, day_of_week, start, end, tariff_id, ras_id, ports): """ rule_id (integer) : unique id of this rule day_of_week (integer): Day Of Week of this rule start (integer): Rule start time, seconds from 00:00:00 end (integer): Rule end Time, seconds from 00:00:00 tariff_id (integer): tariff list which we try to find cpm from ras_id (integer): ras id, this rule will apply to users that login on this ras_id , if set to None, if there wasn't any exact match for user, this rule will be used ports (list): List of ports belongs to ras_id that this rule will apply to. if ras_id matches and port not matched, the total result is not match and we look for another rule or wildcard rule(None) if Ports is an empty array, it'll be used for all not matched users """ ChargeRule.__init__(self, rule_id, charge_obj, day_of_week, start, end, ras_id, ports) self.tariff_id = tariff_id
def getInfo(self): dic = ChargeRule.getInfo(self) dic["type"] = "Internet" dic["bandwidth_limit"] = self.bandwidth_limit dic["assumed_kps"] = self.assumed_kps dic["cpm"] = self.cpm dic["cpk"] = self.cpk if self.bw_tx_leaf_id == None: dic["bw_tx_leaf_name"] = '' dic["bw_rx_leaf_name"] = '' else: dic["bw_tx_leaf_name"] = bw_main.getLoader().getLeafByID( self.bw_tx_leaf_id).getLeafName() dic["bw_rx_leaf_name"] = bw_main.getLoader().getLeafByID( self.bw_rx_leaf_id).getLeafName() return dic
def anytimeAppliable(self,user_obj,instance): return ChargeRule.anytimeAppliable(self,user_obj,instance) and self.hasPrefixFor(user_obj.getTypeObj().getCalledNumber(instance))
def getInfo(self): dic = ChargeRule.getInfo(self) dic["type"] = "VoIP" dic["tariff_id"] = self.tariff_id dic["tariff_name"] = self.getTariffObj().getTariffName() return dic