Merge "Added RPC for getFIxedIPsforNeutronPort + additional -ve validations for RPCs...
[vpnservice.git] / fibmanager / fibmanager-impl / src / main / java / org / opendaylight / vpnservice / fibmanager / NexthopManager.java
index 83c6feb93a176d51d3c757b9496ab8ea9632e893..f82a3e6ecba39e83fe3b3289ff1d212b3d56c1fe 100644 (file)
@@ -83,6 +83,7 @@ public class NexthopManager implements AutoCloseable {
     private static final short FIB_TABLE = 21;
     private static final short DEFAULT_FLOW_PRIORITY = 10;
     private static final String NEXTHOP_ID_POOL_NAME = "nextHopPointerPool";
+    private static final long FIXED_DELAY_IN_MILLISECONDS = 4000;
 
     private static final FutureCallback<Void> DEFAULT_CALLBACK =
         new FutureCallback<Void>() {
@@ -285,8 +286,7 @@ public class NexthopManager implements AutoCloseable {
                 addVpnNexthopToDS(dpnId, vpnId, ipAddress, groupId);
 
                 // install Group
-                // FIXME: mdsalManager.syncInstallGroup(groupEntity);
-                mdsalManager.installGroup(groupEntity);
+                mdsalManager.syncInstallGroup(groupEntity, FIXED_DELAY_IN_MILLISECONDS);
 
             } else {
                 //nexthop exists already; a new flow is going to point to it, increment the flowrefCount by 1
@@ -362,11 +362,13 @@ public class NexthopManager implements AutoCloseable {
                   localDpnId, remoteDpnId, vpnId, prefixIp, nextHopIp);
 
         LOG.trace("getRemoteNextHopPointer: Calling ITM with localDpnId {} ", localDpnId);
-        try{
-            // here use the config for tunnel type param
-            tunnelIfName = getTunnelInterfaceName(remoteDpnId, IpAddressBuilder.getDefaultInstance(nextHopIp));
-        }catch(Exception ex){
-            LOG.error("Error while retrieving nexthop pointer for DC Gateway : ", ex.getMessage());
+        if (nextHopIp != null && !nextHopIp.isEmpty()) {
+            try{
+                // here use the config for tunnel type param
+                tunnelIfName = getTunnelInterfaceName(remoteDpnId, IpAddressBuilder.getDefaultInstance(nextHopIp));
+            }catch(Exception ex){
+            LOG.error("Error while retrieving nexthop pointer for nexthop {} : ", nextHopIp, ex.getMessage());
+            }
         }
         return tunnelIfName;
     }
@@ -401,7 +403,6 @@ public class NexthopManager implements AutoCloseable {
                     GroupEntity groupEntity = MDSALUtil.buildGroupEntity(
                             dpnId, nh.getEgressPointer(), ipAddress, GroupTypes.GroupIndirect, null);
                     // remove Group ...
-                    // FIXME: mdsalManager.syncRemoveGroup(groupEntity);
                     mdsalManager.removeGroup(groupEntity);
                     //update MD-SAL DS
                     removeVpnNexthopFromDS(vpnId, ipAddress);
@@ -463,4 +464,10 @@ public class NexthopManager implements AutoCloseable {
             .child(VpnInterface.class, new VpnInterfaceKey(vpnInterfaceName)).augmentation(
                 Adjacencies.class).child(Adjacency.class, new AdjacencyKey(ipAddress)).build();
     }
+
+    InstanceIdentifier<Adjacencies> getAdjListPath(String vpnInterfaceName) {
+        return InstanceIdentifier.builder(VpnInterfaces.class)
+                .child(VpnInterface.class, new VpnInterfaceKey(vpnInterfaceName)).augmentation(
+                        Adjacencies.class).build();
+    }
 }