Le serveur gitlab sera inaccessible le mercredi 19 février 2020 de 13h à 14h pour une intervention de maintenance programmée.

Commit df586142 authored by Charlie Jacomme's avatar Charlie Jacomme Committed by chirac

radius, make python compatible, and add traceback

parent 433a85f6
......@@ -1005,7 +1005,7 @@ class Interface(RevMixin, AclMixin, FieldPermissionModelMixin, models.Model):
def gen_ipv6_dhcpv6(self):
"""Cree une ip, à assigner avec dhcpv6 sur une machine"""
prefix_v6 = self.type.ip_type.prefix_v6
prefix_v6 = self.type.ip_type.prefix_v6.encode().decode('utf-8')
if not prefix_v6:
return None
return IPv6Address(
......@@ -1331,14 +1331,14 @@ class Ipv6List(RevMixin, AclMixin, FieldPermissionModelMixin, models.Model):
def check_and_replace_prefix(self, prefix=None):
"""Si le prefixe v6 est incorrect, on maj l'ipv6"""
prefix_v6 = prefix or self.interface.type.ip_type.prefix_v6
prefix_v6 = prefix or self.interface.type.ip_type.prefix_v6.encode().decode('utf-8')
if not prefix_v6:
if (IPv6Address(self.ipv6).exploded[:20] !=
if (IPv6Address(self.ipv6.encode().decode('utf-8')).exploded[:20] !=
self.ipv6 = IPv6Address(
IPv6Address(prefix_v6).exploded[:20] +
......@@ -1347,9 +1347,9 @@ class Ipv6List(RevMixin, AclMixin, FieldPermissionModelMixin, models.Model):
.filter(interface=self.interface, slaac_ip=True)
raise ValidationError("Une ip slaac est déjà enregistrée")
prefix_v6 = self.interface.type.ip_type.prefix_v6
prefix_v6 = self.interface.type.ip_type.prefix_v6.encode().decode('utf-8')
if prefix_v6:
if (IPv6Address(self.ipv6).exploded[:20] !=
if (IPv6Address(self.ipv6.encode().decode('utf-8')).exploded[:20] !=
raise ValidationError(
"Le prefixv6 est incorrect et ne correspond pas au type "
......@@ -1850,7 +1850,7 @@ def machine_post_save(**kwargs):
"""Synchronisation ldap et régen parefeu/dhcp lors de la modification
d'une machine"""
user = kwargs['instance'].user
user.ldap_sync(base=False, access_refresh=False, mac_refresh=True)
#user.ldap_sync(base=False, access_refresh=False, mac_refresh=True)
......@@ -48,6 +48,7 @@ from __future__ import unicode_literals
import re
import uuid
import datetime
import sys
from django.db import models
from django.db.models import Q
......@@ -67,7 +68,7 @@ from django.contrib.auth.models import (
from django.core.validators import RegexValidator
import traceback
from reversion import revisions as reversion
import ldapdb.models
......@@ -539,6 +540,7 @@ class User(RevMixin, FieldPermissionModelMixin, AbstractBaseUser,
mac_refresh : synchronise les machines de l'user
group_refresh : synchronise les group de l'user
Si l'instance n'existe pas, on crée le ldapuser correspondant"""
if sys.version_info[0] >= 3:
user_ldap = LdapUser.objects.get(uidNumber=self.uid_number)
......@@ -679,7 +681,7 @@ class User(RevMixin, FieldPermissionModelMixin, AbstractBaseUser,
except Exception as error:
return False, error
return False, traceback.format_exc()
return interface_cible, "Ok"
def notif_auto_newmachine(self, interface):
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment