Ejemplo n.º 1
0
 def get_context_data(self, **kwargs):
     context = super(GenerateAllSwitchView, self).get_context_data()
     switches = Switch.objects.all()
     manager = Manager()
     manager.create_rules(switches)
     rules = Regles.objects.values('regle')
     context["rules"] = rules
     return context
Ejemplo n.º 2
0
def generate_openflow_rules(modeladmin, request, queryset):
    """
    Action for generating openflow rules on switch.
    :param modeladmin:
    :param request:
    :param queryset:
    :return:
    """
    manager = Manager()
    manager.create_rules(queryset)
    modeladmin.message_user(request, "Les règles ont été mises à jour dans la base de données.")
    return redirect('rules_confirm')
Ejemplo n.º 3
0
 def Deploy(self):
     """
     Transition method for deploy a router in the topology, pushing all the rules necessary.
     :return:
     """
     if self.valid is True:
         manager = Manager()
         manager.create_rules(Switch.objects.all())
         deployment = RulesDeployment()
         deployment.send_rules(Switch.objects.all())
     else:
         raise Exception("Not a valid router.")
Ejemplo n.º 4
0
 def Prepare(self):
     """
     Transition method for moving the rules of the previous configuration into a special state,
     and applies rules for the new configuration.
     :return:
     """
     regles = Regles.objects.filter(Q(source=self) | Q(destination=self))
     for regle in regles:
         regle.ChangeRulesStatus()
         regle.save()
     manager = Manager()
     manager.create_rules(Switch.objects.all())
     deployment = RulesDeployment()
     deployment.send_rules(Switch.objects.all())
Ejemplo n.º 5
0
 def form_valid(self, form):
     switches = form.get_selected()
     manager = Manager()
     manager.create_rules(switches)
     rules = Regles.objects.values('regle')
     return render(self.request, "switches_list.html", context={"rules": rules})