Eliminate synchronizer to data model feedback
diff --git a/xos/core/models/plcorebase.py b/xos/core/models/plcorebase.py
index c8c25a7..060570d 100644
--- a/xos/core/models/plcorebase.py
+++ b/xos/core/models/plcorebase.py
@@ -2,6 +2,7 @@
import json
import os
import sys
+import threading
from django import db
from django.db import models
from django.forms.models import model_to_dict
@@ -198,7 +199,7 @@
# default values for created and updated are only there to keep evolution
# from failing.
created = models.DateTimeField(auto_now_add=True, default=timezone.now)
- updated = models.DateTimeField(auto_now=True, default=timezone.now)
+ updated = models.DateTimeField(default=timezone.now)
enacted = models.DateTimeField(null=True, blank=True, default=None)
policed = models.DateTimeField(null=True, blank=True, default=None)
@@ -270,6 +271,9 @@
if not (field in ["backend_register", "backend_status", "deleted", "enacted", "updated"]):
ignore_composite_key_check=False
+ if 'synchronizer' not in threading.current_thread().name:
+ self.updated = datetime.datetime.now()
+
super(PlCoreBase, self).save(*args, **kwargs)
# This is a no-op if observer_disabled is set
diff --git a/xos/synchronizers/base/backend.py b/xos/synchronizers/base/backend.py
index 5f11d46..d7307fa 100644
--- a/xos/synchronizers/base/backend.py
+++ b/xos/synchronizers/base/backend.py
@@ -15,7 +15,7 @@
def run(self):
# start the openstack observer
observer = XOSObserver()
- observer_thread = threading.Thread(target=observer.run)
+ observer_thread = threading.Thread(target=observer.run,name='synchronizer')
observer_thread.start()
# start model policies thread
diff --git a/xos/synchronizers/base/event_loop.py b/xos/synchronizers/base/event_loop.py
index f224380..4f7d436 100644
--- a/xos/synchronizers/base/event_loop.py
+++ b/xos/synchronizers/base/event_loop.py
@@ -521,7 +521,12 @@
loop_end = time.time()
- diag = Diag.objects.filter(name=Config().observer_name).first()
+ try:
+ observer_name = Config().observer_name
+ except:
+ observer_name = ''
+
+ diag = Diag.objects.filter(name=observer_name).first()
if (diag):
br_str = diag.backend_register
br = json.loads(br_str)