- if (port.getLogicalConnectionPoint() != null && port.getPortQual().getIntValue() == 2) {
- String logicalConnectionPoint = null;
- if (port.getPortDirection().getIntValue() == 1) {
- // Port direction is transmit
- logicalConnectionPoint = port.getLogicalConnectionPoint() + "-TX";
- }
- if (port.getPortDirection().getIntValue() == 2) {
- // Port direction is receive
- logicalConnectionPoint = port.getLogicalConnectionPoint() + "-RX";
+ for (org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.srg.CircuitPacks cps : srgCps) {
+ String circuitPackName = cps.getCircuitPackName();
+ try {
+ InstanceIdentifier<CircuitPacks> cpIID = InstanceIdentifier.create(OrgOpenroadmDevice.class).child(
+ CircuitPacks.class, new CircuitPacksKey(circuitPackName));
+ Optional<CircuitPacks> circuitPackObject = rtx.read(LogicalDatastoreType.OPERATIONAL, cpIID).get();
+
+ if (circuitPackObject.isPresent()) {
+ CircuitPacks cp = circuitPackObject.get();
+ if (cp.getPorts() == null) {
+ LOG.warn("No port found for {} {}", deviceInfo.getNodeId(), circuitPackName);
+ } else if (!cp.getPorts().isEmpty()) {
+ for (Ports port : cp.getPorts()) {
+
+ if (port.getLogicalConnectionPoint() != null && port.getPortQual().getIntValue() == 2) {
+ String logicalConnectionPoint = null;
+ if (port.getPortDirection().getIntValue() == 1) {
+ // Port direction is transmit
+ if (!port.getLogicalConnectionPoint().contains("SRG")) {
+ logicalConnectionPoint = "SRG" + srgCounter + "-" + port
+ .getLogicalConnectionPoint() + "-TX";
+ } else {
+ logicalConnectionPoint = port.getLogicalConnectionPoint() + "-TX";
+ }
+ }
+ if (port.getPortDirection().getIntValue() == 2) {
+ // Port direction is receive
+ if (!port.getLogicalConnectionPoint().contains("SRG")) {
+ logicalConnectionPoint = "SRG" + srgCounter + "-" + port
+ .getLogicalConnectionPoint() + "-RX";
+ } else {
+ logicalConnectionPoint = port.getLogicalConnectionPoint() + "-RX";
+ }
+ }
+ if (port.getPortDirection().getIntValue() == 3) {
+ // port is bi-directional
+ if (!port.getLogicalConnectionPoint().contains("SRG")) {
+ logicalConnectionPoint = "SRG" + srgCounter + "-" + port
+ .getLogicalConnectionPoint() + "-TXRX";
+ } else {
+ logicalConnectionPoint = port.getLogicalConnectionPoint() + "-TXRX";
+ }
+ }
+
+ LOG.info("Logical Connection Point for {} {} is {}", circuitPackName, port
+ .getPortName(), logicalConnectionPoint);
+
+ portMapList.add(createMappingObject(port, circuitPackName, logicalConnectionPoint,
+ deviceDb));
+
+ } else if (port.getPortQual().getIntValue() == 1) {
+
+ LOG.info("Port is internal, skipping Logical Connection Point missing for "
+ + circuitPackName + " " + port.getPortName());
+
+ } else if (port.getLogicalConnectionPoint() == null) {
+
+ LOG.info("Value missing, Skipping Logical Connection Point missing for {} {}",
+ circuitPackName, port.getPortName());