Fixed issue with admininactive syncing. Fixed issue with admin batch delete
authorLeonidas Poulopoulos <leopoul@noc.grnet.gr>
Wed, 7 Dec 2011 11:07:22 +0000 (13:07 +0200)
committerLeonidas Poulopoulos <leopoul@noc.grnet.gr>
Wed, 7 Dec 2011 11:07:22 +0000 (13:07 +0200)
flowspec/admin.py
flowspec/models.py
flowspec/tasks.py

index 8743f1f..37a638c 100644 (file)
@@ -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"
index f0c21bf..e1006c1 100644 (file)
@@ -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):
index 199c4f3..f548c7e 100644 (file)
@@ -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)