From: Balagangadhar Bathula Date: Fri, 30 Apr 2021 21:18:25 +0000 (-0400) Subject: Update port-mapping data with trib-slots for B100G X-Git-Tag: 4.0.0~74 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F68%2F95968%2F28;p=transportpce.git Update port-mapping data with trib-slots for B100G Muxponder switch-client port-quals require max/min-trib-slots from muxp-profile to be available in the port-mapping. JIRA: TRNSPRTPCE-449 Change-Id: Ic360fed70fe07f752078596e1facd7063cc28ac9 Signed-off-by: Balagangadhar Bathula --- diff --git a/common/src/main/java/org/opendaylight/transportpce/common/mapping/PortMappingVersion710.java b/common/src/main/java/org/opendaylight/transportpce/common/mapping/PortMappingVersion710.java index 50d1383d4..8d85f8e49 100644 --- a/common/src/main/java/org/opendaylight/transportpce/common/mapping/PortMappingVersion710.java +++ b/common/src/main/java/org/opendaylight/transportpce/common/mapping/PortMappingVersion710.java @@ -43,6 +43,7 @@ import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmappi import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210426.mc.capabilities.McCapabilities; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210426.mc.capabilities.McCapabilitiesBuilder; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210426.mc.capabilities.McCapabilitiesKey; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210426.mpdr.restrictions.grp.MpdrRestrictionsBuilder; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210426.network.Nodes; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210426.network.NodesBuilder; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210426.network.NodesKey; @@ -71,6 +72,8 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.org.open import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.org.openroadm.device.container.org.openroadm.device.Info; import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.org.openroadm.device.container.org.openroadm.device.McCapabilityProfile; import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.org.openroadm.device.container.org.openroadm.device.McCapabilityProfileKey; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.org.openroadm.device.container.org.openroadm.device.MuxpProfile; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.org.openroadm.device.container.org.openroadm.device.MuxpProfileKey; import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.org.openroadm.device.container.org.openroadm.device.OduSwitchingPools; import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.org.openroadm.device.container.org.openroadm.device.Protocols; import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.org.openroadm.device.container.org.openroadm.device.SharedRiskGroup; @@ -89,15 +92,18 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.interfaces.rev191129.OtnO import org.opendaylight.yang.gen.v1.http.org.openroadm.lldp.rev200529.Protocols1; import org.opendaylight.yang.gen.v1.http.org.openroadm.lldp.rev200529.lldp.container.Lldp; import org.opendaylight.yang.gen.v1.http.org.openroadm.lldp.rev200529.lldp.container.lldp.PortConfig; +import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev200327.OpucnTribSlotDef; import org.opendaylight.yang.gen.v1.http.org.openroadm.port.capability.rev200529.Ports1; import org.opendaylight.yang.gen.v1.http.org.openroadm.port.capability.rev200529.port.capability.grp.port.capabilities.SupportedInterfaceCapability; import org.opendaylight.yang.gen.v1.http.org.openroadm.port.capability.rev200529.port.capability.grp.port.capabilities.SupportedInterfaceCapabilityKey; +import org.opendaylight.yang.gen.v1.http.org.openroadm.port.capability.rev200529.port.capability.grp.port.capabilities.supported._interface.capability.otn.capability.MpdrClientRestriction; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.common.Uint16; import org.opendaylight.yangtools.yang.common.Uint32; import org.slf4j.Logger; import org.slf4j.LoggerFactory; + // FIXME: many common pieces of code between PortMapping Versions 121 and 221 and 710 // some mutualization would be helpful @SuppressWarnings("CPD-START") @@ -930,8 +936,26 @@ public class PortMappingVersion710 { .SupportedIfCapability>> supportedIntf = new ArrayList<>(); Map supIfCapMap = port .augmentation(Ports1.class).getPortCapabilities().nonnullSupportedInterfaceCapability(); + SupportedInterfaceCapability sic1 = null; for (SupportedInterfaceCapability sic : supIfCapMap.values()) { supportedIntf.add(sic.getIfCapType()); + sic1 = sic; + } + if (port.getPortQual() == PortQual.SwitchClient + && !sic1.getOtnCapability().getMpdrClientRestriction().isEmpty()) { + List mpdrClientRestriction = sic1.getOtnCapability().getMpdrClientRestriction(); + // Here we assume all the supported-interfaces has the support same rates, and the + // trib-slot numbers are assumed to be the same + String mxpProfileName = mpdrClientRestriction.get(0).getMuxpProfileName().get(0); + // From this muxponder-profile get the min-trib-slot and the max-trib-slot + LOG.info("{}: Muxp-profile used for trib information {}", nodeId, mxpProfileName); + // This provides the tribSlot information from muxProfile + List minMaxOpucnTribSlots = getOpucnTribSlots(nodeId, mxpProfileName); + mpBldr.setMpdrRestrictions( + new MpdrRestrictionsBuilder() + .setMinTribSlot(minMaxOpucnTribSlots.get(0)) + .setMaxTribSlot(minMaxOpucnTribSlots.get(1)) + .build()); } mpBldr.setSupportedInterfaceCapability(supportedIntf); } @@ -944,6 +968,29 @@ public class PortMappingVersion710 { return mpBldr.build(); } + private ArrayList getOpucnTribSlots(String deviceId, String mxpProfileName) { + ArrayList minMaxOpucnTribSlots = new ArrayList<>(2); + + LOG.info("{} : Getting Min/Max Trib-slots from {}", deviceId, mxpProfileName); + InstanceIdentifier deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class) + .child(MuxpProfile.class, new MuxpProfileKey(mxpProfileName)); + + Optional muxpProfileObject = this.deviceTransactionManager.getDataFromDevice(deviceId, + LogicalDatastoreType.OPERATIONAL, deviceIID, + Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT); + + List ntwHoOduOpucnTribSlots = muxpProfileObject.get().getNetworkHoOduOpucnTribSlots(); + // Sort the tib-slots in ascending order and pick min and max + List sortedNtwHoOduOpucnTribSlots = ntwHoOduOpucnTribSlots.stream().sorted( + Comparator.comparingDouble(x -> Double.parseDouble( + x.getValue().substring(x.getValue().lastIndexOf('.') + 1)))) + .collect(Collectors.toList()); + minMaxOpucnTribSlots.add(sortedNtwHoOduOpucnTribSlots.get(0)); + minMaxOpucnTribSlots.add(sortedNtwHoOduOpucnTribSlots.get(sortedNtwHoOduOpucnTribSlots.size() - 1)); + // LOG.info("Min, Max trib slot list {}", minMaxOpucnTribSlots); + return minMaxOpucnTribSlots; + } + private Ports getPort2(Ports port, String nodeId, String circuitPackName, StringBuilder circuitPackName2, //circuitPackName2 will be updated by reference contrary to circuitPackName List circuitPackList, Map lcpMap) {