X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fcompatibility%2Fsal-compatibility%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Fcompatibility%2FNodeMapping.xtend;h=29973b7b330887454c48dbc976712041e428b3d4;hb=d0079eb5f3b99b255cbec1d81de50cbb0ef3d2ec;hp=6bfee578abc0ce56d78ce7aaa432bd4cee7aecd6;hpb=454f93d530edea269105cebd0020d0bf1aa75c79;p=controller.git 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 6bfee578ab..29973b7b33 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 @@ -16,7 +16,17 @@ import org.opendaylight.controller.sal.core.ConstructionException import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId - +import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorUpdated +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnectorUpdated +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortFeatures +import org.opendaylight.controller.sal.core.Bandwidth +import org.opendaylight.controller.sal.core.AdvertisedBandwidth +import org.opendaylight.controller.sal.core.SupportedBandwidth +import org.opendaylight.controller.sal.core.PeerBandwidth +import org.opendaylight.controller.sal.core.Name +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortConfig +import org.opendaylight.controller.sal.core.Config +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.flow.capable.port.State public class NodeMapping { @@ -35,9 +45,15 @@ public class NodeMapping { val arg = node.getPath().get(1); val item = arg.checkInstanceOf(IdentifiableItem); val nodeKey = item.getKey().checkInstanceOf(NodeKey); - return new Node(MD_SAL_TYPE, nodeKey.getId().getValue().toString()); + return new Node(MD_SAL_TYPE, nodeKey.id.toADNodeId); + } + + public static def toADNodeId(NodeId nodeId) { + checkNotNull(nodeId); + return nodeId.value } + public static def toADNodeConnector(NodeConnectorRef source) throws ConstructionException { checkNotNull(source); val InstanceIdentifier path = checkNotNull(source.getValue()); @@ -46,7 +62,11 @@ public class NodeMapping { val arg = path.getPath().get(2); val item = arg.checkInstanceOf(IdentifiableItem); val connectorKey = item.getKey().checkInstanceOf(NodeConnectorKey); - return new NodeConnector(MD_SAL_TYPE, connectorKey.getId().getValue().toString(), node); + return new NodeConnector(MD_SAL_TYPE, connectorKey.id.toADNodeConnectorId, node); + } + + public static def toADNodeConnectorId(NodeConnectorId nodeConnectorId) { + return nodeConnectorId.value } public static def toNodeRef(Node node) { @@ -70,4 +90,107 @@ public class NodeMapping { return toADNode(node.getValue()); } + public static def toADNodeConnectorProperties(NodeConnectorUpdated nc) { + val props = new java.util.HashSet(); + val fcncu = nc.getAugmentation(FlowCapableNodeConnectorUpdated) + if(fcncu != null) { + if(fcncu.currentFeature != null && fcncu.currentFeature.toAdBandwidth != null) { + props.add(fcncu.currentFeature.toAdBandwidth) + } + if(fcncu.advertisedFeatures != null && fcncu.advertisedFeatures.toAdAdvertizedBandwidth != null) { + props.add(fcncu.advertisedFeatures.toAdAdvertizedBandwidth) + } + if(fcncu.supported != null && fcncu.supported.toAdSupportedBandwidth != null) { + props.add(fcncu.supported.toAdSupportedBandwidth) + } + if(fcncu.peerFeatures != null && fcncu.peerFeatures.toAdPeerBandwidth != null) { + props.add(fcncu.peerFeatures.toAdPeerBandwidth) + } + if(fcncu.name != null && fcncu.name.toAdName != null) { + props.add(fcncu.name.toAdName) + } + if(fcncu.configuration != null && fcncu.configuration.toAdConfig != null) { + props.add(fcncu.configuration.toAdConfig) + } + if(fcncu.state != null && fcncu.state.toAdState != null) { + props.add(fcncu.state.toAdState) + } + } + return props + } + + public static def toAdName(String name) { + return new Name(name) + } + + public static def toAdConfig(PortConfig pc) { + var Config config; + if(pc.PORTDOWN){ + config = new Config(Config.ADMIN_DOWN) + } else { + config = new Config(Config.ADMIN_UP) + } + return config + } + + public static def toAdState(State s) { + var org.opendaylight.controller.sal.core.State state + if(s.linkDown) { + state = new org.opendaylight.controller.sal.core.State(org.opendaylight.controller.sal.core.State.EDGE_DOWN) + } else { + state = new org.opendaylight.controller.sal.core.State(org.opendaylight.controller.sal.core.State.EDGE_UP) + } + return state + } + + public static def toAdBandwidth(PortFeatures pf) { + var Bandwidth bw = null + if (pf.is_10mbHd || pf.is_10mbFd ) { + bw= new Bandwidth(Bandwidth.BW10Mbps) + } else if (pf.is_100mbHd || pf.is_100mbFd ) { + bw= new Bandwidth(Bandwidth.BW100Mbps) + } else if (pf.is_1gbHd || pf.is_1gbFd ) { + bw= new Bandwidth(Bandwidth.BW1Gbps) + } else if (pf.is_1gbFd ) { + bw= new Bandwidth(Bandwidth.BW10Gbps) + } else if ( pf.is_10gbFd ) { + bw= new Bandwidth(Bandwidth.BW10Gbps) + } else if ( pf.is_40gbFd ) { + bw= new Bandwidth(Bandwidth.BW40Gbps) + } else if ( pf.is_100gbFd ) { + bw= new Bandwidth(Bandwidth.BW100Gbps) + } else if ( pf.is_1tbFd ) { + bw= new Bandwidth(Bandwidth.BW1Tbps) + } + return bw; + } + + public static def toAdAdvertizedBandwidth(PortFeatures pf) { + var AdvertisedBandwidth abw + val bw = pf.toAdBandwidth + if(bw != null) { + abw = new AdvertisedBandwidth(bw.value) + } + return abw + } + + public static def toAdSupportedBandwidth(PortFeatures pf) { + var SupportedBandwidth sbw + val bw = pf.toAdBandwidth + if(bw != null ) { + sbw = new SupportedBandwidth(bw.value) + } + return sbw + } + + public static def toAdPeerBandwidth(PortFeatures pf) { + var PeerBandwidth pbw + val bw = pf.toAdBandwidth + if(bw != null) { + pbw = new PeerBandwidth(bw.value) + } + return pbw + } + + }