Service redmarrer temporis pour les blacklists.

darcs-hash:20051002191118-41617-8897f3cdbb75d0ebbcdd70df63b748421cce9019.gz
This commit is contained in:
pauget 2005-10-02 21:11:18 +02:00
parent 78d5ac0e36
commit da9b6f7900

View file

@ -810,15 +810,22 @@ class base_classes_crans(crans_ldap) :
# Verif que les dates sont OK # Verif que les dates sont OK
if new[0] == 'now' : if new[0] == 'now' :
new[0] = time.strftime(date_format) new[0] = time.strftime(date_format)
debut=0
else : else :
try : time.strptime(new[0],date_format) try : debut=int(time.mktime(time.strptime(new[0],date_format)))
except : raise ValueError(u'Date de début blacklist invalide') except : raise ValueError(u'Date de début blacklist invalide')
if new[1] == 'now' : if new[1] == 'now' :
new[1] = time.strftime(date_format) new[1] = time.strftime(date_format)
elif new[1]!='-' : fin=0
try : time.strptime(new[1],date_format) elif new[1]!='-' :
try : fin=int(time.mktime(time.strptime(new[1],date_format)))
except : raise ValueError(u'Date de fin blacklist invalide') except : raise ValueError(u'Date de fin blacklist invalide')
else :
fin = -1
if debut == fin :
raise ValueError(u'Dates de début et fin identiques')
new_c = ','.join(new) new_c = ','.join(new)
new_c = preattr(new_c)[1] new_c = preattr(new_c)[1]
@ -831,6 +838,15 @@ class base_classes_crans(crans_ldap) :
if self._data['blacklist'] != liste : if self._data['blacklist'] != liste :
self._data['blacklist']=liste self._data['blacklist']=liste
self.modifs.append('blacklist_' + new[2]) self.modifs.append('blacklist_' + new[2])
if not hasattr(self,"__blacklist_restart") :
self.__blacklist_restart={}
if self.__blacklist_restart.has_key(new[2]) :
self.__blacklist_restart[new[2]] = [ debut, fin ]
else :
if debut not in self.__blacklist_restart[new[2]] :
self.__blacklist_restart[new[2]].Append(debut)
if fin!=-1 and fin not in self.__blacklist_restart[new[2]] :
self.__blacklist_restart[new[2]].Append(fin)
return liste return liste
@ -977,9 +993,9 @@ class base_classes_crans(crans_ldap) :
### Génération de la liste de services à redémarrer ### Génération de la liste de services à redémarrer
# Quasiement tout est traité dans les classes filles. # Quasiement tout est traité dans les classes filles.
for m in self.modifs : if hasattr(self,"__blacklist_restart") :
if sre.match('blacklist_*',m) : for n,t in self.__blacklist_restart.items() :
self.services_to_restart(m) self.services_to_restart("blacklist_%s"%n,[],t)
# Reinitialisation # Reinitialisation
self._init_data = self._data.copy() self._init_data = self._data.copy()