+ private Ports getPartnerPort(Ports port, String circuitPackName, String nodeId) {
+ if (!checkPartnerPortNotNull(port)) {
+ LOG.info(PortMappingUtils.NO_VALID_PARTNERPORT_LOGMSG + PortMappingUtils.CANNOT_AS_LCP_LOGMSG,
+ nodeId, port.getPortName(), circuitPackName);
+ return null;
+ }
+ InstanceIdentifier<Ports> port2ID = InstanceIdentifier
+ .builderOfInherited(OrgOpenroadmDeviceData.class, OrgOpenroadmDevice.class)
+ .child(CircuitPacks.class, new CircuitPacksKey(port.getPartnerPort().getCircuitPackName()))
+ .child(Ports.class, new PortsKey(port.getPartnerPort().getPortName()))
+ .build();
+ Optional<Ports> port2Object = this.deviceTransactionManager
+ .getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, port2ID,
+ Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
+ if (port2Object.isEmpty()
+ || port2Object.get().getPortQual().getIntValue() != PortQual.RoadmExternal.getIntValue()) {
+ LOG.error(PortMappingUtils.NOT_CORRECT_PARTNERPORT_LOGMSG + PortMappingUtils.PARTNERPORT_GET_ERROR_LOGMSG,
+ nodeId, port.getPartnerPort().getPortName(), port.getPartnerPort().getCircuitPackName(),
+ port.getPortName(), circuitPackName);
+ return null;
+ }
+ Ports port2 = port2Object.get();
+ if (!checkPartnerPort(circuitPackName, port, port2)) {
+ LOG.error(PortMappingUtils.NOT_CORRECT_PARTNERPORT_LOGMSG + PortMappingUtils.PARTNERPORT_CONF_ERROR_LOGMSG,
+ nodeId, port2.getPortName(), port.getPartnerPort().getCircuitPackName(),
+ port.getPortName(), circuitPackName);
+ //TODO check if we really needed to increment portIndex in this condition
+ // if yes this block should not be in getPartnerPort and must move back to createPpPortMapping
+ return null;
+ }
+ return port2;
+ }
+
+ private List<Ports> getPortList(String circuitPackName, String nodeId) {
+ InstanceIdentifier<CircuitPacks> cpIID = InstanceIdentifier
+ .builderOfInherited(OrgOpenroadmDeviceData.class, OrgOpenroadmDevice.class)
+ .child(CircuitPacks.class, new CircuitPacksKey(circuitPackName))
+ .build();
+ Optional<CircuitPacks> circuitPackObject = this.deviceTransactionManager.getDataFromDevice(nodeId,
+ LogicalDatastoreType.OPERATIONAL, cpIID,
+ Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
+ if (circuitPackObject.isEmpty()) {
+ LOG.warn(PortMappingUtils.MISSING_CP_LOGMSG + PortMappingUtils.PORTMAPPING_IGNORE_LOGMSG,
+ nodeId, circuitPackName);
+ return new ArrayList<>();
+ }
+ if (circuitPackObject.get().getPorts() == null) {
+ LOG.warn(PortMappingUtils.NO_PORT_ON_CP_LOGMSG, nodeId, PortMappingUtils.FOUND, circuitPackName);
+ return new ArrayList<>();
+ }
+ return new ArrayList<>(circuitPackObject.get().nonnullPorts().values());
+ }
+