mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-22 19:33:11 +00:00
Bug fix pour interfaces mutliples + temps maximum génération forcée
This commit is contained in:
parent
014cd80960
commit
b1a0e64a7b
5 changed files with 40 additions and 7 deletions
|
@ -54,7 +54,7 @@ class DomainAdmin(VersionAdmin):
|
||||||
list_display = ('interface_parent', 'name', 'extension', 'cname')
|
list_display = ('interface_parent', 'name', 'extension', 'cname')
|
||||||
|
|
||||||
class ServiceAdmin(VersionAdmin):
|
class ServiceAdmin(VersionAdmin):
|
||||||
list_display = ('service_type', 'time_regen')
|
list_display = ('service_type', 'min_time_regen', 'regular_time_regen')
|
||||||
|
|
||||||
admin.site.register(Machine, MachineAdmin)
|
admin.site.register(Machine, MachineAdmin)
|
||||||
admin.site.register(MachineType, MachineTypeAdmin)
|
admin.site.register(MachineType, MachineTypeAdmin)
|
||||||
|
|
30
machines/migrations/0047_auto_20170809_0606.py
Normal file
30
machines/migrations/0047_auto_20170809_0606.py
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.10.7 on 2017-08-09 04:06
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
import datetime
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('machines', '0046_auto_20170808_1423'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='service',
|
||||||
|
name='time_regen',
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='service',
|
||||||
|
name='min_time_regen',
|
||||||
|
field=models.DurationField(default=datetime.timedelta(0, 60), help_text='Temps minimal avant nouvelle génération du service'),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='service',
|
||||||
|
name='regular_time_regen',
|
||||||
|
field=models.DurationField(default=datetime.timedelta(0, 3600), help_text='Temps maximal avant nouvelle génération du service'),
|
||||||
|
),
|
||||||
|
]
|
|
@ -275,7 +275,8 @@ class IpList(models.Model):
|
||||||
class Service(models.Model):
|
class Service(models.Model):
|
||||||
""" Definition d'un service (dhcp, dns, etc)"""
|
""" Definition d'un service (dhcp, dns, etc)"""
|
||||||
service_type = models.CharField(max_length=255, blank=True, unique=True)
|
service_type = models.CharField(max_length=255, blank=True, unique=True)
|
||||||
time_regen = models.DurationField(default=timedelta(minutes=1))
|
min_time_regen = models.DurationField(default=timedelta(minutes=1), help_text="Temps minimal avant nouvelle génération du service")
|
||||||
|
regular_time_regen = models.DurationField(default=timedelta(hours=1), help_text="Temps maximal avant nouvelle génération du service")
|
||||||
servers = models.ManyToManyField('Interface', through='Service_link')
|
servers = models.ManyToManyField('Interface', through='Service_link')
|
||||||
|
|
||||||
def ask_regen(self):
|
def ask_regen(self):
|
||||||
|
@ -320,7 +321,7 @@ class Service_link(models.Model):
|
||||||
|
|
||||||
def need_regen(self):
|
def need_regen(self):
|
||||||
""" Décide si le temps minimal écoulé est suffisant pour provoquer une régénération de service"""
|
""" Décide si le temps minimal écoulé est suffisant pour provoquer une régénération de service"""
|
||||||
if self.asked_regen and (self.last_regen + self.service.time_regen) < timezone.now():
|
if (self.asked_regen and (self.last_regen + self.service.min_time_regen) < timezone.now()) or (self.last_regen + self.service.regular_time_regen) < timezone.now():
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
|
@ -26,7 +26,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Nom du service</th>
|
<th>Nom du service</th>
|
||||||
<th>Temps minimum de régénération</th>
|
<th>Temps minimum avant nouvelle régénération</th>
|
||||||
|
<th>Temps avant nouvelle génération obligatoire (max)</th>
|
||||||
<th>Serveurs inclus</th>
|
<th>Serveurs inclus</th>
|
||||||
<th></th>
|
<th></th>
|
||||||
<th></th>
|
<th></th>
|
||||||
|
@ -35,7 +36,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
{% for service in service_list %}
|
{% for service in service_list %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ service.service_type }}</td>
|
<td>{{ service.service_type }}</td>
|
||||||
<td>{{ service.time_regen }}</td>
|
<td>{{ service.min_time_regen }}</td>
|
||||||
|
<td>{{ service.regular_time_regen }}</td>
|
||||||
<td>{% for serv in service.servers.all %}{{ serv }}, {% endfor %}</td>
|
<td>{% for serv in service.servers.all %}{{ serv }}, {% endfor %}</td>
|
||||||
<td class="text-right">
|
<td class="text-right">
|
||||||
{% if is_infra %}
|
{% if is_infra %}
|
||||||
|
|
|
@ -816,9 +816,9 @@ def service_servers(request):
|
||||||
@login_required
|
@login_required
|
||||||
@permission_required('serveur')
|
@permission_required('serveur')
|
||||||
def regen_achieved(request):
|
def regen_achieved(request):
|
||||||
obj = Service_link.objects.filter(service__in=Service.objects.filter(service_type=request.POST['service']), server__in=Interface.objects.filter(domain=Domain.objects.filter(name=request.POST['server'])))
|
obj = Service_link.objects.filter(service__in=Service.objects.filter(service_type=request.POST['service']), server__in=Interface.objects.filter(domain__in=Domain.objects.filter(name=request.POST['server'])))
|
||||||
if obj:
|
if obj:
|
||||||
obj[0].done_regen()
|
obj.first().done_regen()
|
||||||
return HttpReponse("Ok")
|
return HttpReponse("Ok")
|
||||||
|
|
||||||
@csrf_exempt
|
@csrf_exempt
|
||||||
|
|
Loading…
Reference in a new issue