lc_ldap.shortcuts
This commit is contained in:
parent
dc01a371dc
commit
0922e3c63b
8 changed files with 30 additions and 27 deletions
|
@ -5,13 +5,15 @@
|
|||
import os
|
||||
import sys
|
||||
sys.path.append('/usr/scripts/gestion')
|
||||
sys.path.append('/usr/scripts/lc_ldap')
|
||||
sys.path.append('/usr/scripts/')
|
||||
|
||||
from config import NETs, blacklist_sanctions, blacklist_sanctions_soft, blacklist_bridage_upload, mac_komaz, mac_titanic, adm_users, accueil_route
|
||||
|
||||
import pwd
|
||||
import config.firewall
|
||||
import lc_ldap
|
||||
import lc_ldap.shortcuts
|
||||
import lc_ldap.objets
|
||||
import lc_ldap.attributs
|
||||
import socket
|
||||
from ipset import IpsetError, Ipset
|
||||
from iptools import AddrInNet, NetSubnets, IpSubnet, NetInNets
|
||||
|
@ -87,9 +89,9 @@ class firewall_base(object) :
|
|||
blacklisted = [ machine for machine in conn.search("blacklist=*",sizelimit=4096) if machine.blacklist_actif() ]
|
||||
self._blacklisted_machines = set()
|
||||
for item in blacklisted:
|
||||
if isinstance(item, lc_ldap.proprio):
|
||||
if isinstance(item, lc_ldap.objets.proprio):
|
||||
self._blacklisted_machines = self._blacklisted_machines.union(item.machines())
|
||||
elif isinstance(item, lc_ldap.machine):
|
||||
elif isinstance(item, lc_ldap.objets.machine):
|
||||
self._blacklisted_machines.add(item)
|
||||
else:
|
||||
print >> sys.stderr, 'Objet %s inconnu blacklisté' % a.__class__.__name__
|
||||
|
@ -206,7 +208,7 @@ class firewall_base(object) :
|
|||
sys.exit(1)
|
||||
|
||||
# Connection à la base ldap
|
||||
conn = lc_ldap.lc_ldap_admin()
|
||||
conn = lc_ldap.shortcuts.lc_ldap_admin()
|
||||
|
||||
self.reloadable = {
|
||||
'blacklist_hard' : self.blacklist_hard,
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
import sys
|
||||
sys.path.append('/usr/scripts/')
|
||||
sys.path.append('/usr/scripts/gestion')
|
||||
sys.path.append('/usr/scripts/lc_ldap')
|
||||
sys.path.append('/usr/scripts/')
|
||||
|
||||
import cranslib.deprecated
|
||||
cranslib.deprecated.module()
|
||||
|
@ -44,13 +44,11 @@ from iptools import AddrInNet, NetSubnets, IpSubnet
|
|||
from config import NETs, mac_komaz, mac_wifi, mac_titanic, p2p, vlans, debit_max_radin, adm_users, accueil_route, blacklist_sanctions, blacklist_sanctions_soft, periode_transitoire
|
||||
import config.firewall
|
||||
from ipset import IpsetError, Ipset
|
||||
from lc_ldap import lc_ldap
|
||||
from ipt import gethostbyname
|
||||
syslog.openlog('firewall')
|
||||
|
||||
debug = 1
|
||||
db = crans_ldap()
|
||||
QUERY=lc_ldap(uri='ldap://ldap.adm.crans.org/')
|
||||
|
||||
class IptablesError(Exception):
|
||||
""" Gestion des erreurs d'iptables """
|
||||
|
|
|
@ -9,14 +9,14 @@ import hashlib
|
|||
from socket import gethostname
|
||||
from netifaces import interfaces, ifaddresses, AF_INET
|
||||
|
||||
sys.path.append('/usr/scripts/lc_ldap')
|
||||
sys.path.append('/usr/scripts/')
|
||||
sys.path.append('/usr/scripts/gestion')
|
||||
sys.path.append('/etc/crans/secrets/')
|
||||
|
||||
import lc_ldap
|
||||
import lc_ldap.shortcuts
|
||||
import config
|
||||
|
||||
conn=lc_ldap.lc_ldap_admin()
|
||||
conn = lc_ldap.shortcuts.lc_ldap_admin()
|
||||
|
||||
ssh_algo = config.sshfp_algo.keys()
|
||||
|
||||
|
|
|
@ -3,12 +3,12 @@
|
|||
import sys
|
||||
from sh import grep,ErrorReturnCode_1
|
||||
sys.path.append('/usr/scripts/gestion')
|
||||
sys.path.append('/usr/scripts/lc_ldap')
|
||||
sys.path.append('/usr/scripts/')
|
||||
sys.path.append('/etc/crans/secrets/')
|
||||
|
||||
import lc_ldap
|
||||
import lc_ldap.shortcuts
|
||||
|
||||
conn=lc_ldap.lc_ldap_admin()
|
||||
conn=lc_ldap.shortcuts.lc_ldap_admin()
|
||||
|
||||
try:
|
||||
aid=int(sys.argv[1][1:])
|
||||
|
|
|
@ -5,10 +5,10 @@
|
|||
import sys
|
||||
import psycopg2
|
||||
sys.path.append('/usr/scripts/gestion')
|
||||
sys.path.append('/usr/scripts/lc_ldap')
|
||||
sys.path.append('/usr/scripts/')
|
||||
sys.path.append('/etc/crans/secrets/')
|
||||
|
||||
import lc_ldap
|
||||
import lc_ldap.shortcuts
|
||||
|
||||
try:
|
||||
conn = psycopg2.connect("dbname='django' user='crans' host='pgsql.adm.crans.org'")
|
||||
|
@ -17,7 +17,7 @@ try:
|
|||
caller_id = cur.fetchall()[0][0]
|
||||
|
||||
if caller_id == 'full_name' or caller_id == 'both':
|
||||
conn=lc_ldap.lc_ldap_admin()
|
||||
conn=lc_ldap.shortcuts.lc_ldap_admin()
|
||||
aid=int(sys.argv[1][1:])
|
||||
adh=conn.search('aid=%s' % aid)[0]
|
||||
sys.stdout.write('%s %s' % (adh['prenom'][0],adh['nom'][0]))
|
||||
|
|
|
@ -3,13 +3,14 @@
|
|||
|
||||
import sys,os,hashlib
|
||||
sys.path.append('/usr/scripts/gestion')
|
||||
sys.path.append('/usr/scripts/lc_ldap')
|
||||
sys.path.append('/usr/scripts/')
|
||||
sys.path.append('/etc/crans/secrets/')
|
||||
|
||||
import secrets,lc_ldap
|
||||
import secrets
|
||||
import lc_ldap.shortcuts
|
||||
from sh import asterisk
|
||||
|
||||
conn=lc_ldap.lc_ldap_admin()
|
||||
conn=lc_ldap.shortcuts.lc_ldap_admin()
|
||||
|
||||
def gen_multidial(droit):
|
||||
dial="exten => %(droit)s,1,Ringing\nexten => %(droit)s,n,Wait(4)\nexten => %(droit)s,n,Answer\nexten => %(droit)s,n,Dial(" % {'droit':droit}
|
||||
|
|
|
@ -2,13 +2,14 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import sys
|
||||
sys.path.append('/usr/scripts/gestion')
|
||||
sys.path.append('/usr/scripts/lc_ldap')
|
||||
sys.path.append('/usr/scripts/')
|
||||
sys.path.append('/etc/crans/secrets/')
|
||||
|
||||
import secrets,lc_ldap
|
||||
import secrets
|
||||
import lc_ldap.shortcuts
|
||||
|
||||
|
||||
conn=lc_ldap.lc_ldap_admin()
|
||||
conn=lc_ldap.shortcuts.lc_ldap_admin()
|
||||
try:
|
||||
if len(sys.argv[1])==5:
|
||||
aid=int(sys.argv[1][1:])
|
||||
|
|
|
@ -15,11 +15,12 @@ import time
|
|||
sys.path.append('/usr/scripts/gestion')
|
||||
from config import mac_prise
|
||||
from affich_tools import tableau
|
||||
sys.path.append('/usr/scripts/lc_ldap')
|
||||
import lc_ldap
|
||||
sys.path.append('/usr/scripts/')
|
||||
import lc_ldap.shortcuts
|
||||
import lc_ldap.objets
|
||||
import collections
|
||||
|
||||
ldap = lc_ldap.lc_ldap_local()
|
||||
ldap = lc_ldap.shortcuts.lc_ldap_local()
|
||||
|
||||
conn = psycopg2.connect(user='crans', database='mac_prises')
|
||||
conn.set_session(autocommit = True)
|
||||
|
@ -74,7 +75,7 @@ def genere_comptage(duree):
|
|||
for entry in fetched:
|
||||
machines = ldap.search('(macAddress=%s)' % entry['mac'])
|
||||
if len(machines) > 0:
|
||||
if isinstance(machines[0], lc_ldap.machineWifi):
|
||||
if isinstance(machines[0], lc_ldap.objets.machineWifi):
|
||||
continue
|
||||
else:
|
||||
continue
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue