Added INACTIVE in excluded from expiration
[flowspy] / flowspec / tasks.py
index 70b4b01..412d5e4 100644 (file)
@@ -6,12 +6,13 @@ import json
 from celery.task.http import *
 from flowspy.utils import beanstalkc
 from django.conf import settings
+import datetime
 
 import os
 
-cwd = os.getcwd()
 
-LOG_FILENAME = os.path.join(cwd, 'log/celery_jobs.log')
+
+LOG_FILENAME = os.path.join(settings.LOG_FILE_LOCATION, 'celery_jobs.log')
 
 #FORMAT = '%(asctime)s %(levelname)s: %(message)s'
 #logging.basicConfig(format=FORMAT)
@@ -67,7 +68,7 @@ def delete(route, **kwargs):
     route.status = status
     route.response = response
     route.save()
-    subtask(announce).delay("[%s] Rule removal: %s%s- Result %s" %(route.applier, route.name, reason_text, response), route.applier)
+    subtask(announce).delay("[%s] Suspending rule : %s%s- Result %s" %(route.applier, route.name, reason_text, response), route.applier)
 
 # May not work in the first place... proxy is not aware of Route models
 @task
@@ -92,6 +93,7 @@ def batch_delete(routes, **kwargs):
         for route in routes:
             route.status = status
             route.response = response
+            route.expires = datetime.date.today()
             route.save()
             subtask(announce).delay("[%s] Rule removal: %s%s- Result %s" %(route.applier, route.name, reason_text, response), route.applier)
     else:
@@ -121,11 +123,11 @@ def check_sync(route_name=None, selected_routes = []):
         if route.has_expired() and (route.status != 'EXPIRED' and route.status != 'ADMININACTIVE' and route.status != 'INACTIVE'):
             logger.info('Expiring route %s' %route.name)
             subtask(delete).delay(route, reason="EXPIRED")
-        elif route.has_expired() and (route.status == 'ADMININACTIVE' or route.status == 'INACTIVE'):
-            route.status = 'EXPIRED'
-            route.response = 'Rule Expired'
-            logger.info('Expiring route %s' %route.name)
-            route.save()
+#        elif route.has_expired() and (route.status == 'ADMININACTIVE' or route.status == 'INACTIVE'):
+#            route.status = 'EXPIRED'
+#            route.response = 'Rule Expired'
+#            logger.info('Expiring route %s' %route.name)
+#            route.save()
         else:
             if route.status != 'EXPIRED':
                 route.check_sync()