Commit 91c04f26 authored by Andrey Vertiprahov's avatar Andrey Vertiprahov
Browse files

Fix refresh cfgping datastream when timepattern change and fix trace creating...

Fix refresh cfgping datastream when timepattern change and fix trace creating document without initial_data field.
parent a55ed3bf
......@@ -54,7 +54,7 @@ def _on_model_change(sender, instance, *args, **kwargs):
def _on_document_change(sender, document, *args, **kwargs):
_on_change(document, changed_fields=document._changed_fields)
_on_change(document, changed_fields=getattr(document, "_changed_fields", {}))
def _on_change(obj, changed_fields=None):
......@@ -20,10 +20,12 @@ from django.db import models
from noc.core.model.base import NOCModel
from noc.lib.timepattern import TimePattern as TP
from noc.core.model.decorator import on_delete_check
from noc.core.datastream.decorator import datastream
id_lock = Lock()
# ("fm.EscalationItem", "administrative_domain")
......@@ -88,6 +90,14 @@ class TimePattern(NOCModel):
return self.time_pattern.match(d)
def iter_changed_datastream(self, changed_fields=None):
from import ManagedObject
for mo in ManagedObject.objects.filter(time_pattern=self):
for c in mo.iter_changed_datastream(
yield c
# Avoid circular references
# No delete, fixed 'TimePattern' object has no attribute 'timepatternterm_set'
......@@ -531,7 +531,9 @@ class ManagedObject(NOCModel):
def iter_changed_datastream(self, changed_fields=None):
if (
and "managed_object_profile" not in changed_fields
and not changed_fields.intersection(
{"time_pattern_term", "managed_object_profile"}
yield "managedobject",
if config.datastream.enable_cfgping and changed_fields.intersection(
......@@ -544,6 +546,7 @@ class ManagedObject(NOCModel):
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment