Merge "Debug tool for openconfig proprietary extensions"
[transportpce.git] / inventory / src / main / java / org / opendaylight / transportpce / inventory / INode121.java
index bc185290114126cb3d59ca1fbb0bd32ab4013c84..def34d0e9eb0665543d0c36e200965f957b23da7 100644 (file)
@@ -13,6 +13,7 @@ import static org.opendaylight.transportpce.inventory.utils.StringUtils.getCurre
 import static org.opendaylight.transportpce.inventory.utils.StringUtils.prepareDashString;
 import static org.opendaylight.transportpce.inventory.utils.StringUtils.prepareEmptyString;
 
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import java.sql.Connection;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
@@ -26,6 +27,7 @@ import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 import org.opendaylight.transportpce.common.Timeouts;
 import org.opendaylight.transportpce.common.device.DeviceTransactionManager;
 import org.opendaylight.transportpce.inventory.query.Queries;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.OrgOpenroadmDeviceData;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.circuit.pack.CpSlots;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.circuit.pack.CpSlotsKey;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.circuit.pack.Ports;
@@ -82,7 +84,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-@edu.umd.cs.findbugs.annotations.SuppressFBWarnings(
+@SuppressFBWarnings(
     value = "SQL_PREPARED_STATEMENT_GENERATED_FROM_NONCONSTANT_STRING",
     justification = "TODO review the SQL statement generation process")
 public class INode121 {
@@ -99,7 +101,10 @@ public class INode121 {
 
     public boolean addNode(String deviceId) {
 
-        InstanceIdentifier<Info> infoIID = InstanceIdentifier.create(OrgOpenroadmDevice.class).child(Info.class);
+        InstanceIdentifier<Info> infoIID = InstanceIdentifier
+            .builderOfInherited(OrgOpenroadmDeviceData.class, OrgOpenroadmDevice.class)
+            .child(Info.class)
+            .build();
         Optional<Info> infoOpt =
                 deviceTransactionManager.getDataFromDevice(deviceId, LogicalDatastoreType.OPERATIONAL, infoIID,
                         Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
@@ -108,7 +113,7 @@ public class INode121 {
             LOG.warn("Could not get device info from DataBroker");
             return false;
         }
-        deviceInfo = infoOpt.get();
+        deviceInfo = infoOpt.orElseThrow();
         boolean sqlResult = false;
         String query = Queries.getQuery().deviceInfoInsert().get();
         LOG.info("Running {} query ", query);
@@ -198,14 +203,16 @@ public class INode121 {
     }
 
     public void getRoadmShelves(String nodeId) throws InterruptedException, ExecutionException {
-        InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
+        InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier
+            .builderOfInherited(OrgOpenroadmDeviceData.class, OrgOpenroadmDevice.class)
+            .build();
         Optional<OrgOpenroadmDevice> deviceObject = deviceTransactionManager.getDataFromDevice(nodeId,
                 LogicalDatastoreType.OPERATIONAL, deviceIID, Timeouts.DEVICE_READ_TIMEOUT,
                 Timeouts.DEVICE_READ_TIMEOUT_UNIT);
         if (!deviceObject.isPresent()) {
             return;
         }
-        Map<ShelvesKey, Shelves> shelvesMap = deviceObject.get().nonnullShelves();
+        Map<ShelvesKey, Shelves> shelvesMap = deviceObject.orElseThrow().nonnullShelves();
         LOG.info("Shelves size {}", shelvesMap.size());
         try (Connection connection = requireNonNull(dataSource.getConnection())) {
             for (Map.Entry<ShelvesKey, Shelves> shelveEntry : shelvesMap.entrySet()) {
@@ -227,7 +234,9 @@ public class INode121 {
     }
 
     public void getCircuitPacks(String nodeId) throws InterruptedException, ExecutionException {
-        InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
+        InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier
+            .builderOfInherited(OrgOpenroadmDeviceData.class, OrgOpenroadmDevice.class)
+            .build();
         Optional<OrgOpenroadmDevice> deviceObject =
                 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
                         Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
@@ -235,7 +244,7 @@ public class INode121 {
             LOG.warn("Device object {} was not found", nodeId);
             return;
         }
-        Map<CircuitPacksKey, CircuitPacks> circuitPacksMap = deviceObject.get().nonnullCircuitPacks();
+        Map<CircuitPacksKey, CircuitPacks> circuitPacksMap = deviceObject.orElseThrow().nonnullCircuitPacks();
         LOG.info("Circuit pack size {}", circuitPacksMap.size());
 
         try (Connection connection = requireNonNull(dataSource.getConnection())) {
@@ -722,7 +731,7 @@ public class INode121 {
 
         String name = deviceInterface.getName();
         String description = deviceInterface.getDescription();
-        String type = deviceInterface.getType().getTypeName();
+        String type = deviceInterface.getType().toString();
         String administrativeStateEnu = deviceInterface.getAdministrativeState().getName();
         int operationalState = deviceInterface.getOperationalState().getIntValue();
         String circuitId = deviceInterface.getCircuitId();
@@ -751,7 +760,7 @@ public class INode121 {
                     org.opendaylight.yang.gen.v1
                         .http.org.openroadm.optical.channel.interfaces.rev161014.Interface1.class)
                     .getOch());
-                ochRate = ochIfBuilder.getRate().getName();
+                ochRate = ochIfBuilder.getRate().toString();
                 ochWavelengthNumber = ochIfBuilder.getWavelengthNumber().toString();
                 ochModulationFormat = ochIfBuilder.getModulationFormat().getName();
                 ochTransmitPower = ochIfBuilder.getTransmitPower().toString();
@@ -802,7 +811,7 @@ public class INode121 {
                     new OtuBuilder(deviceInterface.augmentation(
                         org.opendaylight.yang.gen.v1.http.org.openroadm.otn.otu.interfaces.rev161014.Interface1.class)
                     .getOtu());
-                otuRate = otuIfBuilder.getRate().getName();
+                otuRate = otuIfBuilder.getRate().toString();
                 otuFecEnu = otuIfBuilder.getFec().getName();
                 otuMaintLoopbackEnabled = otuIfBuilder.getMaintLoopback().getEnabled().toString();
                 otuMaintTypeEnu = otuIfBuilder.getMaintLoopback().getType().getName();
@@ -962,7 +971,7 @@ public class INode121 {
     private static Object[] prepareDevInterfaceOtnOduTxMsiParameters(String nodeId, String interfaceName, TxMsi txMsi) {
 
         String tribSlot = txMsi.getTribSlot().toString();
-        String odtuType = txMsi.getOdtuType().getTypeName();
+        String odtuType = txMsi.getOdtuType().toString();
         String tribPort = txMsi.getTribPort().toString();
         String tribPortPayload = txMsi.getTribPortPayload();
 
@@ -983,7 +992,7 @@ public class INode121 {
     private static Object[] prepareDevInterfaceOtnOduRxMsiParameters(String nodeId, String interfaceName, RxMsi rxMsi) {
 
         String tribSlot = rxMsi.getTribSlot().toString();
-        String odtuType = rxMsi.getOdtuType().getTypeName();
+        String odtuType = rxMsi.getOdtuType().toString();
         String tribPort = rxMsi.getTribPort().toString();
         String tribPortPayload = rxMsi.getTribPortPayload();
 
@@ -1006,7 +1015,7 @@ public class INode121 {
         ExpMsi expMsi) {
 
         String tribSlot = expMsi.getTribSlot().toString();
-        String odtuType = expMsi.getOdtuType().getTypeName();
+        String odtuType = expMsi.getOdtuType().toString();
         String tribPort = expMsi.getTribPort().toString();
         String tribPortPayload = expMsi.getTribPortPayload();
 
@@ -1026,14 +1035,16 @@ public class INode121 {
 
     private void persistDevInterfaces(String nodeId, Connection connection) {
 
-        InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
+        InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier
+            .builderOfInherited(OrgOpenroadmDeviceData.class, OrgOpenroadmDevice.class)
+            .build();
         Optional<OrgOpenroadmDevice> deviceObject =
                 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
                         Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
         if (!deviceObject.isPresent()) {
             return;
         }
-        Map<InterfaceKey, Interface> interfaceMap = deviceObject.get().nonnullInterface();
+        Map<InterfaceKey, Interface> interfaceMap = deviceObject.orElseThrow().nonnullInterface();
         for (Map.Entry<InterfaceKey, Interface> interfaceEntrySet : interfaceMap.entrySet()) {
             Interface deviceInterface = interfaceEntrySet.getValue();
             Object[] parameters = prepareDevInterfaceParameters(nodeId, deviceInterface, connection);
@@ -1054,21 +1065,23 @@ public class INode121 {
 
     private void persistDevProtocols(String nodeId, Connection connection) {
 
-        InstanceIdentifier<Protocols> protocolsIID =
-                InstanceIdentifier.create(OrgOpenroadmDevice.class).child(Protocols.class);
+        InstanceIdentifier<Protocols> protocolsIID = InstanceIdentifier
+            .builderOfInherited(OrgOpenroadmDeviceData.class, OrgOpenroadmDevice.class)
+            .child(Protocols.class)
+            .build();
         Optional<Protocols> protocolObject =
                 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, protocolsIID,
                         Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
-        if (!protocolObject.isPresent() || protocolObject.get().augmentation(Protocols1.class) == null) {
+        if (!protocolObject.isPresent() || protocolObject.orElseThrow().augmentation(Protocols1.class) == null) {
             LOG.error("LLDP subtree is missing");
             return;
         }
-        String adminstatusEnu = protocolObject.get().augmentation(Protocols1.class).getLldp().getGlobalConfig()
+        String adminstatusEnu = protocolObject.orElseThrow().augmentation(Protocols1.class).getLldp().getGlobalConfig()
             .getAdminStatus().getName();
-        String msgTxtInterval = protocolObject.get().augmentation(Protocols1.class).getLldp().getGlobalConfig()
+        String msgTxtInterval = protocolObject.orElseThrow().augmentation(Protocols1.class).getLldp().getGlobalConfig()
             .getMsgTxInterval().toString();
-        String mxgTxHoldMultiplier = protocolObject.get().augmentation(Protocols1.class).getLldp().getGlobalConfig()
-            .getMsgTxHoldMultiplier().toString();
+        String mxgTxHoldMultiplier = protocolObject.orElseThrow().augmentation(Protocols1.class).getLldp()
+            .getGlobalConfig().getMsgTxHoldMultiplier().toString();
         String startTimestamp = getCurrentTimestamp();
         persistDevProtocolLldpPortConfig(nodeId, connection);
         persistDevProtocolLldpNbrList(nodeId, connection);
@@ -1097,18 +1110,20 @@ public class INode121 {
 
     private void persistDevProtocolLldpPortConfig(String nodeId, Connection connection) {
 
-        InstanceIdentifier<Protocols> protocolsIID =
-                InstanceIdentifier.create(OrgOpenroadmDevice.class).child(Protocols.class);
+        InstanceIdentifier<Protocols> protocolsIID = InstanceIdentifier
+            .builderOfInherited(OrgOpenroadmDeviceData.class, OrgOpenroadmDevice.class)
+            .child(Protocols.class)
+            .build();
         Optional<Protocols> protocolObject =
                 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, protocolsIID,
                         Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
-        if (!protocolObject.isPresent() || protocolObject.get().augmentation(Protocols1.class) == null) {
+        if (!protocolObject.isPresent() || protocolObject.orElseThrow().augmentation(Protocols1.class) == null) {
             LOG.error("LLDP subtree is missing");
             return;
         }
         String startTimestamp = getCurrentTimestamp();
         @NonNull
-        Map<PortConfigKey, PortConfig> portConfigMap = protocolObject.get()
+        Map<PortConfigKey, PortConfig> portConfigMap = protocolObject.orElseThrow()
             .augmentation(Protocols1.class).getLldp().nonnullPortConfig();
         for (Map.Entry<PortConfigKey, PortConfig> entry : portConfigMap.entrySet()) {
             PortConfig portConfig = entry.getValue();
@@ -1140,8 +1155,10 @@ public class INode121 {
 
     private void persistDevProtocolLldpNbrList(String nodeId, Connection connection) {
 
-        InstanceIdentifier<Protocols> protocolsIID =
-                InstanceIdentifier.create(OrgOpenroadmDevice.class).child(Protocols.class);
+        InstanceIdentifier<Protocols> protocolsIID = InstanceIdentifier
+            .builderOfInherited(OrgOpenroadmDeviceData.class, OrgOpenroadmDevice.class)
+            .child(Protocols.class)
+            .build();
         Optional<Protocols> protocolObject =
                 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, protocolsIID,
                         Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
@@ -1149,18 +1166,18 @@ public class INode121 {
             LOG.error("Protocols is missing");
             return;
         }
-        if (protocolObject.get().augmentation(Protocols1.class).getLldp().getNbrList() == null) {
+        if (protocolObject.orElseThrow().augmentation(Protocols1.class).getLldp().getNbrList() == null) {
             protocolObject =
                     deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, protocolsIID,
                             Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
-            if (protocolObject.get().augmentation(Protocols1.class).getLldp().getNbrList() == null) {
+            if (protocolObject.orElseThrow().augmentation(Protocols1.class).getLldp().getNbrList() == null) {
                 LOG.error("LLDP nbrlist subtree is missing for {}", nodeId);
                 return;
             }
         }
         String startTimestamp = getCurrentTimestamp();
         Map<IfNameKey, IfName> ifNameMap =
-                protocolObject.get().augmentation(Protocols1.class).getLldp().getNbrList().nonnullIfName();
+                protocolObject.orElseThrow().augmentation(Protocols1.class).getLldp().getNbrList().nonnullIfName();
         for (Map.Entry<IfNameKey, IfName> ifNameEntry : ifNameMap.entrySet()) {
 
             IfName ifNameObj = ifNameEntry.getValue();
@@ -1203,23 +1220,25 @@ public class INode121 {
 
     private void persistDevInternalLinks(String nodeId, Connection connection) {
 
-        InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
+        InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier
+            .builderOfInherited(OrgOpenroadmDeviceData.class, OrgOpenroadmDevice.class)
+            .build();
         Optional<OrgOpenroadmDevice> deviceObject =
                 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
                         Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
         if (!deviceObject.isPresent()) {
             return;
         }
-        if (deviceObject.get().getInternalLink() == null) {
+        if (deviceObject.orElseThrow().getInternalLink() == null) {
             deviceObject = deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION,
                     deviceIID, Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
-            if (deviceObject.get().getInternalLink() == null) {
+            if (deviceObject.orElseThrow().getInternalLink() == null) {
                 LOG.info("External links not found for {}", nodeId);
                 return;
             }
         }
         @NonNull
-        Map<InternalLinkKey, InternalLink> internalLinkMap = deviceObject.get().nonnullInternalLink();
+        Map<InternalLinkKey, InternalLink> internalLinkMap = deviceObject.orElseThrow().nonnullInternalLink();
         String startTimestamp = getCurrentTimestamp();
         for (Map.Entry<InternalLinkKey, InternalLink> internalLinkEntry: internalLinkMap.entrySet()) {
             InternalLink internalLink = internalLinkEntry.getValue();
@@ -1248,24 +1267,26 @@ public class INode121 {
 
     private void persistDevExternalLinks(String nodeId, Connection connection) {
 
-        InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
+        InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier
+            .builderOfInherited(OrgOpenroadmDeviceData.class, OrgOpenroadmDevice.class)
+            .build();
         Optional<OrgOpenroadmDevice> deviceObject =
                 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
                         Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
         if (!deviceObject.isPresent()) {
             return;
         }
-        if (deviceObject.get().getExternalLink() == null) {
+        if (deviceObject.orElseThrow().getExternalLink() == null) {
             deviceObject = deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION,
                     deviceIID, Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
-            if (deviceObject.get().getExternalLink() == null) {
+            if (deviceObject.orElseThrow().getExternalLink() == null) {
                 LOG.info("External links not found for {}", nodeId);
                 return;
             }
         }
         String startTimestamp = getCurrentTimestamp();
         @NonNull
-        Map<ExternalLinkKey, ExternalLink> externalLinkMap = deviceObject.get().nonnullExternalLink();
+        Map<ExternalLinkKey, ExternalLink> externalLinkMap = deviceObject.orElseThrow().nonnullExternalLink();
         for (Map.Entry<ExternalLinkKey, ExternalLink> externalLinkEntry: externalLinkMap.entrySet()) {
             ExternalLink externalLink = externalLinkEntry.getValue();
             String externalLinkName = externalLink.getExternalLinkName();
@@ -1296,7 +1317,9 @@ public class INode121 {
 
     private void persistDevPhysicalLinks(String nodeId, Connection connection) {
 
-        InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
+        InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier
+            .builderOfInherited(OrgOpenroadmDeviceData.class, OrgOpenroadmDevice.class)
+            .build();
         Optional<OrgOpenroadmDevice> deviceObject =
                 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
                         Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
@@ -1304,7 +1327,7 @@ public class INode121 {
             LOG.error("No device with node Id {}", nodeId);
             return;
         }
-        if (deviceObject.get().getPhysicalLink() == null) {
+        if (deviceObject.orElseThrow().getPhysicalLink() == null) {
             deviceObject =
                     deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, deviceIID,
                             Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
@@ -1312,7 +1335,7 @@ public class INode121 {
                 LOG.error("No device with node Id {}", nodeId);
                 return;
             }
-            if (deviceObject.get().getPhysicalLink() == null) {
+            if (deviceObject.orElseThrow().getPhysicalLink() == null) {
                 LOG.info("Physical links not found for {}", nodeId);
                 return;
             }
@@ -1320,7 +1343,7 @@ public class INode121 {
 
         String startTimestamp = getCurrentTimestamp();
         @NonNull
-        Map<PhysicalLinkKey, PhysicalLink> physicalLinkMap = deviceObject.get().nonnullPhysicalLink();
+        Map<PhysicalLinkKey, PhysicalLink> physicalLinkMap = deviceObject.orElseThrow().nonnullPhysicalLink();
         for (Map.Entry<PhysicalLinkKey, PhysicalLink> physicalLinkEntry : physicalLinkMap.entrySet()) {
             PhysicalLink physicalLink = physicalLinkEntry.getValue();
             String physicalLinkName = physicalLink.getPhysicalLinkName();
@@ -1356,7 +1379,9 @@ public class INode121 {
 
     private void persistDevDegree(String nodeId, Connection connection) {
 
-        InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
+        InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier
+            .builderOfInherited(OrgOpenroadmDeviceData.class, OrgOpenroadmDevice.class)
+            .build();
         Optional<OrgOpenroadmDevice> deviceObject =
                 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
                         Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
@@ -1373,7 +1398,7 @@ public class INode121 {
         }
         String startTimestamp = getCurrentTimestamp();
         @NonNull
-        Map<DegreeKey, Degree> degreeMap = deviceObject.get().nonnullDegree();
+        Map<DegreeKey, Degree> degreeMap = deviceObject.orElseThrow().nonnullDegree();
         for (Map.Entry<DegreeKey, Degree> degreeEntry : degreeMap.entrySet()) {
             Degree degree = degreeEntry.getValue();
             String degreeNumber = degree.getDegreeNumber().toString();
@@ -1487,7 +1512,9 @@ public class INode121 {
 
     private void persistDevSrg(String nodeId, Connection connection) {
 
-        InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
+        InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier
+            .builderOfInherited(OrgOpenroadmDeviceData.class, OrgOpenroadmDevice.class)
+            .build();
         Optional<OrgOpenroadmDevice> deviceObject =
                 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
                         Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
@@ -1496,7 +1523,7 @@ public class INode121 {
             return;
         }
 
-        if (deviceObject.get().getSharedRiskGroup() == null) {
+        if (deviceObject.orElseThrow().getSharedRiskGroup() == null) {
             deviceObject =
                     deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, deviceIID,
                             Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
@@ -1507,7 +1534,8 @@ public class INode121 {
         }
 
         @NonNull
-        Map<SharedRiskGroupKey, SharedRiskGroup> sharedRiskGroupMap = deviceObject.get().nonnullSharedRiskGroup();
+        Map<SharedRiskGroupKey, SharedRiskGroup> sharedRiskGroupMap = deviceObject.orElseThrow()
+            .nonnullSharedRiskGroup();
         if (sharedRiskGroupMap.isEmpty()) {
             LOG.info("no srg found for node {} ", nodeId);
             return;
@@ -1598,7 +1626,9 @@ public class INode121 {
 
         //int opticalcontrolmodeEnu=-1;
 
-        InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
+        InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier
+            .builderOfInherited(OrgOpenroadmDeviceData.class, OrgOpenroadmDevice.class)
+            .build();
         Optional<OrgOpenroadmDevice> deviceObject =
                 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
                         Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
@@ -1606,7 +1636,7 @@ public class INode121 {
             LOG.error("No device found in operational datastore for node {}", nodeId);
             return;
         }
-        if (deviceObject.get().getRoadmConnections() == null) {
+        if (deviceObject.orElseThrow().getRoadmConnections() == null) {
             deviceObject =
                     deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.CONFIGURATION, deviceIID,
                             Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
@@ -1617,7 +1647,8 @@ public class INode121 {
         }
 
         @NonNull
-        Map<RoadmConnectionsKey, RoadmConnections> connectionsMap = deviceObject.get().nonnullRoadmConnections();
+        Map<RoadmConnectionsKey, RoadmConnections> connectionsMap = deviceObject.orElseThrow()
+            .nonnullRoadmConnections();
         if (connectionsMap.isEmpty()) {
             LOG.info("ROADM Dev Connections not found!! for {}", nodeId);
             return;
@@ -1663,7 +1694,9 @@ public class INode121 {
 
     private void persistDevConnectionMap(String nodeId, Connection connection) {
 
-        InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
+        InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier
+            .builderOfInherited(OrgOpenroadmDeviceData.class, OrgOpenroadmDevice.class)
+            .build();
         Optional<OrgOpenroadmDevice> deviceObject =
                 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
                         Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
@@ -1673,7 +1706,7 @@ public class INode121 {
         }
         String startTimestamp = getCurrentTimestamp();
         @NonNull
-        Map<ConnectionMapKey, ConnectionMap> connectionsMap = deviceObject.get().nonnullConnectionMap();
+        Map<ConnectionMapKey, ConnectionMap> connectionsMap = deviceObject.orElseThrow().nonnullConnectionMap();
         for (Map.Entry<ConnectionMapKey, ConnectionMap> entry : connectionsMap.entrySet()) {
             ConnectionMap connectionMap = entry.getValue();
             String connectionMapNumber = connectionMap.getConnectionMapNumber().toString();
@@ -1706,7 +1739,9 @@ public class INode121 {
 
     private void persistDevWavelengthMap(String nodeId, Connection connection) {
 
-        InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
+        InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier
+            .builderOfInherited(OrgOpenroadmDeviceData.class, OrgOpenroadmDevice.class)
+            .build();
         Optional<OrgOpenroadmDevice> deviceObject =
                 deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIID,
                         Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
@@ -1717,7 +1752,8 @@ public class INode121 {
 
         String startTimestamp = getCurrentTimestamp();
         @NonNull
-        Map<WavelengthsKey, Wavelengths> wavelengthsMap = deviceObject.get().getWavelengthMap().nonnullWavelengths();
+        Map<WavelengthsKey, Wavelengths> wavelengthsMap = deviceObject.orElseThrow().getWavelengthMap()
+            .nonnullWavelengths();
         for (Map.Entry<WavelengthsKey, Wavelengths> entry : wavelengthsMap.entrySet()) {
             Wavelengths wavelengths = entry.getValue();
             String wavelengthNumber = wavelengths.getWavelengthNumber().toString();