From b42589d43a0d8767585f44f67229ddfd3a829ede Mon Sep 17 00:00:00 2001 From: Ed Warnicke Date: Sun, 5 Jan 2014 23:22:53 -0800 Subject: [PATCH] Fixed Topology Adapter to properly add Edge Properties Change-Id: I89b6349e220a085d8ba6027f8294f88f7e6df244 Signed-off-by: Ed Warnicke --- .../sal/compatibility/NodeMapping.xtend | 9 ++++++++ .../topology/TopologyAdapter.xtend | 9 ++++---- .../topology/TopologyCommitHandler.xtend | 6 ++--- .../topology/TopologyMapping.xtend | 22 +++++++++++++------ 4 files changed, 31 insertions(+), 15 deletions(-) diff --git a/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/NodeMapping.xtend b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/NodeMapping.xtend index 4ad91c2677..4378e7dffe 100644 --- a/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/NodeMapping.xtend +++ b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/NodeMapping.xtend @@ -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(); } + 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(); + } + public static def toADNodeConnectorProperties(FlowNodeConnector fcncu) { val props = new HashSet(); if (fcncu != null) { diff --git a/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/topology/TopologyAdapter.xtend b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/topology/TopologyAdapter.xtend index 6c5c5db419..bd2590f18b 100644 --- a/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/topology/TopologyAdapter.xtend +++ b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/topology/TopologyAdapter.xtend @@ -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 diff --git a/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/topology/TopologyCommitHandler.xtend b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/topology/TopologyCommitHandler.xtend index abe9701dd4..7d05ce60fa 100644 --- a/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/topology/TopologyCommitHandler.xtend +++ b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/topology/TopologyCommitHandler.xtend @@ -40,16 +40,16 @@ class TopologyCommitHandler implements DataCommitHandler)] .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) diff --git a/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/topology/TopologyMapping.xtend b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/topology/TopologyMapping.xtend index 1f0eeea783..62983ccce4 100644 --- a/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/topology/TopologyMapping.xtend +++ b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/topology/TopologyMapping.xtend @@ -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 result = new CopyOnWriteArrayList() - 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) + return nc.toADNodeConnectorProperties } public static def toADNodeId(NodeId nodeId) { -- 2.36.6