From 559583654b4b5be9a343f679ed60324f6c3f34db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre-Elliott=20B=C3=A9cue?= Date: Fri, 22 Feb 2013 19:31:54 +0100 Subject: [PATCH] =?UTF-8?q?[ldap=5Fcrans/gest=5Fcrans]=20Ajout=20d'une=20f?= =?UTF-8?q?onction=20de=20log,=20et=20interversion=20de=20l'affectation=20?= =?UTF-8?q?d'une=20ip,=20et=20des=20tests=20sur=20la=20mac,=20sinon=20l'ip?= =?UTF-8?q?v6=20=C3=A7a=20juste=20marche=20pas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gestion/gest_crans.py | 8 ++++---- gestion/ldap_crans.py | 9 +++++++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/gestion/gest_crans.py b/gestion/gest_crans.py index 421c27cb..043f2e52 100755 --- a/gestion/gest_crans.py +++ b/gestion/gest_crans.py @@ -1501,6 +1501,10 @@ def set_machine(machine): except ValueError, c: err += c.args[0] + '\n' except EnvironmentError, c: err += c.args[0] + '\n' + try: machine.ip(result[2]) + except ValueError, c: err += c.args[0] + '\n' + except EnvironmentError, c: err += c.__str__() + '\n' + except RuntimeError, c: err += c.args[0] + '\n' # Plus d'IP libres, peut-être à traiter differement ? try: machine.mac(result[1]) except ValueError, c: if len(c.args)>1 and c.args[1] == 1 and isadm: @@ -1529,10 +1533,6 @@ def set_machine(machine): err += c.args[0] + '\n' except EnvironmentError, c: err += c.args[0] + '\n' - try: machine.ip(result[2]) - except ValueError, c: err += c.args[0] + '\n' - except EnvironmentError, c: err += c.__str__() + '\n' - except RuntimeError, c: err += c.args[0] + '\n' # Plus d'IP libres, peut-être à traiter differement ? if isadm: try: diff --git a/gestion/ldap_crans.py b/gestion/ldap_crans.py index 6f309348..51b83f7f 100755 --- a/gestion/ldap_crans.py +++ b/gestion/ldap_crans.py @@ -204,6 +204,10 @@ def is_actif(sanction): fin = int(bl[1]) return debut < now and fin > now +def log(contenu): + with open('/tmp/crans.log', 'a') as f: + f.writelines(contenu) + f.writelines('\n') def format_mac(mac): """ @@ -2856,14 +2860,15 @@ Contactez nounou si la MAC est bien celle d'une carte.""", 3) # Lock de la mac self.lock('macAddress', mac) + net = self.netv6() try: self._set('macAddress', [mac]) if self.netv6() != 'special': - self.ipv6(ip6tools.mac_to_ipv6(self.netv6(), netaddr.EUI(mac))) + self.ipv6(ip6tools.mac_to_ipv6(net, netaddr.EUI(mac))) else: self.ipv6(config.ipv6_machines_speciales[int(self.rid())]) except: - raise ValueError('La correspondance MAC <-> EUID64 a planté. Tapez PEB et son entourage.') + raise ValueError('La correspondance MAC <-> EUID64 a planté. Tapez PEB et son entourage. (net : %s, mac : %s, ' % (net, mac)) return mac def __host_alias(self, champ, new):