8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-05 09:26:27 +00:00

Ading prefix_v6_length field to IpType

This commit is contained in:
Charlie Jacomme 2018-07-16 20:52:39 +02:00
parent 0220920067
commit fc612f47dc
4 changed files with 35 additions and 6 deletions

View file

@ -219,7 +219,8 @@ class IpTypeForm(FormRevMixin, ModelForm):
model = IpType model = IpType
fields = ['type', 'extension', 'need_infra', 'domaine_ip_start', fields = ['type', 'extension', 'need_infra', 'domaine_ip_start',
'domaine_ip_stop', 'dnssec_reverse_v4', 'prefix_v6', 'domaine_ip_stop', 'dnssec_reverse_v4', 'prefix_v6',
'dnssec_reverse_v6', 'vlan', 'ouverture_ports'] 'prefix_v6_length','dnssec_reverse_v6', 'vlan',
'ouverture_ports']
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
prefix = kwargs.pop('prefix', self.Meta.model.__name__) prefix = kwargs.pop('prefix', self.Meta.model.__name__)
@ -231,8 +232,8 @@ class EditIpTypeForm(IpTypeForm):
"""Edition d'un iptype. Pas d'edition du rangev4 possible, car il faudrait """Edition d'un iptype. Pas d'edition du rangev4 possible, car il faudrait
synchroniser les objets iplist""" synchroniser les objets iplist"""
class Meta(IpTypeForm.Meta): class Meta(IpTypeForm.Meta):
fields = ['extension', 'type', 'need_infra', 'prefix_v6', 'vlan', fields = ['extension', 'type', 'need_infra', 'prefix_v6', 'prefix_v6_length',
'dnssec_reverse_v4', 'dnssec_reverse_v6', 'vlan', 'dnssec_reverse_v4', 'dnssec_reverse_v6',
'ouverture_ports'] 'ouverture_ports']

View file

@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.7 on 2018-07-16 18:46
from __future__ import unicode_literals
import django.core.validators
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('machines', '0094_role_specific_role'),
]
operations = [
migrations.AddField(
model_name='iptype',
name='prefix_v6_length',
field=models.IntegerField(default=64, validators=[django.core.validators.MaxValueValidator(128), django.core.validators.MinValueValidator(0)]),
),
]

View file

@ -39,7 +39,7 @@ from django.dispatch import receiver
from django.forms import ValidationError from django.forms import ValidationError
from django.utils.functional import cached_property from django.utils.functional import cached_property
from django.utils import timezone from django.utils import timezone
from django.core.validators import MaxValueValidator from django.core.validators import MaxValueValidator, MinValueValidator
from macaddress.fields import MACAddressField from macaddress.fields import MACAddressField
@ -343,6 +343,13 @@ class IpType(RevMixin, AclMixin, models.Model):
null=True, null=True,
blank=True blank=True
) )
prefix_v6_length = models.IntegerField(
default=64,
validators=[
MaxValueValidator(128),
MinValueValidator(0)
]
)
dnssec_reverse_v6 = models.BooleanField( dnssec_reverse_v6 = models.BooleanField(
default=False, default=False,
help_text="Activer DNSSEC sur le reverse DNS IPv6", help_text="Activer DNSSEC sur le reverse DNS IPv6",
@ -405,7 +412,7 @@ class IpType(RevMixin, AclMixin, models.Model):
return { return {
'network' : str(self.prefix_v6), 'network' : str(self.prefix_v6),
'netmask' : 'ffff:ffff:ffff:ffff::', 'netmask' : 'ffff:ffff:ffff:ffff::',
'netmask_cidr' : '64', 'netmask_cidr' : str(self.prefix_v6_length),
'vlan': str(self.vlan), 'vlan': str(self.vlan),
'vlan_id': self.vlan.vlan_id 'vlan_id': self.vlan.vlan_id
} }

View file

@ -45,7 +45,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<td>{{ type.extension }}</td> <td>{{ type.extension }}</td>
<td>{{ type.need_infra }}</td> <td>{{ type.need_infra }}</td>
<td>{{ type.domaine_ip_start }}-{{ type.domaine_ip_stop }}</td> <td>{{ type.domaine_ip_start }}-{{ type.domaine_ip_stop }}</td>
<td>{{ type.prefix_v6 }}</td> <td>{{ type.prefix_v6 }}/{{ type.prefix_v6_length }}</td>
<td>{{ type.dnssec_reverse_v4 }}/{{ type.dnssec_reverse_v6 }}</td> <td>{{ type.dnssec_reverse_v4 }}/{{ type.dnssec_reverse_v6 }}</td>
<td>{{ type.vlan }}</td> <td>{{ type.vlan }}</td>
<td>{{ type.ouverture_ports }}</td> <td>{{ type.ouverture_ports }}</td>