mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-22 11:23:10 +00:00
Ading prefix_v6_length field to IpType
This commit is contained in:
parent
6aed938334
commit
4329641899
4 changed files with 61 additions and 5 deletions
|
@ -219,7 +219,8 @@ class IpTypeForm(FormRevMixin, ModelForm):
|
|||
model = IpType
|
||||
fields = ['type', 'extension', 'need_infra', 'domaine_ip_start',
|
||||
'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):
|
||||
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
|
||||
synchroniser les objets iplist"""
|
||||
class Meta(IpTypeForm.Meta):
|
||||
fields = ['extension', 'type', 'need_infra', 'prefix_v6', 'vlan',
|
||||
'dnssec_reverse_v4', 'dnssec_reverse_v6',
|
||||
fields = ['extension', 'type', 'need_infra', 'prefix_v6', 'prefix_v6_length',
|
||||
'vlan', 'dnssec_reverse_v4', 'dnssec_reverse_v6',
|
||||
'ouverture_ports']
|
||||
|
||||
|
||||
|
|
21
machines/migrations/0088_iptype_prefix_v6_length.py
Normal file
21
machines/migrations/0088_iptype_prefix_v6_length.py
Normal 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', '0087_dnssec'),
|
||||
]
|
||||
|
||||
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)]),
|
||||
),
|
||||
]
|
|
@ -41,8 +41,8 @@ from django.dispatch import receiver
|
|||
from django.forms import ValidationError
|
||||
from django.utils.functional import cached_property
|
||||
from django.utils import timezone
|
||||
from django.core.validators import MaxValueValidator
|
||||
from django.utils.translation import ugettext_lazy as _l
|
||||
from django.core.validators import MaxValueValidator, MinValueValidator
|
||||
|
||||
from macaddress.fields import MACAddressField
|
||||
|
||||
|
@ -265,6 +265,13 @@ class IpType(RevMixin, AclMixin, models.Model):
|
|||
null=True,
|
||||
blank=True
|
||||
)
|
||||
prefix_v6_length = models.IntegerField(
|
||||
default=64,
|
||||
validators=[
|
||||
MaxValueValidator(128),
|
||||
MinValueValidator(0)
|
||||
]
|
||||
)
|
||||
dnssec_reverse_v6 = models.BooleanField(
|
||||
default=False,
|
||||
help_text="Activer DNSSEC sur le reverse DNS IPv6",
|
||||
|
@ -302,6 +309,33 @@ class IpType(RevMixin, AclMixin, models.Model):
|
|||
""" Renvoie une liste des ip en string"""
|
||||
return [str(x) for x in self.ip_set]
|
||||
|
||||
@cached_property
|
||||
def ip_set_full_info(self):
|
||||
"""Iter sur les range cidr, et renvoie network, broacast , etc"""
|
||||
return [
|
||||
{
|
||||
'network': str(ip_set.network),
|
||||
'netmask': str(ip_set.netmask),
|
||||
'netmask_cidr': str(ip_set.prefixlen),
|
||||
'broadcast': str(ip_set.broadcast),
|
||||
'vlan': str(self.vlan),
|
||||
'vlan_id': self.vlan.vlan_id
|
||||
} for ip_set in self.ip_set.iter_cidrs()
|
||||
]
|
||||
|
||||
@cached_property
|
||||
def ip6_set_full_info(self):
|
||||
if self.prefix_v6:
|
||||
return {
|
||||
'network' : str(self.prefix_v6),
|
||||
'netmask' : 'ffff:ffff:ffff:ffff::',
|
||||
'netmask_cidr' : str(self.prefix_v6_length),
|
||||
'vlan': str(self.vlan),
|
||||
'vlan_id': self.vlan.vlan_id
|
||||
}
|
||||
else:
|
||||
return None
|
||||
|
||||
def ip_objects(self):
|
||||
""" Renvoie tous les objets ipv4 relié à ce type"""
|
||||
return IpList.objects.filter(ip_type=self)
|
||||
|
|
|
@ -47,7 +47,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
<td>{{ type.extension }}</td>
|
||||
<td>{{ type.need_infra|tick }}</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|tick }}/{{ type.dnssec_reverse_v6|tick }}</td>
|
||||
<td>{{ type.vlan }}</td>
|
||||
<td>{{ type.ouverture_ports }}</td>
|
||||
|
|
Loading…
Reference in a new issue