mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-12-26 17:03:45 +00:00
Merge branch 'fix_import_crans' into 'dev'
Fix gen_range + macaddress non unique See merge request federez/re2o!218
This commit is contained in:
commit
679ae86243
2 changed files with 24 additions and 6 deletions
21
machines/migrations/0089_auto_20180805_1148.py
Normal file
21
machines/migrations/0089_auto_20180805_1148.py
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.10.7 on 2018-08-05 09:48
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
import macaddress.fields
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('machines', '0088_iptype_prefix_v6_length'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='interface',
|
||||||
|
name='mac_address',
|
||||||
|
field=macaddress.fields.MACAddressField(integer=False, max_length=17),
|
||||||
|
),
|
||||||
|
]
|
|
@ -351,12 +351,9 @@ class IpType(RevMixin, AclMixin, models.Model):
|
||||||
crée les ip une par une. Si elles existent déjà, met à jour le type
|
crée les ip une par une. Si elles existent déjà, met à jour le type
|
||||||
associé à l'ip"""
|
associé à l'ip"""
|
||||||
# Creation du range d'ip dans les objets iplist
|
# Creation du range d'ip dans les objets iplist
|
||||||
networks = []
|
ip_obj = [IpList(ip_type=self, ipv4=str(ip)) for ip in self.ip_range]
|
||||||
for net in self.ip_range.cidrs():
|
|
||||||
networks += net.iter_hosts()
|
|
||||||
ip_obj = [IpList(ip_type=self, ipv4=str(ip)) for ip in networks]
|
|
||||||
listes_ip = IpList.objects.filter(
|
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
|
# Si il n'y a pas d'ip, on les crée
|
||||||
if not listes_ip:
|
if not listes_ip:
|
||||||
|
@ -900,7 +897,7 @@ class Interface(RevMixin, AclMixin, FieldPermissionModelMixin, models.Model):
|
||||||
blank=True,
|
blank=True,
|
||||||
null=True
|
null=True
|
||||||
)
|
)
|
||||||
mac_address = MACAddressField(integer=False, unique=True)
|
mac_address = MACAddressField(integer=False)
|
||||||
machine = models.ForeignKey('Machine', on_delete=models.CASCADE)
|
machine = models.ForeignKey('Machine', on_delete=models.CASCADE)
|
||||||
type = models.ForeignKey('MachineType', on_delete=models.PROTECT)
|
type = models.ForeignKey('MachineType', on_delete=models.PROTECT)
|
||||||
details = models.CharField(max_length=255, blank=True)
|
details = models.CharField(max_length=255, blank=True)
|
||||||
|
|
Loading…
Reference in a new issue