[ldap_crans/gest_crans] Ajout d'une fonction de log, et interversion de l'affectation d'une ip, et des tests sur la mac, sinon l'ipv6 ça juste marche pas
This commit is contained in:
parent
5406f3fcd4
commit
559583654b
2 changed files with 11 additions and 6 deletions
|
@ -1501,6 +1501,10 @@ def set_machine(machine):
|
||||||
except ValueError, c: err += c.args[0] + '\n'
|
except ValueError, c: err += c.args[0] + '\n'
|
||||||
except EnvironmentError, 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])
|
try: machine.mac(result[1])
|
||||||
except ValueError, c:
|
except ValueError, c:
|
||||||
if len(c.args)>1 and c.args[1] == 1 and isadm:
|
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'
|
err += c.args[0] + '\n'
|
||||||
|
|
||||||
except EnvironmentError, 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 ?
|
|
||||||
|
|
||||||
if isadm:
|
if isadm:
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -204,6 +204,10 @@ def is_actif(sanction):
|
||||||
fin = int(bl[1])
|
fin = int(bl[1])
|
||||||
return debut < now and fin > now
|
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):
|
def format_mac(mac):
|
||||||
"""
|
"""
|
||||||
|
@ -2856,14 +2860,15 @@ Contactez nounou si la MAC est bien celle d'une carte.""", 3)
|
||||||
|
|
||||||
# Lock de la mac
|
# Lock de la mac
|
||||||
self.lock('macAddress', mac)
|
self.lock('macAddress', mac)
|
||||||
|
net = self.netv6()
|
||||||
try:
|
try:
|
||||||
self._set('macAddress', [mac])
|
self._set('macAddress', [mac])
|
||||||
if self.netv6() != 'special':
|
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:
|
else:
|
||||||
self.ipv6(config.ipv6_machines_speciales[int(self.rid())])
|
self.ipv6(config.ipv6_machines_speciales[int(self.rid())])
|
||||||
except:
|
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
|
return mac
|
||||||
|
|
||||||
def __host_alias(self, champ, new):
|
def __host_alias(self, champ, new):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue