From d2d6f7e5e44b6f524a3c83a73f6f5397b0737134 Mon Sep 17 00:00:00 2001 From: Gabriel Detraz Date: Sun, 8 Jul 2018 20:32:47 +0200 Subject: [PATCH] Gestion igmp et mld par vlan --- api/serializers.py | 3 ++- machines/forms.py | 13 +++++++++- .../migrations/0092_auto_20180708_2018.py | 25 +++++++++++++++++++ machines/models.py | 10 +++++++- .../templates/topologie/aff_vlanoptions.html | 4 +++ 5 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 machines/migrations/0092_auto_20180708_2018.py diff --git a/api/serializers.py b/api/serializers.py index 8d556771..52902265 100644 --- a/api/serializers.py +++ b/api/serializers.py @@ -153,7 +153,8 @@ class VlanSerializer(NamespacedHMSerializer): """ class Meta: model = machines.Vlan - fields = ('vlan_id', 'name', 'comment', 'arp_protect', 'dhcp_snooping', 'dhcpv6_snooping', 'api_url') + fields = ('vlan_id', 'name', 'comment', 'arp_protect', 'dhcp_snooping', + 'dhcpv6_snooping', 'igmp', 'mld', 'api_url') class NasSerializer(NamespacedHMSerializer): diff --git a/machines/forms.py b/machines/forms.py index 4af060d3..e9c75d59 100644 --- a/machines/forms.py +++ b/machines/forms.py @@ -576,13 +576,24 @@ class VlanForm(FormRevMixin, ModelForm): """Ajout d'un vlan : id, nom""" class Meta: model = Vlan - fields = '__all__' + fields = ['vlan_id', 'name', 'comment'] def __init__(self, *args, **kwargs): prefix = kwargs.pop('prefix', self.Meta.model.__name__) super(VlanForm, self).__init__(*args, prefix=prefix, **kwargs) +class EditOptionVlanForm(FormRevMixin, ModelForm): + """Ajout d'un vlan : id, nom""" + class Meta: + model = Vlan + fields = ['dhcp_snooping', 'dhcpv6_snooping', 'arp_protect', 'igmp', 'mld'] + + def __init__(self, *args, **kwargs): + prefix = kwargs.pop('prefix', self.Meta.model.__name__) + super(EditOptionVlanForm, self).__init__(*args, prefix=prefix, **kwargs) + + class DelVlanForm(FormRevMixin, Form): """Suppression d'un ou plusieurs vlans""" vlan = forms.ModelMultipleChoiceField( diff --git a/machines/migrations/0092_auto_20180708_2018.py b/machines/migrations/0092_auto_20180708_2018.py new file mode 100644 index 00000000..b4f41c14 --- /dev/null +++ b/machines/migrations/0092_auto_20180708_2018.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.7 on 2018-07-08 18:18 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('machines', '0091_auto_20180707_2040'), + ] + + operations = [ + migrations.AddField( + model_name='vlan', + name='igmp', + field=models.BooleanField(default=False, help_text='Gestion multicast v4'), + ), + migrations.AddField( + model_name='vlan', + name='mld', + field=models.BooleanField(default=False, help_text='Gestion multicast v6'), + ), + ] diff --git a/machines/models.py b/machines/models.py index b59d48ae..3526108f 100644 --- a/machines/models.py +++ b/machines/models.py @@ -519,7 +519,15 @@ class Vlan(RevMixin, AclMixin, models.Model): arp_protect = models.BooleanField(default=False) dhcp_snooping = models.BooleanField(default=False) dhcpv6_snooping = models.BooleanField(default=False) - + igmp = models.BooleanField( + default=False, + help_text="Gestion multicast v4" + ) + mld = models.BooleanField( + default=False, + help_text="Gestion multicast v6" + ) + class Meta: permissions = ( ("view_vlan", _("Can view a VLAN object")), diff --git a/topologie/templates/topologie/aff_vlanoptions.html b/topologie/templates/topologie/aff_vlanoptions.html index d9e6f117..7684e951 100644 --- a/topologie/templates/topologie/aff_vlanoptions.html +++ b/topologie/templates/topologie/aff_vlanoptions.html @@ -33,6 +33,8 @@ with this program; if not, write to the Free Software Foundation, Inc., Arp Protect Dhcp Snooping Dhcpv6 Snooping + Igmp + Mld @@ -43,6 +45,8 @@ with this program; if not, write to the Free Software Foundation, Inc., {{ vlan.arp_protect }} {{ vlan.dhcp_snooping }} {{ vlan.dhcpv6_snooping }} + {{ vlan.igmp }} + {{ vlan.mld }} {% can_edit vlan %} {% include 'buttons/edit.html' with href='topologie:edit-vlanoptions' id=vlan.id %}