Fix for populating datastore properly 43/73643/4
authoreswanit <swati.udhavrao.niture@ericsson.com>
Mon, 2 Jul 2018 11:49:11 +0000 (17:19 +0530)
committerSam Hague <shague@redhat.com>
Mon, 9 Jul 2018 20:30:08 +0000 (20:30 +0000)
While updating used RDs, deletion of
extra-route was being performed on wrong
datastore, fixing this one by using operational
vpn interface op data.

Maintaining different transaction for config
extraroute-rds-map datastore.

Removing redundant delete of extra-route
from delAdjFromVpnInterface method since
it is already being taken care by remove
and update of FIB.

Change-Id: I04c4057501abb3c4010361c18da9688379fa70d4
Signed-off-by: eswanit <swati.udhavrao.niture@ericsson.com>
fibmanager/impl/src/main/java/org/opendaylight/netvirt/fibmanager/FibUtil.java
fibmanager/impl/src/main/java/org/opendaylight/netvirt/fibmanager/VrfEntryListener.java
vpnmanager/impl/src/main/java/org/opendaylight/netvirt/vpnmanager/VpnInterfaceManager.java

index 61fee1049dc37c5c0e4204c5fe84a06e1f29d412..26016541c8c0779ce6a07a036c990c0e97d4394d 100644 (file)
@@ -586,8 +586,8 @@ public class FibUtil {
         return "FIB-" + vpnId.toString() + "-" + dpnId.toString() ;
     }
 
-    public void updateUsedRdAndVpnToExtraRoute(WriteTransaction writeOperTxn, String tunnelIpRemoved, String primaryRd,
-            String prefix) {
+    public void updateUsedRdAndVpnToExtraRoute(WriteTransaction writeConfigTxn, WriteTransaction writeOperTxn,
+                                               String tunnelIpRemoved, String primaryRd, String prefix) {
         Optional<VpnInstanceOpDataEntry> optVpnInstance = getVpnInstanceOpData(primaryRd);
         if (!optVpnInstance.isPresent()) {
             return;
@@ -614,11 +614,14 @@ public class FibUtil {
                     //Delete datastore only if extra route is deleted or VM interface is deleted/down
                     if (!MDSALUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, adjId).isPresent()
                             || ifState == null || ifState.getOperStatus() == OperStatus.Down) {
+                        LOG.info("updating data-stores for prefix {} with primaryRd {} for interface {} on vpn {} ",
+                                prefix, primaryRd, prefixToInterface.getVpnInterfaceName(), vpnName);
                         writeOperTxn.delete(LogicalDatastoreType.OPERATIONAL,
-                                getAdjacencyIdentifier(prefixToInterface.getVpnInterfaceName(), prefix));
+                                FibUtil.getAdjacencyIdentifierOp(prefixToInterface.getVpnInterfaceName(),
+                                        vpnName, prefix));
                         writeOperTxn.delete(LogicalDatastoreType.OPERATIONAL,
                                 VpnExtraRouteHelper.getVpnToExtrarouteVrfIdIdentifier(vpnName, usedRd, prefix));
-                        writeOperTxn.delete(LogicalDatastoreType.CONFIGURATION,
+                        writeConfigTxn.delete(LogicalDatastoreType.CONFIGURATION,
                                 VpnExtraRouteHelper.getUsedRdsIdentifier(vpnId, prefix, nextHopRemoved));
                         break;
                     }
index 5d66993cf831a99135107f240a000fe3248eb28d..b1c513f75195539cde6c07ff8917953d0b98b518 100755 (executable)
@@ -326,11 +326,15 @@ public class VrfEntryListener extends AsyncDataTreeChangeListenerBase<VrfEntry,
             //Update the used rds and vpntoextraroute containers only for the deleted nextHops.
             List<String> nextHopsRemoved = FibHelper.getNextHopListFromRoutePaths(original);
             nextHopsRemoved.removeAll(FibHelper.getNextHopListFromRoutePaths(update));
-            ListenableFuture<Void> future =
-                    txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> nextHopsRemoved.parallelStream()
-                            .forEach(nextHopRemoved -> fibUtil.updateUsedRdAndVpnToExtraRoute(
-                                    tx, nextHopRemoved, rd, update.getDestPrefix())));
-            Futures.addCallback(future, new FutureCallback<Void>() {
+            List<ListenableFuture<Void>> futures = new ArrayList<>();
+            ListenableFuture<Void> configFuture =
+                    txRunner.callWithNewWriteOnlyTransactionAndSubmit(configTx ->
+                            futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(operTx ->
+                                    nextHopsRemoved.parallelStream()
+                                            .forEach(nextHopRemoved -> fibUtil.updateUsedRdAndVpnToExtraRoute(
+                                                    configTx, operTx, nextHopRemoved, rd, update.getDestPrefix())))));
+            futures.add(configFuture);
+            Futures.addCallback(configFuture, new FutureCallback<Void>() {
                 @Override
                 public void onSuccess(Void result) {
                     createFibEntries(identifier, update);
index 9c1f6c0e4fa71ae07de5bbb97695115a86afc579..33afa245e659deee104054f446ee1b56e225ee5c 100755 (executable)
@@ -1845,14 +1845,6 @@ public class VpnInterfaceManager extends AsyncDataTreeChangeListenerBase<VpnInte
                             Adjacency adjElem = adjIt.next();
                             if (adjElem.getIpAddress().equals(adj.getIpAddress())) {
                                 String rd = adjElem.getVrfId();
-                                adjIt.remove();
-                                AdjacenciesOp aug = VpnUtil.getVpnInterfaceOpDataEntryAugmentation(adjacencies);
-                                VpnInterfaceOpDataEntry newVpnIntf = VpnUtil
-                                        .getVpnInterfaceOpDataEntry(currVpnIntf.getName(),
-                                                currVpnIntf.getVpnInstanceName(), aug, dpnId,
-                                                currVpnIntf.isScheduledForRemove(), currVpnIntf.getLportTag(),
-                                                currVpnIntf.getGatewayMacAddress());
-                                writeOperTxn.merge(LogicalDatastoreType.OPERATIONAL, identifier, newVpnIntf, true);
                                 if (adj.getNextHopIpList() != null) {
                                     for (String nh : adj.getNextHopIpList()) {
                                         deleteExtraRouteFromCurrentAndImportingVpns(