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.")
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())
def form_valid(self, form): rules_deployment = RulesDeployment() context = rules_deployment.send_rules(Switch.objects.all()) return render(self.request, "rules_success.html", context=context)