diff --git a/flowspec/models.py b/flowspec/models.py index 9181bd98cca090db49e633ae1534002b84b7d92b..a81a9655281727826bf953458404d90ed781985e 100644 --- a/flowspec/models.py +++ b/flowspec/models.py @@ -475,7 +475,7 @@ class Route(models.Model): self.update_status("OUTOFSYNC") def is_synced(self, netconf_device_queried=None): - logger.info('models::is_synced(): self='+str(self)) + logger.info('models::is_synced(): self='+str(self)+" status="+str(self.status)) found = False try: # allows for caching of NETCONF GetConfig query, e.g., during tasks::check_sync @@ -640,14 +640,17 @@ class Route(models.Model): logger.info('models::is_synced(): self='+str(self)+': icmp type fields do not match') except: pass + if found and self.status != "ACTIVE": logger.error('models::is_synced(): rule '+str(self)+' is applied on device but appears in DB as offline') #self.status = "ACTIVE" #self.save() self.update_status("ACTIVE") found = True - if self.status == "ADMININACTIVE" or self.status == "INACTIVE" or self.status == "INACTIVE_TODELETE" or self.status == "PENDING_TODELETE" or self.status == "EXPIRED": - found = True + + logger.info('models::is_synced(): self='+str(self)+ " status="+str(self.status)+" pre found="+str(found)) + if not found and (self.status == "ADMININACTIVE" or self.status == "INACTIVE" or self.status == "INACTIVE_TODELETE" or self.status == "PENDING_TODELETE" or self.status == "EXPIRED"): + found = True logger.info('models::is_synced(): self='+str(self)+ " => returning found="+str(found)) return found diff --git a/flowspec/tasks.py b/flowspec/tasks.py index 69821feb84395634a1972c04ccecfa57dddb5fdc..bca9e4eb6bafcdddca22c70176f1ea467fb31b0f 100644 --- a/flowspec/tasks.py +++ b/flowspec/tasks.py @@ -290,15 +290,16 @@ def check_sync(route_name=None, selected_routes=[]): for route in routes: if route.has_expired() and (route.status != 'EXPIRED' and route.status != 'ADMININACTIVE' and route.status != 'INACTIVE' and route.status != 'INACTIVE_TODELETE' and route.status != 'PENDING_TODELETE'): if route.status != 'ERROR': - logger.info('Expiring %s route %s' %(route.status, route.name)) + logger.info('tasks::check_sync(): expiring %s route %s' %(route.status, route.name)) subtask(deactivate_route).delay(str(route.id), reason="EXPIRED") else: if route.status != 'EXPIRED': old_status = route.status + logger.debug('tasks::check_sync(): calling route.check_sync for %s : %s' % (route.name, old_status)) route.check_sync(netconf_device_queried=device) new_status = route.status if old_status != new_status: - logger.info('status of rule changed during check_sync %s : %s -> %s' % (route.name, old_status, new_status)) + logger.info('tasks::check_sync(): status of rule changed during check_sync %s : %s -> %s' % (route.name, old_status, new_status)) announce("[%s] Rule status change after sync check: %s - Result: %s" % ("-", route.name_visible, ""), route.applier, route)