futures.add(retryingTxRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> {
String vpnName = fibUtil.getVpnNameFromId(vpnInstance.getVpnId());
for (final VrfEntry vrfEntry : vrfTable.get().getVrfEntry()) {
+ /* parentRd is only filled for external PNF cases where the interface on the external
+ * network VPN are used to cleanup the flows. For all other cases, use "rd" for
+ * #fibUtil.isInterfacePresentInDpn().
+ * */
+ String parentRd = vrfEntry.getParentVpnRd() != null ? vrfEntry.getParentVpnRd()
+ : rd;
/* Handle subnet routes here */
SubnetRoute subnetRoute = vrfEntry.augmentation(SubnetRoute.class);
if (subnetRoute != null && !fibUtil
- .isInterfacePresentInDpn(vrfEntry.getParentVpnRd(), dpnId)) {
+ .isInterfacePresentInDpn(parentRd, dpnId)) {
LOG.trace("SUBNETROUTE: cleanUpDpnForVpn: Cleaning subnetroute {} on dpn {}"
+ " for vpn {}", vrfEntry.getDestPrefix(), dpnId, rd);
baseVrfEntryHandler.makeConnectedRoute(dpnId, vpnId, vrfEntry, rd, null,
TransactionAdapter.toWriteTransaction(tx), txnObjects);
} else {
if (subnetRoute == null || !fibUtil
- .isInterfacePresentInDpn(vrfEntry.getParentVpnRd(), dpnId)) {
+ .isInterfacePresentInDpn(parentRd, dpnId)) {
baseVrfEntryHandler.deleteRemoteRoute(null, dpnId, vpnId,
vrfTable.get().key(), vrfEntry, extraRouteOptional,
TransactionAdapter.toWriteTransaction(tx));
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
-import java.util.stream.Collectors;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.PreDestroy;
// read VPNMaps
VpnMap vpnMap = neutronvpnUtils.getVpnMap(vpnId);
List<RouterIds> routerIdsList = vpnMap != null ? vpnMap.getRouterIds() : null;
+ List<Uuid> routerUuidList = new ArrayList<>();
// dissociate router
if (routerIdsList != null && !routerIdsList.isEmpty()) {
- for (RouterIds routerId : routerIdsList) {
- dissociateRouterFromVpn(vpnId, routerId.getRouterId());
- }
- List<Uuid> rtrIdsList = routerIdsList.stream().map(routerId -> routerId.getRouterId())
- .collect(Collectors.toList());
- if (rtrIdsList.contains(vpnId) && vpnMap.getNetworkIds() != null) {
- // dissociate networks
- dissociateNetworksFromVpn(vpnId, vpnMap.getNetworkIds());
+ for (RouterIds router : routerIdsList) {
+ Uuid routerId = router.getRouterId();
+ routerUuidList.add(routerId);
+ dissociateRouterFromVpn(vpnId, routerId);
}
}
+ if (!routerUuidList.contains(vpnId) && vpnMap.getNetworkIds() != null) {
+ dissociateNetworksFromVpn(vpnId, vpnMap.getNetworkIds());
+ }
// remove entire vpnMaps node
deleteVpnMapsNode(vpnId);