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()
@datastream
@on_delete_check(
check=[
# ("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 noc.sa.models.managedobject import ManagedObject
for mo in ManagedObject.objects.filter(time_pattern=self):
for c in mo.iter_changed_datastream(
changed_fields={"time_pattern_term"}
):
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 (
config.datastream.enable_managedobject
and "managed_object_profile" not in changed_fields
and not changed_fields.intersection(
{"time_pattern_term", "managed_object_profile"}
)
):
yield "managedobject", self.id
if config.datastream.enable_cfgping and changed_fields.intersection(
......@@ -544,6 +546,7 @@ class ManagedObject(NOCModel):
"ping_count",
"ping_timeout_ms",
"report_ping_attempts",
"time_pattern_term",
"event_processing_policy",
}
):
......
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