def clearUser(self, user_id, ras_id, unique_id, kill_reason, no_commit=True): """ clear instance of user from online if no_commit is true no credit is deducted from user """ user_obj = None self.loading_user.loadingStart(user_id) try: user_obj, instance = self.__getUserAndInstance( user_id, ras_id, unique_id) self.__forceLogoutUser(user_obj, instance, kill_reason, no_commit) finally: self.loading_user.loadingEnd(user_id) if user_obj != None: getLogConsole().log( user_obj.getUserRepr(), "Clear User", [("Ras", ras_main.getLoader().getRasByID(ras_id).getRasIP()), ("ID", unique_id), ("Kill Reason", kill_reason)])
def __checkDuplicateOnline(self, ras_msg): """ check if there's any other user online, with this global unique id """ global_unique_id = (ras_msg.getRasID(), ras_msg.getUniqueIDValue()) if self.ras_onlines.has_key(global_unique_id): current_online_user_obj = apply(self.getUserObjByUniqueID, global_unique_id) current_online_user_id = current_online_user_obj.getUserID() getLogConsole().log(current_online_user_obj.getUserRepr(), "Duplicate Login", [("New User", ras_msg.getUserRepr()), ("Ras", ras_main.getLoader().getRasByID( global_unique_id[0]).getRasIP()), ("ID", global_unique_id[1])]) toLog( "User %s logged on %s, while user %s was on it, force logouting %s" % (ras_msg.getUserRepr(), global_unique_id, current_online_user_id, current_online_user_id), LOG_ERROR) self.clearUser(current_online_user_id, global_unique_id[0], global_unique_id[1], \ "Another user logged on this global unique id", False)
def __checkStaleOnlines(self, user_obj): instance = user_obj.instances while instance > 0: instance_info = user_obj.getInstanceInfo(instance) user_msg = user_obj.createUserMsg(instance, "IS_ONLINE") if user_msg.send(): instance_info["check_online_fails"] = 0 else: instance_info["check_online_fails"] += 1 if instance_info[ "check_online_fails"] == defs.CHECK_ONLINE_MAX_FAILS: toLog( "Maximum Check Online Fails Reached for user %s" % user_obj.getUserID(), LOG_DEBUG) getLogConsole().log( user_obj.getUserRepr(), "Check Online Fail", [("Ras", ras_main.getLoader().getRasByID( instance_info["ras_id"]).getRasIP()), ("ID", "(%s,%s)" % (instance_info["unique_id"], instance_info["unique_id_val"]))]) self.__forceLogoutUser( user_obj, instance, errorText("USER_LOGIN", "MAX_CHECK_ONLINE_FAILS_REACHED", False)) instance -= 1
def _voipUpdate(self, ras_msg): getLogConsole().logUpdateRasMsg(ras_msg) try: user_main.getOnline().updateUser(ras_msg) user_main.getVoIPErrors().applySuccess(ras_msg) except IBSError, e: user_main.getVoIPErrors().applyFailure(ras_msg, e)
def killUser(self, user_id, ras_id, unique_id, kill_reason): user_obj = None self.loading_user.loadingStart(user_id) try: user_obj, instance = self.__getUserAndInstance( user_id, ras_id, unique_id) user_obj.setKillReason(instance, kill_reason) user_obj.getTypeObj().killInstance(instance) finally: self.loading_user.loadingEnd(user_id) if user_obj != None: getLogConsole().log( user_obj.getUserRepr(), "Kill User", [("Ras", ras_main.getLoader().getRasByID(ras_id).getRasIP()), ("ID", unique_id), ("Kill Reason", kill_reason)])
def _voipAuthenticate(self, ras_msg): getLogConsole().logAuthRasMsg(ras_msg) try: user_main.getOnline().voipAuthenticate(ras_msg) getLogConsole().logAuthRasMsgSuccess(ras_msg) return user_main.getVoIPErrors().applySuccess(ras_msg) except IBSError, e: getLogConsole().logAuthRasMsgFailure(ras_msg, e) return user_main.getVoIPErrors().applyFailure(ras_msg, e)
def _planAuthenticate(self, ras_msg): getLogConsole().logAuthRasMsg(ras_msg) try: user_main.getOnline().persistentLanAuthenticate(ras_msg) getLogConsole().logAuthRasMsgSuccess(ras_msg) return True except IBSError, e: getLogConsole().logAuthRasMsgFailure(ras_msg, e) return False
def _internetAuthenticate(self, ras_msg): getLogConsole().logAuthRasMsg(ras_msg) try: user_main.getOnline().internetAuthenticate(ras_msg) getLogConsole().logAuthRasMsgSuccess(ras_msg) return True except IBSError, e: user_main.getDialerErrors().applyToRasMsg(ras_msg, e) getLogConsole().logAuthRasMsgFailure(ras_msg, e) return False
def getConsoleBuffer(self, request): request.needAuthType(request.ADMIN) requester = request.getAuthNameObj() requester.canDo("SEE CONNECTION LOGS") return console_main.getLogConsole().getBufferFormatted( request.getDateType())
def _voipStop(self, ras_msg): getLogConsole().logStopRasMsg(ras_msg) return user_main.getOnline().voipStop(ras_msg)
def _planStop(self, ras_msg): getLogConsole().logStopRasMsg(ras_msg) return user_main.getOnline().persistentLanStop(ras_msg)
def _internetUpdate(self, ras_msg): getLogConsole().logUpdateRasMsg(ras_msg) return user_main.getOnline().updateUser(ras_msg)
def _internetStop(self, ras_msg): getLogConsole().logStopRasMsg(ras_msg) return user_main.getOnline().internetStop(ras_msg)