-
- private Integer getDegFromParentCP(NodeId nodeId, String interfaceName, String supportingCircuitPack) {
- InstanceIdentifier<CircuitPacks> circuitPackIID = InstanceIdentifier.create(OrgOpenroadmDevice.class)
- .child(CircuitPacks.class, new CircuitPacksKey(supportingCircuitPack));
- Optional<CircuitPacks> circuitPackObject = this.deviceTransactionManager.getDataFromDevice(nodeId.getValue(),
- LogicalDatastoreType.OPERATIONAL, circuitPackIID, Timeouts.DEVICE_READ_TIMEOUT,
- Timeouts.DEVICE_READ_TIMEOUT_UNIT);
- if (!circuitPackObject.isPresent()
- || (circuitPackObject.get().getParentCircuitPack().getCircuitPackName() == null)) {
- LOG.warn("Parent circuitpack not found for NodeId: {} and Interface: {}", nodeId, interfaceName);
- return null;
- }
- String parentCP = circuitPackObject.get().getParentCircuitPack().getCircuitPackName();
- CpToDegree cpToDegree = getCPtoDegreeMapping(nodeId, parentCP);
- if (cpToDegree == null) {
- LOG.error("CP to Degree mapping not found even with parent circuitpack for NodeID: {}" + "and Interface {}",
- nodeId, interfaceName);
- return null;
- } else {
- LOG.debug("CP to degree is {}", cpToDegree.getDegreeNumber());
- return cpToDegree.getDegreeNumber().intValue();
- }
- }
-
- private Integer getDegFromCP(NodeId nodeId, String interfaceName) {
- try {
- java.util.Optional<Interface> interfaceOpt = this.openRoadmInterfaces.getInterface(nodeId.getValue(),
- interfaceName);
- if (!interfaceOpt.isPresent()) {
- LOG.warn("Interface with {} on node {} was not found!", interfaceName, nodeId.getValue());
- return null;
- }
- String supportingCircuitPack = interfaceOpt.get().getSupportingCircuitPackName();
- LOG.debug("Supporting circuitpack name is :{}", interfaceOpt.get().getSupportingCircuitPackName());
- CpToDegree cpToDegree = getCPtoDegreeMapping(nodeId, supportingCircuitPack);
- // Currently devices have different ways to represent connection to Ethernet port
- // and degree port.
- // If Circuit pack is not present under degree tree then read parent CP of given
- // CP (Circuit pack).
- if (cpToDegree != null) {
- return cpToDegree.getDegreeNumber().intValue();
- } else {
- return getDegFromParentCP(nodeId, interfaceName, supportingCircuitPack);
- }
- } catch (OpenRoadmInterfaceException ex) {
- LOG.error("Failed to get source interface {} from node {}!", interfaceName, nodeId, ex);
- return null;
- }
- }