diff --git a/machines/migrations/0085_auto_20180623_1817.py b/machines/migrations/0085_auto_20180623_1817.py
new file mode 100644
index 00000000..0c3216c5
--- /dev/null
+++ b/machines/migrations/0085_auto_20180623_1817.py
@@ -0,0 +1,20 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.10.7 on 2018-06-23 16:17
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('machines', '0084_auto_20180623_1651'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='sshfpralgo',
+ name='name',
+ field=models.CharField(max_length=256),
+ ),
+ ]
diff --git a/machines/models.py b/machines/models.py
index 9e7c6772..5b564852 100644
--- a/machines/models.py
+++ b/machines/models.py
@@ -240,7 +240,7 @@ class SshFprAlgo(RevMixin, AclMixin, models.Model):
"""Un aglorithme de création de la fingerprint ssh"""
PRETTY_NAME = "Algo de clef ssh"
- name = models.TextField(max_length=256)
+ name = models.CharField(max_length=256)
class Meta:
permissions = (
diff --git a/machines/templates/machines/aff_sshfpralgo.html b/machines/templates/machines/aff_sshfpralgo.html
new file mode 100644
index 00000000..fe9e78c4
--- /dev/null
+++ b/machines/templates/machines/aff_sshfpralgo.html
@@ -0,0 +1,47 @@
+{% 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 %}
+
+
+
+
+ Nom de l'algo |
+ |
+
+
+ {% for sshfpralgo in sshfpralgo_list %}
+
+ {{ sshfpralgo.name }} |
+
+ {% can_edit sshfpralgo %}
+ {% include 'buttons/edit.html' with href='machines:edit-sshfpralgo' id=sshfpralgo.id %}
+ {% acl_end %}
+ {% can_delete sshfpralgo %}
+ {% include 'buttons/suppr.html' with href='machines:del-sshfpralgo' id=sshfpralgo.id %}
+ {% acl_end %}
+ {% include 'buttons/history.html' with href='machines:history' name='sshfpralgo' id=sshfpralgo.id %}
+ |
+
+ {% endfor %}
+
+
diff --git a/machines/templates/machines/index_sshfpralgo.html b/machines/templates/machines/index_sshfpralgo.html
new file mode 100644
index 00000000..90107d0a
--- /dev/null
+++ b/machines/templates/machines/index_sshfpralgo.html
@@ -0,0 +1,39 @@
+{% extends "machines/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 %}
+
+{% block title %}Machines{% endblock %}
+
+{% block content %}
+ Liste des algo fingerprint ssh
+ {% can_create SshFprAlgo %}
+ Ajouter un algo ssh
+ {% acl_end %}
+ {% include "machines/aff_sshfpralgo.html" with sshfpralgo_list=sshfpralgo_list %}
+
+
+
+{% endblock %}
+
diff --git a/machines/templates/machines/machine.html b/machines/templates/machines/machine.html
index af7ff3fb..35a1db8e 100644
--- a/machines/templates/machines/machine.html
+++ b/machines/templates/machines/machine.html
@@ -81,6 +81,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% if sshfingerprintform %}
{% bootstrap_form_errors sshfingerprintform %}
{% endif %}
+{% if sshfpralgoform %}
+ {% bootstrap_form_errors sshfpralgoform %}
+{% endif %}
+
@@ -162,6 +166,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
SshFingerprint
{% bootstrap_form sshfingerprintform %}
{% endif %}
+ {% if sshfpralgoform %}
+ Algorithme de fingerprint ssh
+ {% bootstrap_form sshfpralgoform %}
+ {% endif %}
{% bootstrap_button action_name button_type="submit" icon="star" %}
diff --git a/machines/templates/machines/sidebar.html b/machines/templates/machines/sidebar.html
index 68031f29..0394733a 100644
--- a/machines/templates/machines/sidebar.html
+++ b/machines/templates/machines/sidebar.html
@@ -44,6 +44,12 @@ with this program; if not, write to the Free Software Foundation, Inc.,
Extensions et zones
{% acl_end %}
+ {% can_view_all SshFprAlgo %}
+
+
+ Algo de fingerprint ssh
+
+ {% acl_end %}
{% can_view_all IpType %}
diff --git a/machines/urls.py b/machines/urls.py
index 905d4a45..a094f4b8 100644
--- a/machines/urls.py
+++ b/machines/urls.py
@@ -117,6 +117,18 @@ urlpatterns = [
url(r'^index_sshfingerprint/(?P[0-9]+)$',
views.index_sshfingerprint,
name='index-sshfingerprint'),
+ url(r'^new_sshfpralgo/$',
+ views.new_sshfpralgo,
+ name='new-sshfpralgo'),
+ url(r'^edit_sshfpralgo/(?P[0-9]+)$',
+ views.edit_sshfpralgo,
+ name='edit-sshfpralgo'),
+ url(r'^del_sshfpralgo/(?P[0-9]+)$',
+ views.del_sshfpralgo,
+ name='del-sshfpralgo'),
+ url(r'^index_sshfpralgo/$',
+ views.index_sshfpralgo,
+ name='index-sshfpralgo'),
url(r'^add_service/$', views.add_service, name='add-service'),
url(r'^edit_service/(?P[0-9]+)$',
views.edit_service,
diff --git a/machines/views.py b/machines/views.py
index 357b3149..223bcaff 100644
--- a/machines/views.py
+++ b/machines/views.py
@@ -478,7 +478,7 @@ def new_sshfingerprint(request, machine, **_kwargs):
messages.success(request, "Fingerprint ssh ajoutée")
return redirect(reverse(
'machines:index-sshfingerprint',
- kwargs={'machine': str(machine.id)}
+ kwargs={'machineid': str(machine.id)}
))
return form(
{'sshfingerprintform': sshfingerprint, 'action_name': 'Créer'},
@@ -498,7 +498,7 @@ def edit_sshfingerprint(request, sshfingerprint_instance, **_kwargs):
if sshfingerprint.is_valid():
if sshfingerprint.changed_data:
sshfingerprint.save()
- messages.success(request, "Ipv6 modifiée")
+ messages.success(request, "Ssh fingerprint modifiée")
return redirect(reverse(
'machines:index-sshfingerprint',
kwargs={'machineid': str(sshfingerprint_instance.machine.id)}
@@ -529,6 +529,72 @@ def del_sshfingerprint(request, sshfingerprint, **_kwargs):
)
+@login_required
+@can_create(SshFprAlgo)
+def new_sshfpralgo(request, **_kwargs):
+ """Nouvelle sshfpralgo"""
+ sshfpralgo = SshFprAlgoForm(
+ request.POST or None,
+ )
+ if sshfpralgo.is_valid():
+ sshfpralgo.save()
+ messages.success(request, "Algo Fingerprint ssh ajouté")
+ return redirect(reverse(
+ 'machines:index-sshfpralgo'
+ ))
+ return form(
+ {'sshfpralgoform': sshfpralgo, 'action_name': 'Créer'},
+ 'machines/machine.html',
+ request
+ )
+
+
+@login_required
+@can_edit(SshFprAlgo)
+def edit_sshfpralgo(request, sshfpralgo_instance, **_kwargs):
+ """Edition d'une sshfpralgo"""
+ sshfpralgo = SshFprAlgoForm(
+ request.POST or None,
+ instance=sshfpralgo_instance
+ )
+ if sshfpralgo.is_valid():
+ if sshfpralgo.changed_data:
+ sshfpralgo.save()
+ messages.success(request, "Algo de sshfp modifiée")
+ return redirect(reverse(
+ 'machines:index-sshfpralgo'
+ ))
+ return form(
+ {'sshfpralgoform': sshfpralgo, 'action_name': 'Editer'},
+ 'machines/machine.html',
+ request
+ )
+
+
+@login_required
+@can_delete(SshFprAlgo)
+def del_sshfpralgo(request, sshfpralgo, **_kwargs):
+ """ Supprime une sshfpralgo"""
+ if request.method == "POST":
+ try:
+ sshfpralgo.delete()
+ messages.success(request, "La sshfpralgo a été détruite")
+ except ProtectedError:
+ messages.error(
+ request,
+ ("L'algo est affectée à au moins une fingerprint ssh, "
+ "vous ne pouvez pas le supprimer")
+ )
+ return redirect(reverse(
+ 'machines:index-sshfpralgo'
+ ))
+ return form(
+ {'objet': sshfpralgo, 'objet_name': 'sshfpralgo'},
+ 'machines/delete.html',
+ request
+ )
+
+
@login_required
@can_create(IpType)
def add_iptype(request):