Generate ADDED events for Node and NodeConnector 43/3843/2
authorMoiz Raja <moraja@cisco.com>
Thu, 19 Dec 2013 01:14:38 +0000 (17:14 -0800)
committerMoiz Raja <moraja@cisco.com>
Thu, 19 Dec 2013 02:07:28 +0000 (18:07 -0800)
Components like switch manager need to see an ADDED event come in for Node and NodeConnector before
they accept changes for those elements. This commit first checks whether a Node/NodeConnector are
already known to the DataBrokerService. If they are not known then it notifies the listeners of an ADDED
event otherwise it notifies it of a CHANGED event

Also implemented node removal. NOTE: NodeConnector removed events do not seem to be coming through.

Change-Id: Idcbe7fdce37c16158614f62b56767bed624bc803
Signed-off-by: Moiz Raja <moraja@cisco.com>
opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/InventoryAndReadAdapter.xtend

index 8ac6f1b0500d1834fa6883de70a7ae3c6eb601bb..609ace469556e1101389bd17677796b159dde8a6 100644 (file)
@@ -157,17 +157,39 @@ class InventoryAndReadAdapter implements IPluginInTopologyService, IPluginInRead
     }
 
     override onNodeRemoved(NodeRemoved notification) {
     }
 
     override onNodeRemoved(NodeRemoved notification) {
-        // NOOP
+        val properties = Collections.<org.opendaylight.controller.sal.core.Property>emptySet();
+        val org.opendaylight.yangtools.yang.binding.InstanceIdentifier<? extends DataObject> identifier = notification.nodeRef.value  as org.opendaylight.yangtools.yang.binding.InstanceIdentifier<? extends DataObject>;
+
+        inventoryPublisher.updateNode(notification.nodeRef.toADNode, UpdateType.REMOVED, properties);
     }
 
     override onNodeConnectorUpdated(NodeConnectorUpdated update) {
     }
 
     override onNodeConnectorUpdated(NodeConnectorUpdated update) {
-        val properties = Collections.<org.opendaylight.controller.sal.core.Property>emptySet();
-        inventoryPublisher.updateNodeConnector(update.nodeConnectorRef.toADNodeConnector, UpdateType.CHANGED, properties);
+        val properties = new java.util.HashSet<org.opendaylight.controller.sal.core.Property>();
+
+
+        val org.opendaylight.yangtools.yang.binding.InstanceIdentifier<? extends DataObject> identifier = update.nodeConnectorRef.value as org.opendaylight.yangtools.yang.binding.InstanceIdentifier<? extends DataObject>;
+        var updateType = UpdateType.CHANGED;
+        if ( this._dataService.readOperationalData(identifier) == null ){
+            updateType = UpdateType.ADDED;
+        }
+
+        var nodeConnector = update.nodeConnectorRef.toADNodeConnector
+
+
+        properties.add(new org.opendaylight.controller.sal.core.Name(nodeConnector.ID.toString()));
+
+        inventoryPublisher.updateNodeConnector(nodeConnector , updateType , properties);
     }
 
     override onNodeUpdated(NodeUpdated notification) {
         val properties = Collections.<org.opendaylight.controller.sal.core.Property>emptySet();
     }
 
     override onNodeUpdated(NodeUpdated notification) {
         val properties = Collections.<org.opendaylight.controller.sal.core.Property>emptySet();
-        inventoryPublisher.updateNode(notification.nodeRef.toADNode, UpdateType.CHANGED, properties);
+        val org.opendaylight.yangtools.yang.binding.InstanceIdentifier<? extends DataObject> identifier = notification.nodeRef.value  as org.opendaylight.yangtools.yang.binding.InstanceIdentifier<? extends DataObject>;
+
+        var updateType = UpdateType.CHANGED;
+        if ( this._dataService.readOperationalData(identifier) == null ){
+            updateType = UpdateType.ADDED;
+        }
+        inventoryPublisher.updateNode(notification.nodeRef.toADNode, updateType, properties);
     }
 
     override getNodeProps() {
     }
 
     override getNodeProps() {