From e86a0ff58b2940d0f39a375aee53bf4645d235f6 Mon Sep 17 00:00:00 2001 From: Charlie Jacomme Date: Tue, 7 Aug 2018 09:24:21 +0200 Subject: [PATCH 1/3] add prefix_v6_length serializer --- api/serializers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/serializers.py b/api/serializers.py index 6cc020f3..55345b18 100644 --- a/api/serializers.py +++ b/api/serializers.py @@ -864,7 +864,7 @@ class DNSReverseZonesSerializer(serializers.ModelSerializer): model = machines.IpType fields = ('type', 'extension', 'soa', 'ns_records', 'mx_records', 'txt_records', 'ptr_records', 'ptr_v6_records', 'cidrs', - 'prefix_v6') + 'prefix_v6', 'prefix_v6_length') # MAILING From cee0d1188ee5e51e6e9e8889810ffeea89b4e34e Mon Sep 17 00:00:00 2001 From: Charlie Jacomme Date: Tue, 7 Aug 2018 09:52:00 +0200 Subject: [PATCH 2/3] rename booleans dnssec_reverse_* to reverse_* --- machines/forms.py | 2 +- .../migrations/0092_auto_20180807_0926.py | 25 +++++++++++++++++++ machines/models.py | 8 +++--- machines/templates/machines/aff_iptype.html | 2 +- 4 files changed, 31 insertions(+), 6 deletions(-) create mode 100644 machines/migrations/0092_auto_20180807_0926.py diff --git a/machines/forms.py b/machines/forms.py index c0af0bd6..b68cb203 100644 --- a/machines/forms.py +++ b/machines/forms.py @@ -231,7 +231,7 @@ class EditIpTypeForm(IpTypeForm): class Meta(IpTypeForm.Meta): fields = ['extension', 'type', 'need_infra', 'domaine_ip_network', 'domaine_ip_netmask', 'prefix_v6', 'prefix_v6_length', - 'vlan', 'dnssec_reverse_v4', 'dnssec_reverse_v6', + 'vlan', 'reverse_v4', 'reverse_v6', 'ouverture_ports'] diff --git a/machines/migrations/0092_auto_20180807_0926.py b/machines/migrations/0092_auto_20180807_0926.py new file mode 100644 index 00000000..f109a650 --- /dev/null +++ b/machines/migrations/0092_auto_20180807_0926.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.7 on 2018-08-07 07:26 +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('machines', '0091_auto_20180806_2310'), + ] + + operations = [ + migrations.RenameField( + model_name='iptype', + old_name='dnssec_reverse_v4', + new_name='reverse_v4', + ), + migrations.RenameField( + model_name='iptype', + old_name='dnssec_reverse_v6', + new_name='reverse_v6', + ), + ] diff --git a/machines/models.py b/machines/models.py index 34f91adf..2bf362eb 100644 --- a/machines/models.py +++ b/machines/models.py @@ -292,9 +292,9 @@ class IpType(RevMixin, AclMixin, models.Model): ], help_text="Netmask for the ipv4 range domain" ) - dnssec_reverse_v4 = models.BooleanField( + reverse_v4 = models.BooleanField( default=False, - help_text="Activer DNSSEC sur le reverse DNS IPv4", + help_text="Enable reverse DNS for IPv4", ) prefix_v6 = models.GenericIPAddressField( protocol='IPv6', @@ -308,9 +308,9 @@ class IpType(RevMixin, AclMixin, models.Model): MinValueValidator(0) ] ) - dnssec_reverse_v6 = models.BooleanField( + reverse_v6 = models.BooleanField( default=False, - help_text="Activer DNSSEC sur le reverse DNS IPv6", + help_text="Enable reverse DNS for IPv6", ) vlan = models.ForeignKey( 'Vlan', diff --git a/machines/templates/machines/aff_iptype.html b/machines/templates/machines/aff_iptype.html index ccb70a14..afd35d1b 100644 --- a/machines/templates/machines/aff_iptype.html +++ b/machines/templates/machines/aff_iptype.html @@ -48,7 +48,7 @@ with this program; if not, write to the Free Software Foundation, Inc., {{ type.need_infra|tick }} {{ type.domaine_ip_start }}-{{ type.domaine_ip_stop }}{% if type.ip_network %} on {{ type.ip_network }}{% endif %} {{ type.prefix_v6 }}/{{ type.prefix_v6_length }} - {{ type.dnssec_reverse_v4|tick }}/{{ type.dnssec_reverse_v6|tick }} + {{ type.reverse_v4|tick }}/{{ type.reverse_v6|tick }} {{ type.vlan }} {{ type.ouverture_ports }} From b9a4dd6d65579322df9195faefb727a2d5d4484d Mon Sep 17 00:00:00 2001 From: Charlie Jacomme Date: Tue, 7 Aug 2018 09:57:59 +0200 Subject: [PATCH 3/3] ptr are empty if revere disabled --- machines/models.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/machines/models.py b/machines/models.py index 2bf362eb..b9fd9205 100644 --- a/machines/models.py +++ b/machines/models.py @@ -450,14 +450,20 @@ class IpType(RevMixin, AclMixin, models.Model): def get_associated_ptr_records(self): from re2o.utils import all_active_assigned_interfaces - return (all_active_assigned_interfaces() - .filter(type__ip_type=self) - .filter(ipv4__isnull=False)) + if self.reverse_v4: + return (all_active_assigned_interfaces() + .filter(type__ip_type=self) + .filter(ipv4__isnull=False)) + else: + return None def get_associated_ptr_v6_records(self): from re2o.utils import all_active_interfaces - return (all_active_interfaces(full=True) - .filter(type__ip_type=self)) + if self.reverse_v6: + return (all_active_interfaces(full=True) + .filter(type__ip_type=self)) + else: + return None def clean(self): """ Nettoyage. VĂ©rifie :