Example #1
0
    def logConnectionQuery(self, user_id, credit_used, login_time, logout_time,
                           successful, _type, ras_id, details):
        """
            user_id(int): id of user, this connection is related to
            credit_used(float): amount of credit used by user
            login_time(str): string representaion of user login time
            logout_time(str): string representaion of user logout time
            successful(boolean): was user connection successful, or it failed and user connection didn't established normally in authentication or authorization phase
            _type(str): type of connection, can be "internet" or "voip"
            ras_id(integer): id of ras, connection made to
            details(dictionary): dic of connection details, varying for diffrent types/rases/connections
        """
        names_arr, values_arr = self.__createConnectionDetailsArrays(details)

        return ibs_db.createFunctionCallQuery("insert_connection_log", \
                                                ("%s::bigint"%user_id,
                                                 credit_used,
                                                 dbText(login_time),
                                                 dbText(logout_time),
                                                 ["'f'","'t'"][successful],
                                                 "%s::smallint"%self.getTypeValue(_type),
                                                 ras_id,
                                                 names_arr,
                                                 values_arr)
                                              )
Example #2
0
 def updateNormalUserAttrsToNullQuery(self, user_id):
     """
         update normal_username to null, we run into unique constraint violation, when updating multiple
         users. So we update them to null and then update to new username
     """
     return ibs_db.createFunctionCallQuery("update_normal_user",
                                           (user_id, 'null', 'null'))
Example #3
0
 def updateNormalUserAttrsQuery(self, user_id, normal_username,
                                normal_password):
     """
         update user normal attributes in "normal_users" table
     """
     return ibs_db.createFunctionCallQuery(
         "update_normal_user",
         (user_id, dbText(normal_username), dbText(normal_password)))
Example #4
0
 def __logAnalysisQuery(self, ip, user_id, timestamp, url, elapsed, bytes,
                        miss, hit, successful, failure, _count):
     return ibs_db.createFunctionCallQuery("insert_web_analyzer_log", \
                                             ("%s"%dbText(dbTimeFromEpoch(to_float(timestamp, 'timestamp'))),
                                              "%s::bigint"%user_id,
                                              dbText(ip),
                                              dbText(url),
                                              to_int(elapsed,'elapsed'),
                                              to_int(bytes,'bytes'),
                                              "%s::smallint"%to_int(miss, 'misses'),
                                              "%s::smallint"%to_int(hit, 'hits'),
                                              "%s::smallint"%to_int(successful, 'successful'),
                                              "%s::smallint"%to_int(failure , 'failure'),
                                              to_int(_count,'count')
                                             )
                                           )
Example #5
0
    def userAuditLogQuery(self, admin_id, is_user, obj_id, attr_name,
                          old_value, new_value):
        """
            return query, for inserting a new audit log entry
            admin_id(integer): id of admin performing the job
            is_user(boolean): is destination object a user? if not, it's a group
            obj_id(integer): id of user or group
            attr_name(str): name of attribute that has been changed
            old_value(str): value of attribute before change
            new_value(str): value of attribute after change
        """
        if old_value == new_value:
            return ""

        return ibs_db.createFunctionCallQuery(
            "insert_user_audit_log",
            (admin_id, ("'f'", "'t'")[is_user == True], obj_id,
             dbText(attr_name), dbText(old_value), dbText(new_value)))
Example #6
0
 def __commitCreditQuery(self,used_credit):
     return ibs_db.createFunctionCallQuery("change_user_credit",[self.getUserID(), -1*used_credit])
Example #7
0
 def __logEventQuery(self, event_id, event_type_id, admin_username, amount,
                     destination, comment):
     return ibs_db.createFunctionCallQuery("insert_ias_event", \
                     ["%s::bigint"%event_id,"%s::smallint"%event_type_id,dbText(admin_username),"%s::numeric"%amount,dbText(destination),dbText(comment)])
Example #8
0
 def deleteGroupAttrQuery(self, group_id, attr_name):
     return ibs_db.createFunctionCallQuery(
         "delete_group_attr", [group_id, dbText(attr_name)])
Example #9
0
 def updateGroupAttrQuery(self, group_id, attr_name, attr_value):
     return ibs_db.createFunctionCallQuery(
         "update_group_attr",
         [group_id, dbText(attr_name),
          dbText(attr_value)])
Example #10
0
 def deleteNormalUserAttrsQuery(self, user_id):
     """
         delete user normal attributes from "normal_users" table
     """
     return ibs_db.createFunctionCallQuery("delete_normal_user",
                                           (user_id, ))
Example #11
0
 def deleteUserAttrQuery(self, user_id, attr_name):
     return ibs_db.createFunctionCallQuery(
         "delete_user_attr", [user_id, dbText(attr_name)])
Example #12
0
 def updateUserAttrQuery(self, user_id, attr_name, attr_value):
     return ibs_db.createFunctionCallQuery(
         "update_user_attr",
         [user_id, dbText(attr_name),
          dbText(attr_value)])
Example #13
0
 def __insertBasicUserQuery(self, user_id, credit, owner_id, group_id):
     return ibs_db.createFunctionCallQuery(
         "add_user", [user_id, credit, owner_id, group_id])