def deleteConnectionLogsForUsersQuery(self, user_ids): condition = " or ".join( map(lambda user_id: "user_id=%s" % user_id, user_ids)) details_query = ibs_db.createDeleteQuery( "connection_log_details", "connection_log_id in (select connection_log_id from connection_log where %s)" % condition) connection_query = ibs_db.createDeleteQuery("connection_log", condition) return details_query + connection_query
def __deleteAddUserSaveQuery(self, add_user_save_id, admin_restricted, admin_id): cond = "add_user_save_id=%s" % add_user_save_id if admin_restricted: cond += " and admin_id=%s" % admin_id details_cond = "add_user_save_id in (select add_user_save_id from add_user_saves where %s)" % cond else: details_cond = cond return ibs_db.createDeleteQuery("add_user_save_details",details_cond) + \ ibs_db.createDeleteQuery("add_user_saves",details_cond)
def deleteUserAttrQuery(self,user_id,attr_name): """ XXX:change to use stored procedures """ return ibs_db.createDeleteQuery("user_attrs","user_id=%s and attr_name=%s"% (user_id,dbText(attr_name)) )
def __delVoIPChargeRuleQuery(self, charge_rule_id): """ return query needed to delete rule only from charge_rules table it won't delete ports """ return ibs_db.createDeleteQuery("voip_charge_rules", "charge_rule_id=%s" % charge_rule_id)
def deleteAuditLogsForUsersQuery(self, user_ids): """ return query for deleting audit logs of users with ids in user_ids user_ids(iterable object of user_ids) """ condition = " or ".join( map(lambda user_id: "object_id=%s" % user_id, user_ids)) return ibs_db.createDeleteQuery("user_audit_log", "is_user = '******' and (%s)" % condition)
def __delAttributesQuery(self,ras_id): return ibs_db.createDeleteQuery("ras_attrs","ras_id=%s"%ras_id)
def __deleteRasQuery(self,ras_id): return ibs_db.createDeleteQuery("ras","ras_id=%s"%ras_id)
def __delUserNormalAttrsQuery(self,user_id_conds): return ibs_db.createDeleteQuery("normal_users",user_id_conds)
def __deletePlanUserAttrsQuery(self,user_id): return ibs_db.createDeleteQuery("persistent_lan_users","user_id=%s"%user_id)
def __delAllAdminPermsQuery(self, admin_id): return ibs_db.createDeleteQuery("admin_perms", "admin_id=%s" % admin_id)
def __delAllAdminPermsQuery(self,admin_id): return ibs_db.createDeleteQuery("admin_perms","admin_id=%s"%admin_id)
def __delIPfromPoolQuery(self,ippool_id,ip): return ibs_db.createDeleteQuery("ippool_ips","ippool_id=%s and ip=%s"%(ippool_id,dbText(ip)))
def __delChargeQuery(self,charge_id): """ return query to delete the charge itself from charges table """ return ibs_db.createDeleteQuery("charges","charge_id=%s"%charge_id)
def __unlockAdminQuery(self, admin_id, lock_id): return ibs_db.createDeleteQuery( "admin_locks", "admin_id=%s and lock_id=%s" % (admin_id, lock_id))
def __deletePoolIPsQuery(self,ippool_id): return ibs_db.createDeleteQuery("ippool_ips","ippool_id=%s"%ippool_id)
def __deleteAddUserSavesQuery(self, admin_id): return ibs_db.createDeleteQuery("add_user_save_details","add_user_save_id in \ (select add_user_save_id from add_user_saves where admin_id = %s)" %admin_id) + \ ibs_db.createDeleteQuery("add_user_saves","admin_id = %s"%admin_id)
def __deleteAdminDepositChangesQuery(self, admin_id): return ibs_db.createDeleteQuery("admin_deposit_change", "to_admin_id = %s" % admin_id)
def __deleteAdminLocksQuery(self, admin_id): return ibs_db.createDeleteQuery("admin_locks", "admin_id = %s" % admin_id)
def deleteVoIPUserAttrsQuery(self, user_id): """ delete user voip attributes from "voip_users" table """ return ibs_db.createDeleteQuery("voip_users", "user_id=%s" % user_id)
def __delChargeRulePortsQuery(self, rule_id): return ibs_db.createDeleteQuery("charge_rule_ports", "charge_rule_id=%s" % rule_id)
def __delChargeRuleDowsQuery(self,rule_id): return ibs_db.createDeleteQuery("charge_rule_day_of_weeks","charge_rule_id=%s"%rule_id)
def __delChargeRuleDowsQuery(self, rule_id): return ibs_db.createDeleteQuery("charge_rule_day_of_weeks", "charge_rule_id=%s" % rule_id)
def __deleteGroupAttrsQuery(self,group_id): return ibs_db.createDeleteQuery("group_attrs","group_id=%s"%group_id)
def __deleteUserCallerIDsQuery(self, user_id): return ibs_db.createDeleteQuery("caller_id_users","user_id=%s"%user_id)
def __deletePermTemplateQuery(self, template_name): return ibs_db.createDeleteQuery( "admin_perm_templates", "template_name=%s" % dbText(template_name))
def __delChargeQuery(self, charge_id): """ return query to delete the charge itself from charges table """ return ibs_db.createDeleteQuery("charges", "charge_id=%s" % charge_id)
def __deletePermTemplateQuery(self,template_name): return ibs_db.createDeleteQuery("admin_perm_templates","template_name=%s"%dbText(template_name))
def __delPrefixQuery(self,tariff_id,prefix_codes): return ibs_db.createDeleteQuery("tariff_prefix_list","%s"%" or ".join(map(lambda code:"prefix_code=%s"%dbText(code),prefix_codes))) ################################################
def __delUserPLanAttrsQuery(self,user_id_conds): return ibs_db.createDeleteQuery("persistent_lan_users",user_id_conds)
def __deleteTariffQuery(self,tariff_id): return ibs_db.createDeleteQuery("voip_charge_rule_tariff","tariff_id=%s"%tariff_id)
def __deleteMessageQuery(self, table_name, message_id): return ibs_db.createDeleteQuery(table_name, "message_id = %s" % message_id)
def __deleteTariffPrefixesQuery(self,tariff_id): return ibs_db.createDeleteQuery("tariff_prefix_list","tariff_id=%s"%tariff_id)
def __delIPpoolFromRasQuery(self,ras_id,ippool_id): return ibs_db.createDeleteQuery("ras_ippools","ras_id=%s and ippool_id=%s"%(ras_id,ippool_id))
def __deleteGroupAttrsQuery(self, group_id): return ibs_db.createDeleteQuery("group_attrs", "group_id=%s" % group_id)
def deleteNormalUserAttrsQuery(self, user_id): """ delete user normal attributes from "normal_users" table """ return ibs_db.createDeleteQuery("normal_users", "user_id=%s" % user_id)
def deleteVoIPUserAttrsQuery(self,user_id): """ delete user voip attributes from "voip_users" table """ return ibs_db.createDeleteQuery("voip_users","user_id=%s"%user_id)
def __delChargeRulePortsQuery(self,rule_id): return ibs_db.createDeleteQuery("charge_rule_ports","charge_rule_id=%s"%rule_id)
def deleteConnectionLogsForUsersQuery(self,user_ids): condition=" or ".join(map(lambda user_id:"user_id=%s"%user_id,user_ids)) details_query=ibs_db.createDeleteQuery("connection_log_details","connection_log_id in (select connection_log_id from connection_log where %s)"%condition) connection_query=ibs_db.createDeleteQuery("connection_log",condition) return details_query+connection_query
def __delInternetChargeRuleQuery(self,charge_rule_id): """ return query needed to delete rule only from charge_rules table it won't delete ports """ return ibs_db.createDeleteQuery("internet_charge_rules","charge_rule_id=%s"%charge_rule_id)
def __deleteEventQuery(self, event_id): return ibs_db.createDeleteQuery("ias_event", "event_id=%s" % event_id)
def deleteGroupAttrQuery(self,group_id,attr_name): return ibs_db.createDeleteQuery("group_attrs","attr_name=%s and group_id=%s"% (dbText(attr_name),to_int(group_id,"group id")))
def __delLeafServiceQuery(self, leaf_service_id): return ibs_db.createDeleteQuery("bw_leaf_services", "leaf_service_id=%s" % leaf_service_id)
def __deletePermissionQuery(self, admin_id, perm_name): return ibs_db.createDeleteQuery( "admin_perms", "admin_id=%s and perm_name=%s" % (admin_id, dbText(perm_name)))
def __delNodeQuery(self, node_id): return ibs_db.createDeleteQuery("bw_node", "node_id=%s" % node_id)
def __deletePermTemplateDetailsQuery(self, template_name): return ibs_db.createDeleteQuery( "admin_perm_templates_detail", "template_id = (%s)" % (self.__templateNameToIDQuery(template_name)))
def __delLeafQuery(self, leaf_id): return ibs_db.createDeleteQuery("bw_leaf", "leaf_id=%s" % leaf_id)
def __deletePermissionQuery(self,admin_id,perm_name): return ibs_db.createDeleteQuery("admin_perms","admin_id=%s and perm_name=%s"% (admin_id,dbText(perm_name)))
def __delInterfaceQuery(self, int_id): return ibs_db.createDeleteQuery("bw_interface", "interface_id=%s" % int_id)
def __deletePermTemplateDetailsQuery(self,template_name): return ibs_db.createDeleteQuery("admin_perm_templates_detail","template_id = (%s)"%(self.__templateNameToIDQuery(template_name)))
def __delBwStaticIPQuery(self, ip_addr): return ibs_db.createDeleteQuery("bw_static_ip", "ip=%s" % dbText(ip_addr))
def __delUserAttrsQuery(self,user_id_conds): """ user_ids_conds: condition of user_ids """ return ibs_db.createDeleteQuery("user_attrs",user_id_conds)
def __delPrefixQuery(self,tariff_id,prefix_codes): prefix_code_cond = " or ".join(map(lambda code:"prefix_code=%s"%dbText(code),prefix_codes)) return ibs_db.createDeleteQuery("tariff_prefix_list","(%s) and tariff_id = %s"%(prefix_code_cond, tariff_id)) ################################################
def __delUserVoIPAttrsQuery(self,user_id_conds): return ibs_db.createDeleteQuery("voip_users",user_id_conds)
def __delBwStaticIPQuery(self,ip_addr): return ibs_db.createDeleteQuery("bw_static_ip","ip=%s"%dbText(ip_addr))
def __delUserFromUsersTableQuery(self,user_id_conds): return ibs_db.createDeleteQuery("users",user_id_conds)
def __delPortQuery(self,ras_id,port_name): return ibs_db.createDeleteQuery("ras_ports","ras_id=%s and port_name=%s"%(ras_id,dbText(port_name)))
def __deleteUserMessagesQuery(self, message_ids, user_id): cond = "( %s ) and user_id = %s" % (" or ".join( map(lambda message_id: "message_id=%s" % message_id, message_ids)), user_id) return ibs_db.createDeleteQuery("user_messages", cond)
def __delInterfaceQuery(self,int_id): return ibs_db.createDeleteQuery("bw_interface","interface_id=%s"%int_id)