def __checkIPAddr(self, ip): """ check if "ip" is valid, raise an exception if not """ if not iplib.checkIPAddrWithoutMask(ip): raise GeneralException( errorText("GENERAL", "INVALID_IP_ADDRESS") % ip)
def __updateRasCheckInput(self, ras_id, ras_ip, ras_description, ras_type, radius_secret, comment): ras_obj = ras_main.getLoader()[ras_id] if ras_obj.getRasIP() != ras_ip: if not iplib.checkIPAddrWithoutMask(ras_ip): raise GeneralException( errorText("RAS", "INVALID_RAS_IP") % ras_ip) if ras_main.getLoader().rasIPExists(ras_ip): raise GeneralException( errorText("RAS", "RAS_IP_ALREADY_EXISTS") % ras_ip) if self.__rasIPExistsInDB(ras_ip): raise GeneralException( errorText("RAS", "RAS_IS_INACTIVE") % ras_ip) if ras_obj.getRasDesc() != ras_description and ras_main.getLoader( ).rasDescExists(ras_description): raise GeneralException( errorText("RAS", "RAS_DESCRIPTION_ALREADY_EXISTS") % ras_description) self.__checkValidRasDescription(ras_description) if not ras_main.getFactory().hasType(ras_type): raise GeneralException( errorText("RAS", "RAS_TYPE_NOT_REGISTERED") % ras_type)
def __addNewRasCheckInput(self,ras_ip,ras_type,radius_secret): if not iplib.checkIPAddrWithoutMask(ras_ip): raise GeneralException(errorText("RAS","INVALID_RAS_IP")%ras_ip) if ras_main.getLoader().rasIPExists(ras_ip): raise GeneralException(errorText("RAS","RAS_IP_ALREADY_EXISTS")%ras_ip) if self.__rasIPExistsInDB(ras_ip): raise GeneralException(errorText("RAS","RAS_IS_INACTIVE")%ras_ip) if not ras_main.getFactory().hasType(ras_type): raise GeneralException(errorText("RAS","RAS_TYPE_NOT_REGISTERED")%ras_type)
def checkIPs(self, ips): for ip in ips: if not iplib.checkIPAddrWithoutMask(ip): raise GeneralException( errorText("GENERAL", "INVALID_IP_ADDRESS") % ip)
def __creditChangeCheckInput(self,remote_address,credit_change_comment): """ check credit changed related inputs and raise exception on errors """ if iplib.checkIPAddrWithoutMask(remote_address)==0: raise GeneralException(errorText("GENERAL","INVALID_IP_ADDRESS")%remote_address)
def __checkIPAddr(self,ip): """ check if "ip" is valid, raise an exception if not """ if not iplib.checkIPAddrWithoutMask(ip): raise GeneralException(errorText("GENERAL","INVALID_IP_ADDRESS")%ip)