mirror of https://gitlab.federez.net/re2o/re2o
Browse Source
Switch conf json See merge request federez/re2o!180 (cherry picked from commitcherry-pick-a02e03aca02e03ac71)7ab0d656add model PortProfileadc5757fMerge branch 'switch_conf_json' of https://gitlab.federez.net/federez/re2o into switch_conf_json983b5620Refactor port_profile7b49bd5Pas de null sur manytomany92f30fbeAjout reglages sécurité + frontendd123ce92Menu séparé pour les profils de ports447919a2Ajout et transfert des anciennes données vers le nouveau système de profil de portse6b8c5c8Finition, gestion du renvoie du profil par défaut du portb2d45d00Adapte freeradius pour le nouveau système de profil de ports51793bdeBoolean direct pour désactiver un port + logo2e092b3fFix langue et 802.X radius + diversa07e0d92Petit bug affichage vlanseefa0b4aPEP8 mon amour + typosfeddc3f6Conflicts fix switch_conf_json
19 changed files with 889 additions and 133 deletions
@ -0,0 +1,44 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Generated by Django 1.10.7 on 2018-06-26 16:37 |
|||
from __future__ import unicode_literals |
|||
|
|||
from django.db import migrations, models |
|||
import django.db.models.deletion |
|||
import re2o.mixins |
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('machines', '0082_auto_20180525_2209'), |
|||
('topologie', '0060_server'), |
|||
] |
|||
|
|||
operations = [ |
|||
migrations.CreateModel( |
|||
name='PortProfile', |
|||
fields=[ |
|||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), |
|||
('name', models.CharField(max_length=255, verbose_name='Name')), |
|||
('profil_default', models.CharField(blank=True, choices=[('room', 'room'), ('nothing', 'nothing'), ('accespoint', 'accesspoint'), ('uplink', 'uplink'), ('asso_machine', 'asso_machine')], max_length=32, null=True, unique=True, verbose_name='profil default')), |
|||
('radius_type', models.CharField(choices=[('NO', 'NO'), ('802.1X', '802.1X'), ('MAC-radius', 'MAC-radius')], max_length=32, verbose_name='RADIUS type')), |
|||
('radius_mode', models.CharField(choices=[('STRICT', 'STRICT'), ('COMMON', 'COMMON')], default='COMMON', max_length=32, verbose_name='RADIUS mode')), |
|||
('speed', models.CharField(choices=[('10-half', '10-half'), ('100-half', '100-half'), ('10-full', '10-full'), ('100-full', '100-full'), ('1000-full', '1000-full'), ('auto', 'auto'), ('auto-10', 'auto-10'), ('auto-100', 'auto-100')], default='auto', help_text='Mode de transmission et vitesse du port', max_length=32, verbose_name='Speed')), |
|||
('mac_limit', models.IntegerField(blank=True, help_text='Limit du nombre de mac sur le port', null=True, verbose_name='Mac limit')), |
|||
('flow_control', models.BooleanField(default=False, help_text='Gestion des débits', verbose_name='Flow control')), |
|||
('dhcp_snooping', models.BooleanField(default=False, help_text='Protection dhcp pirate', verbose_name='Dhcp snooping')), |
|||
('dhcpv6_snooping', models.BooleanField(default=False, help_text='Protection dhcpv6 pirate', verbose_name='Dhcpv6 snooping')), |
|||
('arp_protect', models.BooleanField(default=False, help_text="Verification assignation de l'IP par dhcp", verbose_name='Arp protect')), |
|||
('ra_guard', models.BooleanField(default=False, help_text='Protection contre ra pirate', verbose_name='Ra guard')), |
|||
('loop_protect', models.BooleanField(default=False, help_text='Protection contre les boucles', verbose_name='Loop Protect')), |
|||
('vlan_tagged', models.ManyToManyField(blank=True, related_name='vlan_tagged', to='machines.Vlan', verbose_name='VLAN(s) tagged')), |
|||
('vlan_untagged', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='vlan_untagged', to='machines.Vlan', verbose_name='VLAN untagged')), |
|||
], |
|||
options={ |
|||
'verbose_name': 'Port profile', |
|||
'permissions': (('view_port_profile', 'Can view a port profile object'),), |
|||
'verbose_name_plural': 'Port profiles', |
|||
}, |
|||
bases=(re2o.mixins.AclMixin, re2o.mixins.RevMixin, models.Model), |
|||
), |
|||
] |
|||
@ -0,0 +1,25 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Generated by Django 1.10.7 on 2018-06-26 23:23 |
|||
from __future__ import unicode_literals |
|||
|
|||
from django.db import migrations, models |
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('topologie', '0061_portprofile'), |
|||
] |
|||
|
|||
operations = [ |
|||
migrations.AlterField( |
|||
model_name='portprofile', |
|||
name='radius_mode', |
|||
field=models.CharField(choices=[('STRICT', 'STRICT'), ('COMMON', 'COMMON')], default='COMMON', help_text="En cas d'auth par mac, auth common ou strcit sur le port", max_length=32, verbose_name='RADIUS mode'), |
|||
), |
|||
migrations.AlterField( |
|||
model_name='portprofile', |
|||
name='radius_type', |
|||
field=models.CharField(choices=[('NO', 'NO'), ('802.1X', '802.1X'), ('MAC-radius', 'MAC-radius')], help_text="Choix du type d'authentification radius : non actif, mac ou 802.1X", max_length=32, verbose_name='RADIUS type'), |
|||
), |
|||
] |
|||
@ -0,0 +1,21 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Generated by Django 1.10.7 on 2018-06-28 07:49 |
|||
from __future__ import unicode_literals |
|||
|
|||
from django.db import migrations, models |
|||
import django.db.models.deletion |
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('topologie', '0062_auto_20180627_0123'), |
|||
] |
|||
|
|||
operations = [ |
|||
migrations.AddField( |
|||
model_name='port', |
|||
name='custom_profil', |
|||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to='topologie.PortProfile'), |
|||
), |
|||
] |
|||
@ -0,0 +1,53 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Generated by Django 1.10.7 on 2017-12-31 19:53 |
|||
from __future__ import unicode_literals |
|||
|
|||
from django.db import migrations |
|||
|
|||
|
|||
def transfer_profil(apps, schema_editor): |
|||
db_alias = schema_editor.connection.alias |
|||
port = apps.get_model("topologie", "Port") |
|||
profil = apps.get_model("topologie", "PortProfile") |
|||
vlan = apps.get_model("machines", "Vlan") |
|||
port_list = port.objects.using(db_alias).all() |
|||
profil_nothing = profil.objects.using(db_alias).create(name='nothing', profil_default='nothing', radius_type='NO') |
|||
profil_uplink = profil.objects.using(db_alias).create(name='uplink', profil_default='uplink', radius_type='NO') |
|||
profil_machine = profil.objects.using(db_alias).create(name='asso_machine', profil_default='asso_machine', radius_type='NO') |
|||
profil_room = profil.objects.using(db_alias).create(name='room', profil_default='room', radius_type='NO') |
|||
profil_borne = profil.objects.using(db_alias).create(name='accesspoint', profil_default='accesspoint', radius_type='NO') |
|||
for vlan_instance in vlan.objects.using(db_alias).all(): |
|||
if port.objects.using(db_alias).filter(vlan_force=vlan_instance): |
|||
custom_profil = profil.objects.using(db_alias).create(name='vlan-force-' + str(vlan_instance.vlan_id), radius_type='NO', vlan_untagged=vlan_instance) |
|||
port.objects.using(db_alias).filter(vlan_force=vlan_instance).update(custom_profil=custom_profil) |
|||
if port.objects.using(db_alias).filter(room__isnull=False).filter(radius='STRICT').count() > port.objects.using(db_alias).filter(room__isnull=False).filter(radius='NO').count() and port.objects.using(db_alias).filter(room__isnull=False).filter(radius='STRICT').count() > port.objects.using(db_alias).filter(room__isnull=False).filter(radius='COMMON').count(): |
|||
profil_room.radius_type = 'MAC-radius' |
|||
profil_room.radius_mode = 'STRICT' |
|||
common_profil = profil.objects.using(db_alias).create(name='mac-radius-common', radius_type='MAC-radius', radius_mode='COMMON') |
|||
no_rad_profil = profil.objects.using(db_alias).create(name='no-radius', radius_type='NO') |
|||
port.objects.using(db_alias).filter(room__isnull=False).filter(radius='COMMON').update(custom_profil=common_profil) |
|||
port.objects.using(db_alias).filter(room__isnull=False).filter(radius='NO').update(custom_profil=no_rad_profil) |
|||
elif port.objects.using(db_alias).filter(room__isnull=False).filter(radius='COMMON').count() > port.objects.using(db_alias).filter(room__isnull=False).filter(radius='NO').count() and port.objects.using(db_alias).filter(room__isnull=False).filter(radius='COMMON').count() > port.objects.using(db_alias).filter(room__isnull=False).filter(radius='STRICT').count(): |
|||
profil_room.radius_type = 'MAC-radius' |
|||
profil_room.radius_mode = 'COMMON' |
|||
strict_profil = profil.objects.using(db_alias).create(name='mac-radius-strict', radius_type='MAC-radius', radius_mode='STRICT') |
|||
no_rad_profil = profil.objects.using(db_alias).create(name='no-radius', radius_type='NO') |
|||
port.objects.using(db_alias).filter(room__isnull=False).filter(radius='STRICT').update(custom_profil=strict_profil) |
|||
port.objects.using(db_alias).filter(room__isnull=False).filter(radius='NO').update(custom_profil=no_rad_profil) |
|||
else: |
|||
strict_profil = profil.objects.using(db_alias).create(name='mac-radius-strict', radius_type='MAC-radius', radius_mode='STRICT') |
|||
common_profil = profil.objects.using(db_alias).create(name='mac-radius-common', radius_type='MAC-radius', radius_mode='COMMON') |
|||
port.objects.using(db_alias).filter(room__isnull=False).filter(radius='STRICT').update(custom_profil=strict_profil) |
|||
port.objects.using(db_alias).filter(room__isnull=False).filter(radius='NO').update(custom_profil=common_profil) |
|||
profil_room.save() |
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('topologie', '0063_port_custom_profil'), |
|||
] |
|||
|
|||
operations = [ |
|||
migrations.RunPython(transfer_profil), |
|||
] |
|||
@ -0,0 +1,23 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Generated by Django 1.10.7 on 2018-06-30 15:03 |
|||
from __future__ import unicode_literals |
|||
|
|||
from django.db import migrations |
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('topologie', '0064_createprofil'), |
|||
] |
|||
|
|||
operations = [ |
|||
migrations.RemoveField( |
|||
model_name='port', |
|||
name='radius', |
|||
), |
|||
migrations.RemoveField( |
|||
model_name='port', |
|||
name='vlan_force', |
|||
), |
|||
] |
|||
@ -0,0 +1,25 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Generated by Django 1.10.7 on 2018-06-30 16:55 |
|||
from __future__ import unicode_literals |
|||
|
|||
from django.db import migrations, models |
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('topologie', '0065_auto_20180630_1703'), |
|||
] |
|||
|
|||
operations = [ |
|||
migrations.AddField( |
|||
model_name='port', |
|||
name='state', |
|||
field=models.BooleanField(default=True, help_text='Etat du port Actif', verbose_name='Etat du port Actif'), |
|||
), |
|||
migrations.AlterField( |
|||
model_name='portprofile', |
|||
name='profil_default', |
|||
field=models.CharField(blank=True, choices=[('room', 'room'), ('accespoint', 'accesspoint'), ('uplink', 'uplink'), ('asso_machine', 'asso_machine'), ('nothing', 'nothing')], max_length=32, null=True, unique=True, verbose_name='profil default'), |
|||
), |
|||
] |
|||
@ -0,0 +1,75 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Generated by Django 1.10.7 on 2018-06-30 22:16 |
|||
from __future__ import unicode_literals |
|||
|
|||
from django.db import migrations, models |
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('topologie', '0066_auto_20180630_1855'), |
|||
] |
|||
|
|||
operations = [ |
|||
migrations.RenameField( |
|||
model_name='port', |
|||
old_name='custom_profil', |
|||
new_name='custom_profile', |
|||
), |
|||
migrations.AlterField( |
|||
model_name='port', |
|||
name='state', |
|||
field=models.BooleanField(default=True, help_text='Port state Active', verbose_name='Port State Active'), |
|||
), |
|||
migrations.AlterField( |
|||
model_name='portprofile', |
|||
name='arp_protect', |
|||
field=models.BooleanField(default=False, help_text='Check if ip is dhcp assigned', verbose_name='Arp protect'), |
|||
), |
|||
migrations.AlterField( |
|||
model_name='portprofile', |
|||
name='dhcp_snooping', |
|||
field=models.BooleanField(default=False, help_text='Protect against rogue dhcp', verbose_name='Dhcp snooping'), |
|||
), |
|||
migrations.AlterField( |
|||
model_name='portprofile', |
|||
name='dhcpv6_snooping', |
|||
field=models.BooleanField(default=False, help_text='Protect against rogue dhcpv6', verbose_name='Dhcpv6 snooping'), |
|||
), |
|||
migrations.AlterField( |
|||
model_name='portprofile', |
|||
name='flow_control', |
|||
field=models.BooleanField(default=False, help_text='Flow control', verbose_name='Flow control'), |
|||
), |
|||
migrations.AlterField( |
|||
model_name='portprofile', |
|||
name='loop_protect', |
|||
field=models.BooleanField(default=False, help_text='Protect again loop', verbose_name='Loop Protect'), |
|||
), |
|||
migrations.AlterField( |
|||
model_name='portprofile', |
|||
name='mac_limit', |
|||
field=models.IntegerField(blank=True, help_text='Limit of mac-address on this port', null=True, verbose_name='Mac limit'), |
|||
), |
|||
migrations.AlterField( |
|||
model_name='portprofile', |
|||
name='ra_guard', |
|||
field=models.BooleanField(default=False, help_text='Protect against rogue ra', verbose_name='Ra guard'), |
|||
), |
|||
migrations.AlterField( |
|||
model_name='portprofile', |
|||
name='radius_mode', |
|||
field=models.CharField(choices=[('STRICT', 'STRICT'), ('COMMON', 'COMMON')], default='COMMON', help_text='In case of mac-auth : mode common or strict on this port', max_length=32, verbose_name='RADIUS mode'), |
|||
), |
|||
migrations.AlterField( |
|||
model_name='portprofile', |
|||
name='radius_type', |
|||
field=models.CharField(choices=[('NO', 'NO'), ('802.1X', '802.1X'), ('MAC-radius', 'MAC-radius')], help_text='Type of radius auth : inactive, mac-address or 802.1X', max_length=32, verbose_name='RADIUS type'), |
|||
), |
|||
migrations.AlterField( |
|||
model_name='portprofile', |
|||
name='speed', |
|||
field=models.CharField(choices=[('10-half', '10-half'), ('100-half', '100-half'), ('10-full', '10-full'), ('100-full', '100-full'), ('1000-full', '1000-full'), ('auto', 'auto'), ('auto-10', 'auto-10'), ('auto-100', 'auto-100')], default='auto', help_text='Port speed limit', max_length=32, verbose_name='Speed'), |
|||
), |
|||
] |
|||
@ -0,0 +1,85 @@ |
|||
{% comment %} |
|||
Re2o est un logiciel d'administration développé initiallement au rezometz. Il |
|||
se veut agnostique au réseau considéré, de manière à être installable en |
|||
quelques clics. |
|||
|
|||
Copyright © 2018 Gabriel Détraz |
|||
|
|||
This program is free software; you can redistribute it and/or modify |
|||
it under the terms of the GNU General Public License as published by |
|||
the Free Software Foundation; either version 2 of the License, or |
|||
(at your option) any later version. |
|||
|
|||
This program is distributed in the hope that it will be useful, |
|||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
GNU General Public License for more details. |
|||
|
|||
You should have received a copy of the GNU General Public License along |
|||
with this program; if not, write to the Free Software Foundation, Inc., |
|||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
|||
{% endcomment %} |
|||
|
|||
{% load acl %} |
|||
{% load i18n %} |
|||
|
|||
<div class="table-responsive"> |
|||
|
|||
{% if port_profile_list.paginator %} |
|||
{% include "pagination.html" with list=port_profile_list %} |
|||
{% endif %} |
|||
|
|||
|
|||
<table class="table table-striped"> |
|||
<thead> |
|||
<tr> |
|||
<th>{% trans "Name" %}</th> |
|||
<th>{% trans "Default for" %}</th> |
|||
<th>{% trans "VLANs" %}</th> |
|||
<th>{% trans "RADIUS settings" %}</th> |
|||
<th>{% trans "Speed" %}</th> |
|||
<th>{% trans "Mac address limit" %}</th> |
|||
<th>{% trans "Security" %}</th> |
|||
<th></th> |
|||
</tr> |
|||
</thead> |
|||
{% for port_profile in port_profile_list %} |
|||
<tr> |
|||
<td>{{port_profile.name}}</td> |
|||
<td>{{port_profile.profil_default}}</td> |
|||
<td> |
|||
{% if port_profile.vlan_untagged %} |
|||
<b>Untagged : </b>{{port_profile.vlan_untagged}} |
|||
<br> |
|||
{% endif %} |
|||
{% if port_profile.vlan_tagged.all %} |
|||
<b>Tagged : </b>{{port_profile.vlan_tagged.all|join:", "}} |
|||
{% endif %} |
|||
</td> |
|||
<td> |
|||
<b>Type : </b>{{port_profile.radius_type}} |
|||
{% if port_profile.radius_type == "MAC-radius" %} |
|||
<br> |
|||
<b>Mode : </b>{{port_profile.radius_mode}}</td> |
|||
{% endif %} |
|||
<td>{{port_profile.speed}}</td> |
|||
<td>{{port_profile.mac_limit}}</td> |
|||
<td>{{port_profile.security_parameters_enabled|join:"<br>"}}</td> |
|||
<td class="text-right"> |
|||
{% include 'buttons/history.html' with href='topologie:history' name='portprofile' id=port_profile.pk %} |
|||
{% can_edit port_profile %} |
|||
{% include 'buttons/edit.html' with href='topologie:edit-port-profile' id=port_profile.pk %} |
|||
{% acl_end %} |
|||
{% can_delete port_profile %} |
|||
{% include 'buttons/suppr.html' with href='topologie:del-port-profile' id=port_profile.pk %} |
|||
{% acl_end %} |
|||
</td> |
|||
</tr> |
|||
{% endfor %} |
|||
</table> |
|||
|
|||
{% if port_profile_list.paginator %} |
|||
{% include "pagination.html" with list=port_profile_list %} |
|||
{% endif %} |
|||
|
|||
</div> |
|||
@ -0,0 +1,43 @@ |
|||
{% extends "topologie/sidebar.html" %} |
|||
{% comment %} |
|||
Re2o est un logiciel d'administration développé initiallement au rezometz. Il |
|||
se veut agnostique au réseau considéré, de manière à être installable en |
|||
quelques clics. |
|||
|
|||
Copyright © 2018 Gabriel Détraz |
|||
|
|||
|
|||
This program is free software; you can redistribute it and/or modify |
|||
it under the terms of the GNU General Public License as published by |
|||
the Free Software Foundation; either version 2 of the License, or |
|||
(at your option) any later version. |
|||
|
|||
This program is distributed in the hope that it will be useful, |
|||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
GNU General Public License for more details. |
|||
|
|||
You should have received a copy of the GNU General Public License along |
|||
with this program; if not, write to the Free Software Foundation, Inc., |
|||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
|||
{% endcomment %} |
|||
|
|||
{% load bootstrap3 %} |
|||
{% load acl %} |
|||
{% load i18n %} |
|||
|
|||
{% block title %}Switchs{% endblock %} |
|||
|
|||
{% block content %} |
|||
|
|||
<h2>{% trans "Port profiles" %}</h2> |
|||
{% can_create PortProfile %} |
|||
<a class="btn btn-primary btn-sm" role="button" href="{% url 'topologie:new-port-profile' %}"><i class="fa fa-plus"></i>{% trans " Add a port profile" %}</a> |
|||
<hr> |
|||
{% acl_end %} |
|||
{% include "topologie/aff_port_profile.html" with port_profile_list=port_profile_list %} |
|||
<br /> |
|||
<br /> |
|||
<br /> |
|||
|
|||
{% endblock %} |
|||
Loading…
Reference in new issue