diff --git a/machines/migrations/0048_auto_20170823_2315.py b/machines/migrations/0048_auto_20170823_2315.py new file mode 100644 index 00000000..0c0a48f3 --- /dev/null +++ b/machines/migrations/0048_auto_20170823_2315.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.7 on 2017-08-23 21:15 +from __future__ import unicode_literals + +import django.core.validators +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('machines', '0047_auto_20170809_0606'), + ] + + operations = [ + migrations.AlterField( + model_name='iptype', + name='domaine_range', + field=models.IntegerField(validators=[django.core.validators.MinValueValidator(16), django.core.validators.MaxValueValidator(32)]), + ), + ] diff --git a/machines/models.py b/machines/models.py index 2207d1b6..bd4426c3 100644 --- a/machines/models.py +++ b/machines/models.py @@ -68,7 +68,7 @@ class IpType(models.Model): extension = models.ForeignKey('Extension', on_delete=models.PROTECT) need_infra = models.BooleanField(default=False) domaine_ip = models.GenericIPAddressField(protocol='IPv4') - domaine_range = models.IntegerField(validators=[MinValueValidator(8), MaxValueValidator(32)]) + domaine_range = models.IntegerField(validators=[MinValueValidator(16), MaxValueValidator(32)]) @cached_property def network(self): @@ -94,8 +94,9 @@ class IpType(models.Model): def gen_ip_range(self): # Creation du range d'ip dans les objets iplist - for ip in self.ip_network.iter_hosts(): - obj, created = IpList.objects.get_or_create(ip_type=self, ipv4=str(ip)) + ip_obj = [IpList(ip_type=self, ipv4=str(ip)) for ip in self.ip_network.iter_hosts()] + IpList.objects.bulk_create(ip_obj) + return def del_ip_range(self): """ Methode dépréciée, IpList est en mode cascade et supprimé automatiquement"""