From: Leonidas Poulopoulos Date: Wed, 7 Dec 2011 11:07:22 +0000 (+0200) Subject: Fixed issue with admininactive syncing. Fixed issue with admin batch delete X-Git-Tag: v0.5~41 X-Git-Url: https://code.grnet.gr/git/flowspy/commitdiff_plain/e173e7c23e0de69dda10ade00821bec3cb416c2b Fixed issue with admininactive syncing. Fixed issue with admin batch delete --- diff --git a/flowspec/admin.py b/flowspec/admin.py index 8743f1f..37a638c 100644 --- a/flowspec/admin.py +++ b/flowspec/admin.py @@ -7,14 +7,12 @@ from django.contrib.auth.models import User from django.contrib.auth.admin import UserAdmin from accounts.models import UserProfile - class RouteAdmin(admin.ModelAdmin): actions = ['deactivate'] def deactivate(self, request, queryset): queryset = queryset.filter(status='ACTIVE') - rows = queryset.update(status='PENDING') response = batch_delete.delay(queryset, reason="ADMININACTIVE") self.message_user(request, "Added request %s to job que. Check in a while for result" % response) deactivate.short_description = "Remove selected routes from network" diff --git a/flowspec/models.py b/flowspec/models.py index f0c21bf..e1006c1 100644 --- a/flowspec/models.py +++ b/flowspec/models.py @@ -249,12 +249,12 @@ class Route(models.Model): except: pass if found and self.status != "ACTIVE": - logger.error('Rule is applied on device but appears as offline') - self.status = "ACTIVE" - self.save() - found = True - if not found and self.status == "ADMININACTIVE": - found = True + logger.error('Rule is applied on device but appears as offline') + self.status = "ACTIVE" + self.save() + found = True + if self.status == "ADMININACTIVE": + found = True return found def get_then(self): diff --git a/flowspec/tasks.py b/flowspec/tasks.py index 199c4f3..f548c7e 100644 --- a/flowspec/tasks.py +++ b/flowspec/tasks.py @@ -61,6 +61,8 @@ def delete(route, **kwargs): @task def batch_delete(routes, **kwargs): if routes: + for route in routes: + route.status='PENDING';route.save() applier = PR.Applier(route_objects=routes) conf = applier.delete_routes() commit, response = applier.apply(configuration = conf)