BUG 8930 - delete Op VPN interface when deleting external network 12/61512/3
authorVinh Nguyen <vinh.nguyen@hcl.com>
Thu, 10 Aug 2017 19:26:24 +0000 (12:26 -0700)
committerSam Hague <shague@redhat.com>
Thu, 21 Sep 2017 16:14:17 +0000 (16:14 +0000)
Op VPNInterafce is removed in VrfEntryListener when the last
adjacency for the VPNInterface is removed.
The problem is VPN interface for external network doesn't
have any adjacency nor VrfEntry.
As a result, when the external Vpn interface is removed
the Op VpnInstance is not removed as it should.

Fix: Delete the Op VPN interface in VpnInterfaceManager
if the VPN interface to be deleted doesn't have any adjacency

Change-Id: Ice4b9fcb0103c6aff25053cc5b3db3b01311be06
Signed-off-by: Vinh Nguyen <vinh.nguyen@hcl.com>
vpnservice/vpnmanager/vpnmanager-impl/src/main/java/org/opendaylight/netvirt/vpnmanager/VpnInterfaceManager.java

index e2a6dbf1c553e7810c2296aebb262a7d3e2af3be..1d0cb3d365f322ae5e714a5ac10011c78a429bb3 100755 (executable)
@@ -1226,7 +1226,7 @@ public class VpnInterfaceManager extends AsyncDataTreeChangeListenerBase<VpnInte
                 VpnUtil.scheduleVpnInterfaceForRemoval(dataBroker, interfaceName, dpId, vpnName, Boolean.TRUE,
                         null);
                 removeAdjacenciesFromVpn(dpId, lportTag, interfaceName, vpnOpInterface.getVpnInstanceName(),
-                        vpnId, writeConfigTxn, writeInvTxn, interfaceState);
+                        vpnId, writeConfigTxn, writeOperTxn, writeInvTxn, interfaceState);
                 if (interfaceManager.isExternalInterface(interfaceName)) {
                     processExternalVpnInterface(vpnOpInterface, vpnId, dpId, lportTag, writeInvTxn,
                             NwConstants.DEL_FLOW);
@@ -1249,6 +1249,7 @@ public class VpnInterfaceManager extends AsyncDataTreeChangeListenerBase<VpnInte
 
     private void removeAdjacenciesFromVpn(final BigInteger dpnId, final int lportTag, final String interfaceName,
                                           final String vpnName, final long vpnId, WriteTransaction writeConfigTxn,
+                                          final WriteTransaction writeOperTxn,
                                           final WriteTransaction writeInvTxn, Interface interfaceState) {
         //Read NextHops
         InstanceIdentifier<VpnInterface> identifier = VpnUtil.getVpnInterfaceIdentifier(interfaceName);
@@ -1345,6 +1346,10 @@ public class VpnInterfaceManager extends AsyncDataTreeChangeListenerBase<VpnInte
                     }
                 }
             }
+        } else {
+            // this vpn interface has no more adjacency left, so clean up the vpn interface from Operational DS
+            LOG.info("Clean up vpn interface {} from dpn {} to vpn {} list.", interfaceName, dpnId, primaryRd);
+            writeOperTxn.delete(LogicalDatastoreType.OPERATIONAL, identifier);
         }
     }