Change-Id: I89b6349e220a085d8ba6027f8294f88f7e6df244
Signed-off-by: Ed Warnicke <eaw@cisco.com>
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.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 {
public class NodeMapping {
return new HashSet<org.opendaylight.controller.sal.core.Property>();
}
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) {
public static def toADNodeConnectorProperties(FlowNodeConnector fcncu) {
val props = new HashSet<org.opendaylight.controller.sal.core.Property>();
if (fcncu != null) {
package org.opendaylight.controller.sal.compatibility.topology
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
import org.opendaylight.controller.sal.binding.api.data.DataProviderService
import org.opendaylight.controller.sal.topology.IPluginInTopologyService
import org.opendaylight.controller.sal.topology.IPluginOutTopologyService
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier
import static extension org.opendaylight.controller.sal.compatibility.topology.TopologyMapping.*
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 {
class TopologyAdapter implements IPluginInTopologyService {
override sollicitRefresh() {
val path = InstanceIdentifier.builder(NetworkTopology).child(Topology,new TopologyKey(new TopologyId("flow:1"))).toInstance;
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
}
}
\ No newline at end of file
val topology = reader.readOperationalData(topologyPath)
val adds = FluentIterable.from(modification.createdOperationalData.entrySet)
.filter[value instanceof Link]
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)]
.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]
.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)
.toList
msg.addAll(adds)
msg.addAll(updates)
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 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
throw new UnsupportedOperationException("Utility class. Instantiation is not allowed.");
}
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>()
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) {
}
public static def toAdEdge(Link link,Topology topology) {
return new Edge(adSrc,adDst);
}
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) {
}
public static def toADNodeId(NodeId nodeId) {