Gestion des bornes.
Meilleure gestion des erreurs. Fichier commun zamok et nectaris darcs-hash:20040906094417-d1718-e36642e0349b2d0a24c29021eea0b54d239cf20e.gz
This commit is contained in:
parent
a60988c663
commit
a5abd19754
1 changed files with 162 additions and 127 deletions
|
@ -24,7 +24,7 @@ make_lock('auto_generate')
|
||||||
##### Options fournies ?
|
##### Options fournies ?
|
||||||
try :
|
try :
|
||||||
if len(sys.argv) > 1 :
|
if len(sys.argv) > 1 :
|
||||||
options, arg = getopt.getopt(sys.argv[1:], '', ['quiet', 'home=', 'mail_bienvenue=', 'ML-ENS=', 'droits', 'switch=' , 'dhcp', 'dns', 'firewall' ])
|
options, arg = getopt.getopt(sys.argv[1:], '', ['quiet', 'home=', 'mail_bienvenue=', 'ML-ENS=', 'droits', 'switch=' , 'dhcp', 'dns', 'firewall', 'conf_wifi', 'bornes_wifi=' ])
|
||||||
else :
|
else :
|
||||||
options, arg = ( [],'')
|
options, arg = ( [],'')
|
||||||
except getopt.error, msg :
|
except getopt.error, msg :
|
||||||
|
@ -49,8 +49,12 @@ else :
|
||||||
auto = 0
|
auto = 0
|
||||||
if debug : print 'Services à redémarrer imposés (non lecture de la base LDAP)'
|
if debug : print 'Services à redémarrer imposés (non lecture de la base LDAP)'
|
||||||
|
|
||||||
|
from socket import gethostname
|
||||||
|
|
||||||
|
if gethostname().split(".")[0] == 'zamok':
|
||||||
inst = []
|
inst = []
|
||||||
if 'home' in to_do.keys() :
|
if 'home' in to_do.keys() :
|
||||||
|
if auto : db.services_to_restart('-home')
|
||||||
cprint('Création home','gras')
|
cprint('Création home','gras')
|
||||||
for args in to_do['home'] :
|
for args in to_do['home'] :
|
||||||
anim('\t' + args)
|
anim('\t' + args)
|
||||||
|
@ -67,9 +71,10 @@ if 'home' in to_do.keys() :
|
||||||
sys.stderr.write(output+'\n')
|
sys.stderr.write(output+'\n')
|
||||||
else :
|
else :
|
||||||
print OK
|
print OK
|
||||||
if auto : db.services_to_restart('-home')
|
|
||||||
except :
|
except :
|
||||||
print ERREUR
|
print ERREUR
|
||||||
|
# On devra le refaire la prochaine fois
|
||||||
|
if auto : db.services_to_restart('home',[args])
|
||||||
if debug :
|
if debug :
|
||||||
import traceback
|
import traceback
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
|
@ -97,6 +102,7 @@ if 'mail_bienvenue' in to_do.keys() :
|
||||||
db.services_to_restart('mail_bienvenue',pas_fait)
|
db.services_to_restart('mail_bienvenue',pas_fait)
|
||||||
|
|
||||||
if 'ML-ENS' in to_do.keys() :
|
if 'ML-ENS' in to_do.keys() :
|
||||||
|
if auto : db.services_to_restart('-ML-ENS')
|
||||||
cprint('Inscription ML-ENS','gras')
|
cprint('Inscription ML-ENS','gras')
|
||||||
for mail in to_do['ML-ENS'] :
|
for mail in to_do['ML-ENS'] :
|
||||||
anim('\t'+mail)
|
anim('\t'+mail)
|
||||||
|
@ -104,25 +110,33 @@ if 'ML-ENS' in to_do.keys() :
|
||||||
if status :
|
if status :
|
||||||
# Il y a eu une erreur
|
# Il y a eu une erreur
|
||||||
print ERREUR
|
print ERREUR
|
||||||
|
if auto : db.services_to_restart('ML-ENS', [mail])
|
||||||
if debug :
|
if debug :
|
||||||
sys.stderr.write(output+'\n')
|
sys.stderr.write(output+'\n')
|
||||||
else :
|
else :
|
||||||
print OK
|
print OK
|
||||||
db.services_to_restart('-ML-ENS')
|
|
||||||
|
|
||||||
if 'droits' in to_do.keys() :
|
if 'droits' in to_do.keys() :
|
||||||
|
if auto : db.services_to_restart('-droits')
|
||||||
|
try:
|
||||||
from gen_confs.droits import droits
|
from gen_confs.droits import droits
|
||||||
a = droits()
|
a = droits()
|
||||||
a.debug = debug
|
a.debug = debug
|
||||||
a.reconfigure()
|
a.reconfigure()
|
||||||
db.services_to_restart('-droits')
|
except:
|
||||||
|
if auto : db.services_to_restart('droits')
|
||||||
|
raise
|
||||||
|
|
||||||
if 'switch' in to_do.keys() :
|
if 'switch' in to_do.keys() :
|
||||||
|
if auto : db.services_to_restart('-switch')
|
||||||
|
try:
|
||||||
from gen_confs.switchs import switch
|
from gen_confs.switchs import switch
|
||||||
a = switch(to_do['switch'])
|
a = switch(to_do['switch'])
|
||||||
a.debug = debug
|
a.debug = debug
|
||||||
a.reconfigure()
|
a.reconfigure()
|
||||||
if auto : db.services_to_restart('-switch')
|
except:
|
||||||
|
if auto : db.services_to_restart('switch',to_do['switch'])
|
||||||
|
raise
|
||||||
|
|
||||||
# Les services suivants ont besoin de la liste des machines
|
# Les services suivants ont besoin de la liste des machines
|
||||||
# On va donc la lire une seule fois pour leur passer ensuite
|
# On va donc la lire une seule fois pour leur passer ensuite
|
||||||
|
@ -147,11 +161,10 @@ if 'dhcp' in to_do.keys() :
|
||||||
if auto :
|
if auto :
|
||||||
for i in inst:
|
for i in inst:
|
||||||
db.services_to_restart("-%s" % i[1])
|
db.services_to_restart("-%s" % i[1])
|
||||||
|
## On fait ce qu'il reste à faire
|
||||||
##### On fait ce qu'il reste à faire
|
|
||||||
|
|
||||||
if inst :
|
if inst :
|
||||||
##### Récolte des données
|
# Récolte des données
|
||||||
cprint('Lecture base LDAP','gras')
|
cprint('Lecture base LDAP','gras')
|
||||||
# Machines de l'assoce
|
# Machines de l'assoce
|
||||||
machines = crans(db.conn).machines()
|
machines = crans(db.conn).machines()
|
||||||
|
@ -169,7 +182,7 @@ if inst :
|
||||||
a.reinit()
|
a.reinit()
|
||||||
print OK
|
print OK
|
||||||
|
|
||||||
#### Reconfiguration des services
|
# Reconfiguration des services
|
||||||
|
|
||||||
for i in inst :
|
for i in inst :
|
||||||
i[0].debug = debug
|
i[0].debug = debug
|
||||||
|
@ -180,7 +193,29 @@ if inst :
|
||||||
# Erreur, il faudra relancer le service la prochaine fois
|
# Erreur, il faudra relancer le service la prochaine fois
|
||||||
if auto : db.services_to_restart('%s' % i[1])
|
if auto : db.services_to_restart('%s' % i[1])
|
||||||
sys.stderr.write('Erreur dans le service %s\n' % i[1])
|
sys.stderr.write('Erreur dans le service %s\n' % i[1])
|
||||||
|
elif gethostname().split(".")[0] == 'nectaris':
|
||||||
|
# On s'occupe de nectaris
|
||||||
|
if 'conf_wifi' in to_do.keys():
|
||||||
|
if auto : db.services_to_restart('-conf_wifi')
|
||||||
|
try:
|
||||||
|
from gen_confs.wifi import wifi
|
||||||
|
a = wifi()
|
||||||
|
a.debug = debug
|
||||||
|
a.reconfigure()
|
||||||
|
except:
|
||||||
|
if auto : db.services_to_restart('conf_wifi')
|
||||||
|
raise
|
||||||
|
if 'bornes_wifi' in to_do.keys():
|
||||||
|
if auto : db.services_to_restart('-bornes_wifi')
|
||||||
|
try:
|
||||||
|
from gen_confs.wifi import bornes_wifi
|
||||||
|
a = bornes_wifi(to_do['bornes_wifi'])
|
||||||
|
a.debug = debug
|
||||||
|
a.reconfigure()
|
||||||
|
except:
|
||||||
|
# Pas terrible : on va redemarrer les bornes qui ont redemarré correctement
|
||||||
|
if auto : db.services_to_restart('bornes_wifi', to_do['bornes_wifi'])
|
||||||
|
raise
|
||||||
|
|
||||||
if debug :
|
if debug :
|
||||||
print 'Non traité ici mais signalé dans la base LDAP : \n\t', db.services_to_restart()
|
print 'Non traité ici mais signalé dans la base LDAP : \n\t', db.services_to_restart()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue