diff --git a/gestion/gen_confs/generate.py b/gestion/gen_confs/generate.py index 84804a81..9e98d405 100755 --- a/gestion/gen_confs/generate.py +++ b/gestion/gen_confs/generate.py @@ -302,7 +302,7 @@ Subject: Modifications sur une machine du CR@NS from gen_confs.bind import dns inst.append([dns(),"dns"]) - if 'dhcp' in to_do.keys() : + if 'dhcp' in to_do.keys() or 'dhcp-nectaris' in to_do.keys() : from gen_confs.dhcpd import dhcp inst.append([dhcp(),"dhcp"]) diff --git a/gestion/ldap_crans.py b/gestion/ldap_crans.py index 761a94a5..f377f8b4 100755 --- a/gestion/ldap_crans.py +++ b/gestion/ldap_crans.py @@ -410,7 +410,9 @@ class crans_ldap : except ldap.ALREADY_EXISTS : # Existe déja => rien à faire pass - + except : + print modlist + def search(self,expression,mode='') : """ Recherche dans la base LDAP, expression est une chaîne : @@ -858,27 +860,15 @@ class base_classes_crans(crans_ldap) : ### Génération de la liste de services à redémarrer # Correspondance modif de la base -> service ayant besoin d'être redémarré - # pour paiement et carte d'étudiant : traitement dans la classe adhérent - # car il faut vérifier l'existance de machines - annuaire_modif_service = { 'host' : [ 'dhcp', 'dhcp-nectaris', 'dns' ], - 'ipHostNumber' : [ 'dhcp', 'dhcp-nectaris', 'dns', 'firewall' ], - 'macAddress' : [ 'dhcp', 'dhcp-nectaris', 'dns', 'firewall' ], - 'ipsec' : [ 'conf_wifi' ], - 'hostAlias' : [ 'dns' ] , - 'droits' : [ 'droits' ] , - 'ports' : [ 'firewall-komaz' ] , - } - + # Une grosse partie du traitement est délocalisé dans les classes filles. serv = [] for m in self.modifs : if sre.match('blacklist_*',m) : serv.append(m) elif m == 'chbre' and '????' in [ self._init_data.get("chbre",[''])[0] , self._data.get("chbre",[''])[0] ] : serv.append('bl_chbre_invalide') - else : - for s in annuaire_modif_service.get(m,[]) : - if s not in serv : - serv.append(s) + elif m == 'droits' : + serv.append('droits') # Reinitialisation self._init_data = self._data.copy() @@ -2052,22 +2042,43 @@ class machine(base_classes_crans) : raise EnvironmentError(u'Il faut être administrateur pour effectuer cette opération.') ret ='' - + + # Besion de redémarrer les firewalls ? + if 'ipHostNumber' in self.modifs or 'macAddress' in self.modifs : + reconf_ip = self._init_data.get('ipHostNumber',[]) + reconf_ip += self._data.get('ipHostNumber',[]) + else : + reconf_ip = [] + # Enregistrement self._save() # Clef IPsec if 'ipsec' in self.modifs : ret += coul(u'Clef IPsec de la machine : %s\n' % self.ipsec(),'cyan') - elif 'macAddress' in self.modifs and self.__typ == 'fixe' : - # Reconfiguration switch necessaire - self.services_to_restart('switch',[self.proprietaire().chbre()]) - + self.services_to_restart('conf_wifi') + + # Reconfiguration firewalls et dhcps + if reconf_ip : + self.services_to_restart('firewall' , reconf_ip) + self.services_to_restart('firewall-komaz' , reconf_ip) + if self.__typ == 'wifi' : + self.services_to_restart('dhcp-nectaris') + else : + self.services_to_restart('dhcp') + if 'ports' in self.modifs : + self.services_to_restart('firewall-komaz', [ self.ip() ] ) + + # Reconfiguration DNS ? + if 'host' in self.modifs or 'ipHostNumber' in self.modifs or 'hostAlias' in self.modifs : + self.services_to_restart('dns') + + # Reconfiguration bornes wifi ? if 'canal' in self.modifs or 'puissance' in self.modifs : self.services_to_restart('bornes_wifi',[self.nom()]) + # Reconfiguration clients wifi ? if self.__typ == 'wifi' and ( 'ipHostNumber' in self.modifs or 'host' in self.modifs ) : - # Reconfiguration clients wifi necessaire self.services_to_restart('conf_wifi') # Regénération blackliste nécessaire ? @@ -2076,12 +2087,9 @@ class machine(base_classes_crans) : for s in bl : self.services_to_restart(s,[ self.ip() ] ) - # Regénération de l'autostatus ? + # Regénération de l'autostatus et mail de changmement ? if self.proprietaire().__class__ == crans : self.services_to_restart('autostatus') - - # On envoie un mail pour annoncer le changement - if self.proprietaire().__class__ == crans : self.services_to_restart('mail_modification_machine',[self.ip()]) # Remise à zéro @@ -2097,19 +2105,21 @@ class machine(base_classes_crans) : if self.proprietaire().__class__ == crans and not isadm : raise EnvironmentError(u'Il faut être administrateur pour effectuer cette opération.') - if self.__typ == 'wifi' : - self.services_to_restart('conf_wifi') - elif self.__typ == 'fixe' : - self.services_to_restart('switch',[ self.proprietaire().chbre() ]) self.proprio = self.__proprietaire.Nom() # On met dans un coin le nom du proprio self.__proprietaire = None # On oublie le propriétaire self._delete(self.dn,comment) + + # Services à redémarrer + if self.__typ == 'wifi' : + self.services_to_restart('conf_wifi') + self.services_to_restart('dhcp-nectaris') + else : + self.services_to_restart('dhcp') - self.services_to_restart('dhcp') - self.services_to_restart('dhcp-nectaris') self.services_to_restart('dns') - self.services_to_restart('firewall',[ self.nom() ]) + self.services_to_restart('firewall',[ self.ip() ]) + self.services_to_restart('firewall-komaz',[ self.ip() ]) def portTCPin(self,ports=None) : """ Ports TCP ouverts depuis l'extérieur pour la machine """