From 4143558604e69fd42cede229788b7bff69e73d40 Mon Sep 17 00:00:00 2001 From: chirac Date: Wed, 18 Oct 2017 16:27:48 +0200 Subject: [PATCH] Support des enregistrements AAAA sur le @ de la zone --- machines/forms.py | 3 ++- .../migrations/0062_extension_origin_v6.py | 20 +++++++++++++++++++ machines/models.py | 16 +++++++++++++-- machines/serializers.py | 2 +- .../templates/machines/aff_extension.html | 4 +++- 5 files changed, 40 insertions(+), 5 deletions(-) create mode 100644 machines/migrations/0062_extension_origin_v6.py diff --git a/machines/forms.py b/machines/forms.py index 0086c3d6..34d3a2bc 100644 --- a/machines/forms.py +++ b/machines/forms.py @@ -266,13 +266,14 @@ class ExtensionForm(ModelForm): """Formulaire d'ajout et edition d'une extension""" class Meta: model = Extension - fields = ['name', 'need_infra', 'origin'] + fields = '__all__' def __init__(self, *args, **kwargs): prefix = kwargs.pop('prefix', self.Meta.model.__name__) super(ExtensionForm, self).__init__(*args, prefix=prefix, **kwargs) self.fields['name'].label = 'Extension à ajouter' self.fields['origin'].label = 'Enregistrement A origin' + self.fields['origin_v6'].label = 'Enregistrement AAAA origin' class DelExtensionForm(Form): diff --git a/machines/migrations/0062_extension_origin_v6.py b/machines/migrations/0062_extension_origin_v6.py new file mode 100644 index 00000000..1c3d869a --- /dev/null +++ b/machines/migrations/0062_extension_origin_v6.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.7 on 2017-10-18 14:08 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('machines', '0061_auto_20171015_2033'), + ] + + operations = [ + migrations.AddField( + model_name='extension', + name='origin_v6', + field=models.GenericIPAddressField(blank=True, null=True, protocol='IPv6'), + ), + ] diff --git a/machines/models.py b/machines/models.py index c1d8ca80..a782b7a9 100644 --- a/machines/models.py +++ b/machines/models.py @@ -247,11 +247,23 @@ class Extension(models.Model): blank=True, null=True ) + origin_v6 = models.GenericIPAddressField( + protocol='IPv6', + null=True, + blank=True + ) @cached_property def dns_entry(self): - """ Une entrée DNS A""" - return "@ IN A " + str(self.origin) + """ Une entrée DNS A et AAAA sur origin (zone self)""" + entry = "" + if self.origin: + entry += "@ IN A " + str(self.origin) + if self.origin_v6: + if entry: + entry += "\n" + entry += "@ IN AAAA " + str(self.origin_v6) + return entry def __str__(self): return self.name diff --git a/machines/serializers.py b/machines/serializers.py index 6e0ca4e3..7d222ef0 100644 --- a/machines/serializers.py +++ b/machines/serializers.py @@ -161,7 +161,7 @@ class ExtensionSerializer(serializers.ModelSerializer): class Meta: model = Extension - fields = ('name', 'origin', 'zone_entry') + fields = ('name', 'origin', 'origin_v6', 'zone_entry') def get_origin_ip(self, obj): return obj.origin.ipv4 diff --git a/machines/templates/machines/aff_extension.html b/machines/templates/machines/aff_extension.html index 18fd7c4b..069f545a 100644 --- a/machines/templates/machines/aff_extension.html +++ b/machines/templates/machines/aff_extension.html @@ -28,7 +28,8 @@ with this program; if not, write to the Free Software Foundation, Inc., Extension Autorisation infra pour utiliser l'extension Enregistrement A origin - + Enregistrement AAAA origin + {% for extension in extension_list %} @@ -36,6 +37,7 @@ with this program; if not, write to the Free Software Foundation, Inc., {{ extension.name }} {{ extension.need_infra }} {{ extension.origin }} + {{ extension.origin_v6 }} {% if is_infra %} {% include 'buttons/edit.html' with href='machines:edit-extension' id=extension.id %}