From 15be9cc6fbc91c10492137f992a2aa362b538efc Mon Sep 17 00:00:00 2001 From: pauget Date: Fri, 22 Oct 2004 15:57:48 +0200 Subject: [PATCH] Reconnexion automatique pour les gens blacklists. darcs-hash:20041022135748-41617-82beaee5b102ea50927228860b5ad80a7e847b10.gz --- gestion/gen_confs/generate.py | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/gestion/gen_confs/generate.py b/gestion/gen_confs/generate.py index 003745a8..7af79620 100755 --- a/gestion/gen_confs/generate.py +++ b/gestion/gen_confs/generate.py @@ -20,12 +20,12 @@ sys.path.append('/usr/scripts/gestion') from ldap_crans import crans_ldap, crans, smtpserv, hostname from lock import * from affich_tools import anim, cprint, OK, ERREUR, WARNING -from time import localtime, strftime +from time import localtime, strftime, time import config -args_autorises = ['quiet', 'remove=', 'list' ,'help'] +args_autorises = ['quiet', 'remove=', 'list' ,'help', 'reconnect'] if hostname == 'zamok' : - args_autorises += [ 'home=', 'mail_bienvenue=', 'ML-ENS=', 'droits', 'switch=' , 'dhcp', 'dns', 'firewall' , 'del_user=', 'blacklist_upload', 'autostatus' ] + args_autorises += [ 'home=', 'mail_bienvenue=', 'ML-ENS=', 'droits', 'switch=' , 'dhcp', 'dns', 'firewall' , 'del_user=', 'blacklist_upload', 'autostatus'] elif hostname == 'nectaris' : args_autorises += [ 'conf_wifi', 'bornes_wifi=' , 'droits-nectaris'] elif hostname == 'sila' : @@ -66,6 +66,23 @@ for opt, val in options : print 'Services à redémarrer :' print db.services_to_restart() sys.exit(0) + + elif opt == '--reconnect' : + # Personnes à reconnecter + print 'Recheche personnes en fin de sanction.' + hier = strftime('%d/%m/%Y %H:%M'.split()[0],localtime(time()-60*60*24)) + c = db.search('blacklist=*,%s*' % hier) + services = [] + for a_reco in c['adherent'] + c['machine'] + c['club'] : + for bl in a_reco.blacklist() : + fin, sanction = bl.split(',')[1:3] + if fin.split()[0] == hier and sanction not in services : + services.append(sanction) + for s in services : + print "Ajout de blacklist_%s pour reconfiguration" % s + db.services_to_restart('blacklist_%s' % s.encode()) + sys.exit(0) + elif opt =='-h' or opt == '--help' : print __doc__ % { 'prog' : sys.argv[0].split('/')[-1] , 'options' : '\n\t'.join(args_autorises) } sys.exit(0) @@ -185,7 +202,7 @@ if hostname == 'zamok': if debug : import traceback traceback.print_exc() - + if 'ML-ENS' in to_do.keys() : if auto : db.services_to_restart('-ML-ENS') cprint('Inscription ML-ENS','gras')