Example #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))