Fixed Topology Adapter to properly add Edge Properties 23/4023/2
authorEd Warnicke <eaw@cisco.com>
Mon, 6 Jan 2014 07:22:53 +0000 (23:22 -0800)
committerEd Warnicke <eaw@cisco.com>
Mon, 6 Jan 2014 12:40:55 +0000 (04:40 -0800)
Change-Id: I89b6349e220a085d8ba6027f8294f88f7e6df244
Signed-off-by: Ed Warnicke <eaw@cisco.com>
opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/NodeMapping.xtend
opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/topology/TopologyAdapter.xtend
opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/topology/TopologyCommitHandler.xtend
opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/topology/TopologyMapping.xtend

index 4ad91c26779dcdfdb451200636c958ca3d4ae027..4378e7dffece701592936ce85dba77884c6ce8d8 100644 (file)
@@ -48,6 +48,7 @@ import java.util.Date
 import org.opendaylight.controller.sal.core.TimeStamp
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowNodeConnector
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowNode
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector
 
 public class NodeMapping {
 
@@ -171,6 +172,14 @@ public class NodeMapping {
         return new HashSet<org.opendaylight.controller.sal.core.Property>();
     }
 
+    public static def toADNodeConnectorProperties(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector nc) {
+        val fcnc = nc.getAugmentation(FlowCapableNodeConnector)
+        if (fcnc != null) {
+            return fcnc.toADNodeConnectorProperties
+        }
+        return new HashSet<org.opendaylight.controller.sal.core.Property>();
+    }
+
     public static def toADNodeConnectorProperties(FlowNodeConnector fcncu) {
         val props = new HashSet<org.opendaylight.controller.sal.core.Property>();
         if (fcncu != null) {
index 6c5c5db4190459d33047156954334380b3aa440a..bd2590f18b4dc5927acd8da2b1a9882faa731413 100644 (file)
@@ -1,5 +1,6 @@
 package org.opendaylight.controller.sal.compatibility.topology
 
+import org.opendaylight.controller.md.sal.binding.util.TypeSafeDataReader
 import org.opendaylight.controller.sal.binding.api.data.DataProviderService
 import org.opendaylight.controller.sal.topology.IPluginInTopologyService
 import org.opendaylight.controller.sal.topology.IPluginOutTopologyService
@@ -10,9 +11,6 @@ import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier
 
 import static extension org.opendaylight.controller.sal.compatibility.topology.TopologyMapping.*
-import java.util.List
-import org.opendaylight.controller.sal.topology.TopoEdgeUpdate
-import java.util.Collections
 
 class TopologyAdapter implements IPluginInTopologyService {
     
@@ -24,8 +22,9 @@ class TopologyAdapter implements IPluginInTopologyService {
     
     override sollicitRefresh() {
         val path = InstanceIdentifier.builder(NetworkTopology).child(Topology,new TopologyKey(new TopologyId("flow:1"))).toInstance;
-        val topology =  (dataService.readOperationalData(path) as Topology);
-        topologyPublisher.edgeUpdate(topology.toADEdgeUpdates)
+        val reader = TypeSafeDataReader.forReader(dataService)
+        val topology = reader.readOperationalData(path)
+        topologyPublisher.edgeUpdate(topology.toADEdgeUpdates(reader))
     }
     
 }
\ No newline at end of file
index abe9701dd4dc80e05e9bec8ec6ad24f2ee69f2ff..7d05ce60fa43c7fd3920dcbc59b1d6396ff159d9 100644 (file)
@@ -40,16 +40,16 @@ class TopologyCommitHandler implements DataCommitHandler<InstanceIdentifier<? ex
             val topology = reader.readOperationalData(topologyPath)
             val adds = FluentIterable.from(modification.createdOperationalData.entrySet)
                 .filter[value instanceof Link]
-                .transform[(value as Link).toAdEdge(topology).toTopoEdgeUpdate(UpdateType.ADDED)]
+                .transform[(value as Link).toAdEdge(topology).toTopoEdgeUpdate(UpdateType.ADDED,reader)]
                 .toList
             val updates = FluentIterable.from(modification.updatedOperationalData.entrySet)
                 .filter[!modification.createdOperationalData.containsKey(key) && (value instanceof Link)]
-                .transform[(value as Link).toAdEdge(topology).toTopoEdgeUpdate(UpdateType.ADDED)] // Evidently the ADSAL does not expect edge 'CHANGED"
+                .transform[(value as Link).toAdEdge(topology).toTopoEdgeUpdate(UpdateType.ADDED,reader)] // Evidently the ADSAL does not expect edge 'CHANGED"
                 .toList
             val removes = FluentIterable.from(modification.removedOperationalData)
                 .transform[reader.readOperationalData(it as InstanceIdentifier<DataObject>)]
                 .filter[it instanceof Link]
-                .transform[(it as Link).toAdEdge(topology).toTopoEdgeUpdate(UpdateType.REMOVED)]
+                .transform[(it as Link).toAdEdge(topology).toTopoEdgeUpdate(UpdateType.REMOVED,reader)]
                 .toList
             msg.addAll(adds)
             msg.addAll(updates)
index 1f0eeea7833edf465d9f6a1bfe2fc0ea55934d92..62983ccce477abec0a6c9a3a069b763c0911fdc9 100644 (file)
@@ -16,7 +16,10 @@ import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.network.topology.topology.Link
 
 import static com.google.common.base.Preconditions.*
-import static org.opendaylight.controller.sal.compatibility.NodeMapping.*
+import static extension org.opendaylight.controller.sal.compatibility.NodeMapping.*
+import org.opendaylight.controller.md.sal.binding.util.TypeSafeDataReader
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector
 
 class TopologyMapping {
     
@@ -24,9 +27,9 @@ class TopologyMapping {
         throw new UnsupportedOperationException("Utility class. Instantiation is not allowed.");
     }
     
-    public static def toADEdgeUpdates(Topology topology) {
+    public static def toADEdgeUpdates(Topology topology,TypeSafeDataReader reader) {
         val List<TopoEdgeUpdate> result = new CopyOnWriteArrayList<TopoEdgeUpdate>()
-        return FluentIterable.from(topology.link).transform[toAdEdge(topology).toTopoEdgeUpdate].copyInto(result)
+        return FluentIterable.from(topology.link).transform[toAdEdge(topology).toTopoEdgeUpdate(reader)].copyInto(result)
     }
     
     public static def toAdEdge(Link link,Topology topology) {
@@ -35,12 +38,17 @@ class TopologyMapping {
         return new Edge(adSrc,adDst); 
     }
     
-    public static def toTopoEdgeUpdate(Edge e) {
-        return toTopoEdgeUpdate(e,UpdateType.ADDED)
+    public static def toTopoEdgeUpdate(Edge e,TypeSafeDataReader reader) {
+        return toTopoEdgeUpdate(e,UpdateType.ADDED,reader)
     }
     
-    public static def toTopoEdgeUpdate(Edge e,UpdateType type) {
-        return new TopoEdgeUpdate(e,Collections.emptySet,type)
+    public static def toTopoEdgeUpdate(Edge e,UpdateType type,TypeSafeDataReader reader) {
+        return new TopoEdgeUpdate(e,e.toAdEdgeProperties(reader),type)
+    }
+    
+    public static def toAdEdgeProperties(Edge e,TypeSafeDataReader reader) {
+        val nc = reader.readOperationalData(e.tailNodeConnector.toNodeConnectorRef.value as InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector>)
+        return nc.toADNodeConnectorProperties     
     }
     
     public static def toADNodeId(NodeId nodeId) {