Exemple #1
0
def pre_delete_hote(sender, **kwargs):
    """
    Clean-up all traces of the router in the Database.
    :param sender:
    :param kwargs:
    :return:
    """
    # Retrieve all flux where the deleted host is present
    flux_list = Flux.objects.filter(Q(hote_src=kwargs['instance']) | Q(hote_dst=kwargs['instance']))
    # Remove stats from these flux
    Stats.objects.filter(idflux__in=flux_list).delete()
    # delete flux
    flux_list.delete()

    # remove rules for designated host
    deployment = RulesDeployment()
    deployment.remove_host([kwargs['instance']])

    # Remove host from the BGP configuration
    render_conf_hosts(Hote.objects.exclude(idhote=kwargs['instance'].idhote))
Exemple #2
0
def post_save_hote(sender, **kwargs):
    """
    Signal used for creating flux objects in the Database (for statistic purposes)
    :param sender:
    :param kwargs:
    :return:
    """
    if kwargs['created'] is True:
        db_flux = list()
        db_flux.append(Flux(hote_src=None, hote_dst=kwargs['instance'], type="ICMPv6"))
        db_flux.append(Flux(hote_src=None, hote_dst=kwargs['instance'], type="ARP"))
        for peer_dst in Hote.objects.all():
            if peer_dst != kwargs['instance']:
                db_flux.append(Flux(hote_src=peer_dst, hote_dst=kwargs['instance'], type="IPv4"))
                db_flux.append(Flux(hote_src=kwargs['instance'], hote_dst=peer_dst, type="IPv4"))
                db_flux.append(Flux(hote_src=peer_dst, hote_dst=kwargs['instance'], type="IPv6"))
                db_flux.append(Flux(hote_src=kwargs['instance'], hote_dst=peer_dst, type="IPv6"))
        Flux.objects.bulk_create(db_flux)

        # Deploy BGP configuration with the new host
        render_conf_hosts(Hote.objects.all())
Exemple #3
0
def generate_routeserver_conf(modeladmin, request, queryset):
    """
    Action for generating BIRD configuration files.
    :param modeladmin:
    :param request:
    :param queryset:
    :return:
    """
    # remove keyboard-chair errors
    if modeladmin.model is Membre:
        queryset = queryset.exclude(nommembre="TouIX")
        data = render_conf_members(request, queryset)
        return render(request, "members_list.html", context=data)
    elif modeladmin.model is Hote:
        queryset = queryset.exclude(idmembre__nommembre="TouIX")
        data = render_conf_hosts(request, queryset)
        return render(request, "members_list.html", context=data)