From cead9aab1980555a94f52f4525427bba66920c09 Mon Sep 17 00:00:00 2001 From: chirac Date: Fri, 22 Jun 2018 17:48:10 +0200 Subject: [PATCH] Fix gen_range + macaddress non unique --- machines/models.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/machines/models.py b/machines/models.py index fe1923bb..25ca82e5 100644 --- a/machines/models.py +++ b/machines/models.py @@ -305,12 +305,9 @@ class IpType(RevMixin, AclMixin, models.Model): crée les ip une par une. Si elles existent déjà, met à jour le type associé à l'ip""" # Creation du range d'ip dans les objets iplist - networks = [] - for net in self.ip_range.cidrs(): - networks += net.iter_hosts() - ip_obj = [IpList(ip_type=self, ipv4=str(ip)) for ip in networks] + ip_obj = [IpList(ip_type=self, ipv4=str(ip)) for ip in self.ip_range] listes_ip = IpList.objects.filter( - ipv4__in=[str(ip) for ip in networks] + ipv4__in=[str(ip) for ip in self.ip_range] ) # Si il n'y a pas d'ip, on les crée if not listes_ip: @@ -730,7 +727,7 @@ class Interface(RevMixin, AclMixin, FieldPermissionModelMixin, models.Model): blank=True, null=True ) - mac_address = MACAddressField(integer=False, unique=True) + mac_address = MACAddressField(integer=False) machine = models.ForeignKey('Machine', on_delete=models.CASCADE) type = models.ForeignKey('MachineType', on_delete=models.PROTECT) details = models.CharField(max_length=255, blank=True)