Watch for changes in Node objects
Change-Id: If01962e18763c67be06d955fac25b4656e3479f4
diff --git a/xos/synchronizer/steps/sync_onos_netcfg.py b/xos/synchronizer/steps/sync_onos_netcfg.py
index 509c7a0..8c157e3 100644
--- a/xos/synchronizer/steps/sync_onos_netcfg.py
+++ b/xos/synchronizer/steps/sync_onos_netcfg.py
@@ -5,20 +5,28 @@
import base64
import json
from synchronizers.base.syncstep import SyncStep
-from core.models import Service, Slice, Controller, ControllerSlice, ControllerUser, Node, TenantAttribute, Tag
+from core.models import Service, Slice, Controller, ControllerSlice, ControllerUser, Node, TenantAttribute, Tag, ModelLink, AddressPool
from services.vtn.models import VTNService
from xos.logger import Logger, logging
logger = Logger(level=logging.INFO)
class SyncONOSNetcfg(SyncStep):
- provides=[]
- observes=None
+ provides=[VTNService]
+ observes=VTNService
+ watches=[ModelLink(Node,via='node'), ModelLink(AddressPool,via='addresspool')]
requested_interval=0
def __init__(self, **args):
SyncStep.__init__(self, **args)
+ def handle_watched_object(self, o):
+ logger.info("handle_watched_object is invoked for object %s" % (str(o)),extra=o.tologdict())
+ if (type(o) is Node): # For Node add/delete/modify
+ self.call()
+ if (type(o) is AddressPool): # For public gateways
+ self.call()
+
def get_node_tag(self, node, tagname):
tags = Tag.select_by_content_object(node).filter(name=tagname)
return tags[0].value
diff --git a/xos/synchronizer/vtn_synchronizer_config b/xos/synchronizer/vtn_synchronizer_config
index d931839..9c99456 100644
--- a/xos/synchronizer/vtn_synchronizer_config
+++ b/xos/synchronizer/vtn_synchronizer_config
@@ -32,6 +32,7 @@
driver=openstack
pretend=False
backoff_disabled=True
+enable_watchers=True
[nova]
ca_ssl_cert=/etc/ssl/certs/ca-certificates.crt