X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fcompatibility%2Fsal-compatibility%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Fcompatibility%2Ftopology%2FTopologyMapping.xtend;h=850c442b9b7374865cc19b372d9c87819cd1c43b;hp=1f0eeea7833edf465d9f6a1bfe2fc0ea55934d92;hb=63440dddd588ab727fb0f5f0df28e61dfecf86a2;hpb=f0fb3be54c79ce64725b467acdbf99a45b3a2504 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..850c442b9b 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 @@ -10,23 +10,27 @@ import org.opendaylight.controller.sal.core.Node import org.opendaylight.controller.sal.core.NodeConnector import org.opendaylight.controller.sal.core.UpdateType import org.opendaylight.controller.sal.topology.TopoEdgeUpdate -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.NodeId -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.TpId -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.network.topology.Topology -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.network.topology.topology.Link +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TpId +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.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 +import org.slf4j.LoggerFactory class TopologyMapping { - + private static val LOG = LoggerFactory.getLogger(TopologyMapping); private new() { 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 +39,30 @@ 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,TypeSafeDataReader reader) { + return new TopoEdgeUpdate(e,e.toAdEdgeProperties(reader),type) } - public static def toTopoEdgeUpdate(Edge e,UpdateType type) { - return new TopoEdgeUpdate(e,Collections.emptySet,type) + public static def toAdEdgeProperties(Edge e,TypeSafeDataReader reader) { + val ncref = e.tailNodeConnector.toNodeConnectorRef + if(ncref == null) { + LOG.debug("Edge {} ncref {}",e,ncref) + return null; + } + val ncInstanceId = (ncref.value as InstanceIdentifier) + if(ncInstanceId == null) { + LOG.debug("Edge {} ncref {}",e,ncref) + return null; + } + val nc = reader.readOperationalData(ncInstanceId) + if(nc == null) { + return null; + } + return nc.toADNodeConnectorProperties } public static def toADNodeId(NodeId nodeId) {