+ private ArrayList<OpucnTribSlotDef> getOpucnTribSlots(String deviceId, String mxpProfileName) {
+ ArrayList<OpucnTribSlotDef> minMaxOpucnTribSlots = new ArrayList<>(2);
+
+ LOG.info("{} : Getting Min/Max Trib-slots from {}", deviceId, mxpProfileName);
+ InstanceIdentifier<MuxpProfile> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class)
+ .child(MuxpProfile.class, new MuxpProfileKey(mxpProfileName));
+
+ Optional<MuxpProfile> muxpProfileObject = this.deviceTransactionManager.getDataFromDevice(deviceId,
+ LogicalDatastoreType.OPERATIONAL, deviceIID,
+ Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
+
+ List<OpucnTribSlotDef> ntwHoOduOpucnTribSlots = muxpProfileObject.get().getNetworkHoOduOpucnTribSlots();
+ // Sort the tib-slots in ascending order and pick min and max
+ List<OpucnTribSlotDef> 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<CircuitPacks> circuitPackList, Map<String, String> lcpMap) {
+ if (!checkPartnerPortNotNull(port)) {
+ LOG.warn("{} : port {} on {} - Error in the configuration ",
+ nodeId, port.getPortName(), circuitPackName);
+ return null;
+ }
+ if (lcpMap.containsKey(circuitPackName + '+' + port.getPortName())) {
+ return null;
+ }
+ Optional<CircuitPacks> cpOpt = circuitPackList.stream()
+ .filter(
+ cP -> cP.getCircuitPackName().equals(port.getPartnerPort().getCircuitPackName()))
+ .findFirst();
+ if (!cpOpt.isPresent()) {
+ LOG.error("{} : Error fetching circuit-pack {}",
+ nodeId, port.getPartnerPort().getCircuitPackName());
+ return null;
+ }
+ Optional<Ports> poOpt = cpOpt.get().nonnullPorts().values().stream()
+ .filter(p -> p.getPortName().equals(port.getPartnerPort().getPortName().toString()))
+ .findFirst();
+ if (!poOpt.isPresent()) {
+ LOG.error("{} : Error fetching port {} on {}",
+ nodeId, port.getPartnerPort().getPortName(), port.getPartnerPort().getCircuitPackName());
+ return null;
+ }
+ Ports port2 = poOpt.get();
+ circuitPackName2.append(cpOpt.get().getCircuitPackName());
+ if (!checkPartnerPort(circuitPackName, port, port2)) {
+ LOG.error("{} : port {} on {} is not a correct partner port of {} on {}",
+ nodeId, port2.getPortName(), circuitPackName2, port.getPortName(), circuitPackName);
+ return null;
+ }
+ return port2;
+ }
+
+
+ private void putXpdrLcpsInMaps(int line, String nodeId,
+ Integer xponderNb, XpdrNodeTypes xponderType,
+ String circuitPackName, String circuitPackName2, Ports port, Ports port2,
+ Map<String, String> lcpMap, Map<String, Mapping> mappingMap) {
+ String lcp1 = createXpdrLogicalConnectionPort(xponderNb, line, StringConstants.NETWORK_TOKEN);
+ String lcp2 = createXpdrLogicalConnectionPort(xponderNb, line + 1, StringConstants.NETWORK_TOKEN);
+ if (lcpMap.containsKey(lcp1) || lcpMap.containsKey(lcp2)) {
+ LOG.warn("{} : mapping already exists for {} or {}", nodeId, lcp1, lcp2);
+ return;
+ }
+ lcpMap.put(circuitPackName + '+' + port.getPortName(), lcp1);
+ lcpMap.put(circuitPackName2 + '+' + port2.getPortName(), lcp2);
+ mappingMap.put(lcp1,
+ createXpdrMappingObject(nodeId, port, circuitPackName, lcp1, lcp2, null, null, xponderType));
+ mappingMap.put(lcp2,
+ createXpdrMappingObject(nodeId, port2, circuitPackName2, lcp2, lcp1, null, null, xponderType));
+ return;
+ }
+
+ private int[] fillXpdrLcpsMaps(int line, int client, String nodeId,
+ Integer xponderNb, XpdrNodeTypes xponderType,
+ String circuitPackName, Ports port,
+ List<CircuitPacks> circuitPackList, Map<String, String> lcpMap, Map<String, Mapping> mappingMap) {
+
+ if (port.getPortQual() == null) {
+ LOG.warn("{} : port {} on {} - PortQual was not found",
+ nodeId, port.getPortName(), circuitPackName);
+ return new int[] {line, client};
+ }
+
+ switch (port.getPortQual()) {
+
+ case XpdrClient:
+ case SwitchClient:
+ String lcp0 = createXpdrLogicalConnectionPort(xponderNb, client, StringConstants.CLIENT_TOKEN);
+ lcpMap.put(circuitPackName + '+' + port.getPortName(), lcp0);
+ mappingMap.put(lcp0,
+ createXpdrMappingObject(nodeId, port, circuitPackName, lcp0, null, null, null, null));
+ client++;
+ break;
+
+ case XpdrNetwork:
+ case SwitchNetwork:
+ line = fillXpdrNetworkLcpsMaps(line, nodeId,
+ xponderNb, xponderType,
+ circuitPackName, port,
+ circuitPackList, lcpMap, mappingMap);
+ break;
+
+ default:
+ LOG.error("{} : port {} on {} - unsupported PortQual {}",
+ nodeId, port.getPortName(), circuitPackName, port.getPortQual());
+ }
+ return new int[] {line, client};
+ }
+
+ private int fillXpdrNetworkLcpsMaps(int line, String nodeId,
+ Integer xponderNb, XpdrNodeTypes xponderType,
+ String circuitPackName, Ports port,
+ List<CircuitPacks> circuitPackList, Map<String, String> lcpMap, Map<String, Mapping> mappingMap) {
+
+ switch (port.getPortDirection()) {
+
+ case Bidirectional:
+ String lcp = createXpdrLogicalConnectionPort(xponderNb, line, StringConstants.NETWORK_TOKEN);
+ lcpMap.put(circuitPackName + '+' + port.getPortName(), lcp);
+ mappingMap.put(lcp,
+ createXpdrMappingObject(nodeId, port, circuitPackName, lcp, null, null, null, xponderType));
+ line++;
+ break;
+
+ case Rx:
+ case Tx:
+ StringBuilder circuitPackName2 = new StringBuilder();
+ Ports port2 = getPort2(port, nodeId, circuitPackName, circuitPackName2,
+ circuitPackList, lcpMap);
+
+ if (port2 == null) {
+ //key already present or an error occured and was logged
+ return line;
+ }
+
+ putXpdrLcpsInMaps(line, nodeId, xponderNb, xponderType,
+ circuitPackName, circuitPackName2.toString(), port, port2,
+ lcpMap, mappingMap);
+ line += 2;
+ break;
+
+ default:
+ LOG.error("{} : port {} on {} - unsupported Direction {}",
+ nodeId, port.getPortName(), circuitPackName, port.getPortDirection());
+ }
+
+ return line;
+ }
+
+ private boolean createMcCapabilitiesList(String nodeId, Info deviceInfo,
+ Map<McCapabilitiesKey, McCapabilities> mcCapabilitiesMap) {