From 9b925f389cd3c1e80796bd800dd1c7196218f0ed Mon Sep 17 00:00:00 2001 From: Hugo LEVY-FALK Date: Tue, 3 Oct 2017 18:27:06 +0200 Subject: [PATCH] =?UTF-8?q?Politique=20d'ouverture=20des=20ports=20par=20d?= =?UTF-8?q?=C3=A9faut=20associ=C3=A9e=20=C3=A0=20un=20range=20d'IP.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- machines/forms.py | 4 ++-- .../migrations/0060_iptype_ouverture_ports.py | 21 +++++++++++++++++++ machines/models.py | 1 + machines/serializers.py | 5 +++-- 4 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 machines/migrations/0060_iptype_ouverture_ports.py diff --git a/machines/forms.py b/machines/forms.py index 18631651..7922654a 100644 --- a/machines/forms.py +++ b/machines/forms.py @@ -145,7 +145,7 @@ class DelMachineTypeForm(Form): class IpTypeForm(ModelForm): class Meta: model = IpType - fields = ['type','extension','need_infra','domaine_ip_start','domaine_ip_stop', 'prefix_v6', 'vlan'] + fields = ['type','extension','need_infra','domaine_ip_start','domaine_ip_stop', 'prefix_v6', 'vlan', 'ouverture_ports'] def __init__(self, *args, **kwargs): @@ -154,7 +154,7 @@ class IpTypeForm(ModelForm): class EditIpTypeForm(IpTypeForm): class Meta(IpTypeForm.Meta): - fields = ['extension','type','need_infra', 'prefix_v6', 'vlan'] + fields = ['extension','type','need_infra', 'prefix_v6', 'vlan', 'ouverture_ports'] class DelIpTypeForm(Form): iptypes = forms.ModelMultipleChoiceField(queryset=IpType.objects.all(), label="Types d'ip actuelles", widget=forms.CheckboxSelectMultiple) diff --git a/machines/migrations/0060_iptype_ouverture_ports.py b/machines/migrations/0060_iptype_ouverture_ports.py new file mode 100644 index 00000000..e35f398f --- /dev/null +++ b/machines/migrations/0060_iptype_ouverture_ports.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.7 on 2017-10-03 16:08 +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('machines', '0059_iptype_prefix_v6'), + ] + + operations = [ + migrations.AddField( + model_name='iptype', + name='ouverture_ports', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='machines.OuverturePortList'), + ), + ] diff --git a/machines/models.py b/machines/models.py index 8e7b1c3c..5d08038e 100644 --- a/machines/models.py +++ b/machines/models.py @@ -72,6 +72,7 @@ class IpType(models.Model): domaine_ip_stop = models.GenericIPAddressField(protocol='IPv4') prefix_v6 = models.GenericIPAddressField(protocol='IPv6', null=True, blank=True) vlan = models.ForeignKey('Vlan', on_delete=models.PROTECT, blank=True, null=True) + ouverture_ports = models.ForeignKey('OuverturePortList', blank=True, null=True) @cached_property def ip_range(self): diff --git a/machines/serializers.py b/machines/serializers.py index 51daa4b5..6561bba9 100644 --- a/machines/serializers.py +++ b/machines/serializers.py @@ -80,10 +80,10 @@ class ExtensionNameField(serializers.RelatedField): class TypeSerializer(serializers.ModelSerializer): extension = ExtensionNameField(read_only=True) - + class Meta: model = IpType - fields = ('type', 'extension', 'domaine_ip_start', 'domaine_ip_stop') + fields = ('type', 'extension', 'domaine_ip_start', 'domaine_ip_stop', 'ouverture_ports') class ExtensionSerializer(serializers.ModelSerializer): origin = serializers.SerializerMethodField('get_origin_ip') @@ -184,3 +184,4 @@ class ServiceServersSerializer(serializers.ModelSerializer): def get_regen_status(self, obj): return obj.need_regen() +