Commit e6ed5dde authored by glondu's avatar glondu

Factorisation ultime des connexions a la base LDAP.

Renommage crans_ldap -> CransLdap.

darcs-hash:20060506052907-68412-7cbd4a4eece00def70ce788d50ea53399808e033.gz
parent 0b3f36bd
......@@ -52,7 +52,7 @@ else:
sys.stdout.write(coul('Warning : impossible de lire le fichier de secret !\n', 'jaune'))
sys.exit(1)
# uri pour les instances de crans_ldap faisant de la lecture seule
# uri pour les instances de CransLdap faisant de la lecture seule
if os.path.exists('/var/run/ldapi'):
ro_uri = 'ldapi://%2fvar%2frun%2fldapi/'
else:
......@@ -224,7 +224,7 @@ class Service:
','.join(self.args),
dates)).replace(" et maintenant", "")
class crans_ldap:
class CransLdap:
"""
Classe de connexion la base LDAP du crans.
"""
......@@ -818,7 +818,7 @@ class crans_ldap:
#############################################################################
class BaseClasseCrans(crans_ldap):
class BaseClasseCrans(CransLdap):
""" Mthodes de base des classes machines, et BaseProprietaire """
def __eq__(self, autre):
......@@ -2934,7 +2934,7 @@ class BorneWifi(Machine):
return new
class _FakeProprio(crans_ldap):
class _FakeProprio(CransLdap):
""" Dfinitions de base d'un propritaire virtuel """
idn = ''
def __init__(self, conn=None):
......@@ -2970,6 +2970,18 @@ class AssociationCrans(_FakeProprio):
def chbre(self):
return u"CRA"
db = None
def crans_ldap(readonly=False):
""" Renvoie un objet CransLdap """
global db
if readonly:
return CransLdap(readonly)
if db == None:
db = CransLdap()
return db
if __name__ == '__main__':
import sys
......@@ -2984,18 +2996,18 @@ if __name__ == '__main__':
elif '--lock' in sys.argv:
print "Liste des locks"
db = crans_ldap()
db = CransLdap()
for lock in db.list_locks():
print "%s\t %s" % (lock[1]["lockid"][0], lock[0].split(',')[0])
elif '--purgelock' in sys.argv:
print "Suppression de tous les locks"
db = crans_ldap()
db = CransLdap()
db.remove_lock('*')
elif '--menage' in sys.argv:
print "Mnage des machines des adhrents partis..."
db = crans_ldap()
db = CransLdap()
machines = db.search('paiement!=%s&host=*.crans.org' % ann_scol , 'w')['machine']
print "Destruction de %i machines" % len(machines)
for m in machines:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment