On lance conf-wifi-ng automatiquement (pour les "nouvelles" bornes)
darcs-hash:20050906135043-d1718-0d2a0636d77270669317e1788b9d423067c51b21.gz
This commit is contained in:
parent
c0053f3da0
commit
9e6f51d199
1 changed files with 34 additions and 26 deletions
|
@ -211,6 +211,12 @@ class crans_ldap :
|
||||||
def __init__(self) :
|
def __init__(self) :
|
||||||
self.connect()
|
self.connect()
|
||||||
|
|
||||||
|
def __del__(self) :
|
||||||
|
# Destruction des locks résiduels
|
||||||
|
if hasattr(self,'_locks') :
|
||||||
|
for lock in self._locks :
|
||||||
|
self.remove_lock(lock)
|
||||||
|
|
||||||
def connect(self):
|
def connect(self):
|
||||||
""" Initialisation des connexion vers le serveur LDAP """
|
""" Initialisation des connexion vers le serveur LDAP """
|
||||||
|
|
||||||
|
@ -349,8 +355,11 @@ class crans_ldap :
|
||||||
except :
|
except :
|
||||||
pass
|
pass
|
||||||
raise EnvironmentError(u'Objet (%s=%s) locké, patienter.' % (item, valeur), l)
|
raise EnvironmentError(u'Objet (%s=%s) locké, patienter.' % (item, valeur), l)
|
||||||
|
else :
|
||||||
return lock_dn
|
if not hasattr(self,'_locks') :
|
||||||
|
self._locks = [lock_dn]
|
||||||
|
else :
|
||||||
|
self._locks.append(lock_dn)
|
||||||
|
|
||||||
def remove_lock(self,lockdn) :
|
def remove_lock(self,lockdn) :
|
||||||
""" Destruction d'un lock
|
""" Destruction d'un lock
|
||||||
|
@ -358,6 +367,11 @@ class crans_ldap :
|
||||||
# Mettre des verifs ?
|
# Mettre des verifs ?
|
||||||
if lockdn!='*' :
|
if lockdn!='*' :
|
||||||
self.conn.delete_s(lockdn)
|
self.conn.delete_s(lockdn)
|
||||||
|
try:
|
||||||
|
self._locks.remove(lockdn)
|
||||||
|
except:
|
||||||
|
# Pas grave si ca foire, le lock n'y est plus
|
||||||
|
pass
|
||||||
else :
|
else :
|
||||||
locks = self.list_locks()
|
locks = self.list_locks()
|
||||||
for l in locks :
|
for l in locks :
|
||||||
|
@ -654,15 +668,7 @@ class crans_ldap :
|
||||||
|
|
||||||
class base_classes_crans(crans_ldap) :
|
class base_classes_crans(crans_ldap) :
|
||||||
""" Méthodes de base des classes machines, et base_proprietaire """
|
""" Méthodes de base des classes machines, et base_proprietaire """
|
||||||
|
|
||||||
def __del__(self) :
|
|
||||||
# Destruction des locks résiduels
|
|
||||||
for lock in self._locks :
|
|
||||||
try :
|
|
||||||
self.remove_lock(lock)
|
|
||||||
except :
|
|
||||||
pass
|
|
||||||
|
|
||||||
def id(self):
|
def id(self):
|
||||||
""" Retourne la valeur de l'attribu caractéristique de la classe (aid,mid,cid)"""
|
""" Retourne la valeur de l'attribu caractéristique de la classe (aid,mid,cid)"""
|
||||||
try :
|
try :
|
||||||
|
@ -984,13 +990,11 @@ class base_proprietaire(base_classes_crans) :
|
||||||
raise TypeError
|
raise TypeError
|
||||||
|
|
||||||
self.modifs=[]
|
self.modifs=[]
|
||||||
self._locks = []
|
|
||||||
|
|
||||||
if data :
|
if data :
|
||||||
self.dn=data[0]
|
self.dn=data[0]
|
||||||
if mode == 'w' :
|
if mode == 'w' :
|
||||||
try :
|
try :
|
||||||
self._locks.append(self.lock(self.idn, self.id()))
|
self.lock(self.idn, self.id())
|
||||||
self._modifiable = 'w'
|
self._modifiable = 'w'
|
||||||
except EnvironmentError , c:
|
except EnvironmentError , c:
|
||||||
self._modifiable = 0
|
self._modifiable = 0
|
||||||
|
@ -1059,7 +1063,7 @@ class base_proprietaire(base_classes_crans) :
|
||||||
liste = liste + [ new ]
|
liste = liste + [ new ]
|
||||||
|
|
||||||
# Lock de mailAlias
|
# Lock de mailAlias
|
||||||
self._locks.append(self.lock('mailAlias',new))
|
self.lock('mailAlias',new)
|
||||||
|
|
||||||
self._set('mailAlias',liste)
|
self._set('mailAlias',liste)
|
||||||
return liste
|
return liste
|
||||||
|
@ -1187,6 +1191,7 @@ class base_proprietaire(base_classes_crans) :
|
||||||
self.services_to_restart('dns')
|
self.services_to_restart('dns')
|
||||||
if m.ipsec() :
|
if m.ipsec() :
|
||||||
self.services_to_restart('conf_wifi')
|
self.services_to_restart('conf_wifi')
|
||||||
|
self.services_to_restart('conf_wifi_ng')
|
||||||
self.services_to_restart('nectaris-dhcp')
|
self.services_to_restart('nectaris-dhcp')
|
||||||
else :
|
else :
|
||||||
self.services_to_restart('switch',[self.chbre()])
|
self.services_to_restart('switch',[self.chbre()])
|
||||||
|
@ -1389,7 +1394,7 @@ class adherent(base_proprietaire) :
|
||||||
raise ValueError(u'Chambre déjà occupée.',adh[0])
|
raise ValueError(u'Chambre déjà occupée.',adh[0])
|
||||||
|
|
||||||
# Lock de la chambre
|
# Lock de la chambre
|
||||||
self._locks.append(self.lock('chbre',new))
|
self.lock('chbre',new)
|
||||||
|
|
||||||
self._set('chbre',[new])
|
self._set('chbre',[new])
|
||||||
return new
|
return new
|
||||||
|
@ -1559,7 +1564,7 @@ class adherent(base_proprietaire) :
|
||||||
raise ValueError(u'Création du compte impossible : home existant',1)
|
raise ValueError(u'Création du compte impossible : home existant',1)
|
||||||
|
|
||||||
# Lock du mail
|
# Lock du mail
|
||||||
self._locks.append(self.lock('mail',login))
|
self.lock('mail',login)
|
||||||
|
|
||||||
self._data['mail']= [ login ]
|
self._data['mail']= [ login ]
|
||||||
if not 'compte' in self.modifs :
|
if not 'compte' in self.modifs :
|
||||||
|
@ -1588,7 +1593,7 @@ class adherent(base_proprietaire) :
|
||||||
while self.exist('(uidNumber=%s)' % uidNumber) :
|
while self.exist('(uidNumber=%s)' % uidNumber) :
|
||||||
uidNumber += 1
|
uidNumber += 1
|
||||||
try :
|
try :
|
||||||
self._locks.append(self.lock('uidNumber',str(uidNumber)))
|
self.lock('uidNumber',str(uidNumber))
|
||||||
except :
|
except :
|
||||||
# Quelqu'un nous a piqué l'uid que l'on venait de choisir !
|
# Quelqu'un nous a piqué l'uid que l'on venait de choisir !
|
||||||
return self.compte(login,uidNumber,hash_pass,shell)
|
return self.compte(login,uidNumber,hash_pass,shell)
|
||||||
|
@ -1614,7 +1619,7 @@ class adherent(base_proprietaire) :
|
||||||
# Attribution de l'alias, sinon on passe
|
# Attribution de l'alias, sinon on passe
|
||||||
|
|
||||||
# Lock de cannonicalAlias
|
# Lock de cannonicalAlias
|
||||||
self._locks.append(self.lock('cannonicalAlias',a))
|
self.lock('cannonicalAlias',a)
|
||||||
|
|
||||||
# Attribution
|
# Attribution
|
||||||
self._set('cannonicalAlias',[a])
|
self._set('cannonicalAlias',[a])
|
||||||
|
@ -1735,7 +1740,7 @@ class club(base_proprietaire) :
|
||||||
raise ValueError(u'Création du compte impossible : home existant',1)
|
raise ValueError(u'Création du compte impossible : home existant',1)
|
||||||
|
|
||||||
# Lock du mail
|
# Lock du mail
|
||||||
self._locks.append(self.lock('mail',login))
|
self.lock('mail',login)
|
||||||
|
|
||||||
if not 'compte' in self.modifs :
|
if not 'compte' in self.modifs :
|
||||||
self.modifs.append('compte')
|
self.modifs.append('compte')
|
||||||
|
@ -1750,7 +1755,7 @@ class club(base_proprietaire) :
|
||||||
while self.exist('(uidNumber=%s)' % uidNumber) :
|
while self.exist('(uidNumber=%s)' % uidNumber) :
|
||||||
uidNumber += 1
|
uidNumber += 1
|
||||||
try:
|
try:
|
||||||
self._locks.append(self.lock('uidNumber',str(uidNumber)))
|
self.lock('uidNumber',str(uidNumber))
|
||||||
except :
|
except :
|
||||||
# Quelqu'un nous a piqué l'uid que l'on venait de choisir !
|
# Quelqu'un nous a piqué l'uid que l'on venait de choisir !
|
||||||
return self.compte(login)
|
return self.compte(login)
|
||||||
|
@ -1784,14 +1789,13 @@ class machine(base_classes_crans) :
|
||||||
self.conn = conn
|
self.conn = conn
|
||||||
if not self.conn : self.connect()
|
if not self.conn : self.connect()
|
||||||
self.modifs=[]
|
self.modifs=[]
|
||||||
self._locks=[]
|
|
||||||
t = parent_or_tuple.__class__
|
t = parent_or_tuple.__class__
|
||||||
if t == tuple :
|
if t == tuple :
|
||||||
# Initialisation avec données fournies
|
# Initialisation avec données fournies
|
||||||
self.dn = parent_or_tuple[0]
|
self.dn = parent_or_tuple[0]
|
||||||
if typ == 'w' :
|
if typ == 'w' :
|
||||||
try :
|
try :
|
||||||
self._locks.append(self.lock(self.idn, self.id()))
|
self.lock(self.idn, self.id())
|
||||||
self._modifiable = 'w'
|
self._modifiable = 'w'
|
||||||
except EnvironmentError , c:
|
except EnvironmentError , c:
|
||||||
self._modifiable = 0
|
self._modifiable = 0
|
||||||
|
@ -1870,7 +1874,7 @@ class machine(base_classes_crans) :
|
||||||
raise ValueError(u"Il s'agit de l'adresse MAC d'une interface PPP.", 2)
|
raise ValueError(u"Il s'agit de l'adresse MAC d'une interface PPP.", 2)
|
||||||
|
|
||||||
# Lock de la mac
|
# Lock de la mac
|
||||||
self._locks.append(self.lock('macAddress',mac))
|
self.lock('macAddress',mac)
|
||||||
|
|
||||||
self._set('macAddress',[mac])
|
self._set('macAddress',[mac])
|
||||||
return mac
|
return mac
|
||||||
|
@ -1917,7 +1921,7 @@ class machine(base_classes_crans) :
|
||||||
raise ValueError(u"%s : nom déjà pris" % champ.capitalize())
|
raise ValueError(u"%s : nom déjà pris" % champ.capitalize())
|
||||||
|
|
||||||
# Lock host
|
# Lock host
|
||||||
self._locks.append(self.lock('host',new))
|
self.lock('host',new)
|
||||||
|
|
||||||
return new
|
return new
|
||||||
|
|
||||||
|
@ -2078,7 +2082,7 @@ class machine(base_classes_crans) :
|
||||||
raise ValueError(u'IP déjà prise.')
|
raise ValueError(u'IP déjà prise.')
|
||||||
|
|
||||||
# Lock ip
|
# Lock ip
|
||||||
self._locks.append(self.lock('ipHostNumber',ip))
|
self.lock('ipHostNumber',ip)
|
||||||
|
|
||||||
self._set('ipHostNumber',[ip])
|
self._set('ipHostNumber',[ip])
|
||||||
return ip
|
return ip
|
||||||
|
@ -2266,6 +2270,7 @@ class machine(base_classes_crans) :
|
||||||
if 'ipsec' in self.modifs :
|
if 'ipsec' in self.modifs :
|
||||||
ret += coul(u'Clef IPsec de la machine : %s\n' % self.ipsec(),'cyan')
|
ret += coul(u'Clef IPsec de la machine : %s\n' % self.ipsec(),'cyan')
|
||||||
self.services_to_restart('conf_wifi')
|
self.services_to_restart('conf_wifi')
|
||||||
|
self.services_to_restart('conf_wifi_ng')
|
||||||
|
|
||||||
# Reconfiguration firewalls et dhcps
|
# Reconfiguration firewalls et dhcps
|
||||||
if reconf_ip :
|
if reconf_ip :
|
||||||
|
@ -2285,10 +2290,12 @@ class machine(base_classes_crans) :
|
||||||
# Reconfiguration bornes wifi ?
|
# Reconfiguration bornes wifi ?
|
||||||
if 'canal' in self.modifs or 'puissance' in self.modifs :
|
if 'canal' in self.modifs or 'puissance' in self.modifs :
|
||||||
self.services_to_restart('bornes_wifi',[self.nom()])
|
self.services_to_restart('bornes_wifi',[self.nom()])
|
||||||
|
self.services_to_restart('conf_wifi_ng')
|
||||||
|
|
||||||
# Reconfiguration clients wifi ?
|
# Reconfiguration clients wifi ?
|
||||||
if self.__typ == 'wifi' and ( 'ipHostNumber' in self.modifs or 'host' in self.modifs or 'macAddress' in self.modifs ) :
|
if self.__typ == 'wifi' and ( 'ipHostNumber' in self.modifs or 'host' in self.modifs or 'macAddress' in self.modifs ) :
|
||||||
self.services_to_restart('conf_wifi')
|
self.services_to_restart('conf_wifi')
|
||||||
|
self.services_to_restart('conf_wifi_ng')
|
||||||
|
|
||||||
# Regénération blackliste nécessaire ?
|
# Regénération blackliste nécessaire ?
|
||||||
bl = self.blacklist_actif()
|
bl = self.blacklist_actif()
|
||||||
|
@ -2322,6 +2329,7 @@ class machine(base_classes_crans) :
|
||||||
# Services à redémarrer
|
# Services à redémarrer
|
||||||
if self.__typ == 'wifi' :
|
if self.__typ == 'wifi' :
|
||||||
self.services_to_restart('conf_wifi')
|
self.services_to_restart('conf_wifi')
|
||||||
|
self.services_to_restart('conf_wifi_ng')
|
||||||
self.services_to_restart('nectaris-dhcp')
|
self.services_to_restart('nectaris-dhcp')
|
||||||
else:
|
else:
|
||||||
self.services_to_restart('rouge-dhcp')
|
self.services_to_restart('rouge-dhcp')
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue