ITM module sync-up
[genius.git] / itm / itm-impl / src / main / java / org / opendaylight / genius / itm / rpc / ItmManagerRpcService.java
index 50f702ec4f1837249ef0984558e3fd93483eaf57..a28cc91815609f6d03b6ac89e211cbf8930e90b9 100644 (file)
@@ -341,6 +341,10 @@ public class ItmManagerRpcService implements ItmRpcService {
             resultBld.withResult(output.build()) ;
         } else {
             List<DPNTEPsInfo> meshedDpnList = ItmUtils.getTunnelMeshInfo(dataBroker);
+            if(meshedDpnList == null){
+                LOG.error("There are no tunnel mesh info in config DS");
+                return Futures.immediateFuture(resultBld.build());
+            }
             // Look for external tunnels if not look for internal tunnel
             for (DPNTEPsInfo teps : meshedDpnList) {
                 TunnelEndPoints firstEndPt = teps.getTunnelEndPoints().get(0);
@@ -349,9 +353,7 @@ public class ItmManagerRpcService implements ItmRpcService {
                             TunnelList.class)
                             .child(InternalTunnel.class, new InternalTunnelKey(teps.getDPNID(), srcDpn, input.getTunnelType()));
 
-                    Optional<InternalTunnel>
-                            tnl =
-                            ItmUtils.read(LogicalDatastoreType.CONFIGURATION, path, dataBroker);
+                    Optional<InternalTunnel> tnl = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, path, dataBroker);
                     if (tnl != null && tnl.isPresent()) {
                         InternalTunnel tunnel = tnl.get();
                         GetInternalOrExternalInterfaceNameOutputBuilder
@@ -361,6 +363,8 @@ public class ItmManagerRpcService implements ItmRpcService {
                         resultBld = RpcResultBuilder.success();
                         resultBld.withResult(output.build());
                         break;
+                    }else{
+                        LOG.error("Tunnel not found for source DPN {} ans destination IP {}", srcDpn, dstIp);
                     }
                 }
             }
@@ -671,4 +675,29 @@ public class ItmManagerRpcService implements ItmRpcService {
         return Futures.immediateFuture(resultBld.build());
     }
 
+    @Override
+    public Future<RpcResult<IsDcgwPresentOutput>> isDcgwPresent(IsDcgwPresentInput input) {
+        RpcResultBuilder<IsDcgwPresentOutput> resultBld = RpcResultBuilder.success();
+
+        List<DcGatewayIp> dcGatewayIpList = ItmUtils.getDcGatewayIpList(dataBroker);
+        String dcgwIpStr = input.getDcgwIp();
+        IpAddress dcgwIpAddr = new IpAddress(dcgwIpStr.toCharArray());
+        long retVal;
+
+        if((dcGatewayIpList != null) &&
+                (!dcGatewayIpList.isEmpty()) &&
+                (dcGatewayIpList.contains(dcgwIpAddr))) {
+            //Match found
+            retVal = 1;
+            IsDcgwPresentOutputBuilder output = new IsDcgwPresentOutputBuilder().setRetVal(retVal);
+            resultBld.withResult(output.build());
+        } else {
+            //Match not found
+            retVal = 2;
+            IsDcgwPresentOutputBuilder output = new IsDcgwPresentOutputBuilder().setRetVal(retVal);
+            resultBld.withResult(output.build());
+        }
+        return Futures.immediateFuture(resultBld.build());
+    }
+
 }