import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import java.util.concurrent.Callable;
import java.util.concurrent.Future;
import javax.annotation.PostConstruct;
import org.opendaylight.netvirt.fibmanager.api.IFibManager;
import org.opendaylight.netvirt.vpnmanager.api.InterfaceUtils;
import org.opendaylight.netvirt.vpnmanager.api.VpnExtraRouteHelper;
+import org.opendaylight.netvirt.vpnmanager.api.VpnHelper;
import org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.VpnInterface;
import org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.vpn._interface.VpnInstanceNames;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
String intfName = null;
List<Uuid> subnetList = new ArrayList<>();
Map<Long, String> vpnIdRdMap = new HashMap<>();
+ Set<String> listVpnName = new HashSet<String>();
while (interfacelistIter.hasNext()) {
intfName = interfacelistIter.next();
VpnInterface vpnInterface =
VpnUtil.getConfiguredVpnInterface(dataBroker, intfName);
if (vpnInterface != null) {
+ listVpnName.addAll(VpnHelper
+ .getVpnInterfaceVpnInstanceNamesString(vpnInterface.getVpnInstanceNames()));
handleTunnelEventForDPNVpn(stateTunnelList, action, vpnIdRdMap,
tunnelAction, isTepDeletedOnDpn,
subnetList, TunnelEventProcessingMethod.POPULATESUBNETS,
for (Map.Entry<Long, String> entry : vpnIdRdMap.entrySet()) {
Long vpnId = entry.getKey();
rd = entry.getValue();
- if ((tunnelAction == TunnelAction.TUNNEL_EP_ADD)
- && (tunTypeVal == VpnConstants.ITMTunnelLocType.External.getValue())) {
+ if (tunnelAction == TunnelAction.TUNNEL_EP_ADD
+ && tunTypeVal == VpnConstants.ITMTunnelLocType.External.getValue()) {
fibManager.populateExternalRoutesOnDpn(srcDpnId, vpnId, rd, srcTepIp, destTepIp);
- } else if ((tunnelAction == TunnelAction.TUNNEL_EP_DELETE)
- && (tunTypeVal == VpnConstants.ITMTunnelLocType.External.getValue())) {
+ } else if (tunnelAction == TunnelAction.TUNNEL_EP_DELETE
+ && tunTypeVal == VpnConstants.ITMTunnelLocType.External.getValue()) {
fibManager.cleanUpExternalRoutesOnDpn(srcDpnId, vpnId, rd, srcTepIp, destTepIp);
}
}
-
- if (tunnelAction == TunnelAction.TUNNEL_EP_ADD) {
- for (Uuid subnetId : subnetList) {
- // Populate the List of subnets
- vpnSubnetRouteHandler.updateSubnetRouteOnTunnelUpEvent(subnetId, srcDpnId);
+ if (listVpnName.size() >= 1) {
+ if (tunnelAction == TunnelAction.TUNNEL_EP_ADD) {
+ for (Uuid subnetId : subnetList) {
+ // Populate the List of subnets
+ vpnSubnetRouteHandler.updateSubnetRouteOnTunnelUpEvent(subnetId, srcDpnId);
+ }
}
- }
-
- if ((tunnelAction == TunnelAction.TUNNEL_EP_DELETE) && isTepDeletedOnDpn) {
- for (Uuid subnetId : subnetList) {
- // Populate the List of subnets
- vpnSubnetRouteHandler.updateSubnetRouteOnTunnelDownEvent(subnetId, srcDpnId);
+ if ((tunnelAction == TunnelAction.TUNNEL_EP_DELETE) && isTepDeletedOnDpn) {
+ for (Uuid subnetId : subnetList) {
+ // Populate the List of subnets
+ vpnSubnetRouteHandler.updateSubnetRouteOnTunnelDownEvent(subnetId, srcDpnId);
+ }
}
}
} catch (RuntimeException e) {
if (method == TunnelEventProcessingMethod.POPULATESUBNETS) {
Optional<VpnInterfaceOpDataEntry> opVpnInterface = VpnUtil
.getVpnInterfaceOpDataEntry(dataBroker, intfName, vpnName);
- if (opVpnInterface.isPresent()) {
+ if (opVpnInterface.isPresent() && !opVpnInterface.get().isScheduledForRemove()) {
VpnInterfaceOpDataEntry vpnInterface = opVpnInterface.get();
jobCoordinator.enqueueJob("VPNINTERFACE-" + intfName,
new UpdateVpnInterfaceOnTunnelEvent(tunnelAction,
}
}
}
- //Iterate over the VpnId-to-Rd map.
- for (Map.Entry<Long, String> entry : vpnIdRdMap.entrySet()) {
- Long vpnId = entry.getKey();
- rd = entry.getValue();
- if (tunnelAction == TunnelAction.TUNNEL_EP_ADD
- && tunTypeVal == VpnConstants.ITMTunnelLocType.External.getValue()) {
- fibManager.populateExternalRoutesOnDpn(srcDpnId, vpnId, rd, srcTepIp, destTepIp);
- } else if (tunnelAction == TunnelAction.TUNNEL_EP_DELETE
- && tunTypeVal == VpnConstants.ITMTunnelLocType.External.getValue()) {
- fibManager.cleanUpExternalRoutesOnDpn(srcDpnId, vpnId, rd, srcTepIp, destTepIp);
- }
- }
-
- if (tunnelAction == TunnelAction.TUNNEL_EP_ADD) {
- for (Uuid subnetId : subnetList) {
- // Populate the List of subnets
- vpnSubnetRouteHandler.updateSubnetRouteOnTunnelUpEvent(subnetId, srcDpnId);
- }
- }
- if (tunnelAction == TunnelAction.TUNNEL_EP_DELETE && isTepDeletedOnDpn) {
- for (Uuid subnetId : subnetList) {
- // Populate the List of subnets
- vpnSubnetRouteHandler.updateSubnetRouteOnTunnelDownEvent(subnetId, srcDpnId);
- }
- }
}
private class UpdateVpnInterfaceOnTunnelEvent implements Callable {