package org.opendaylight.netvirt.vpnmanager;
import static java.util.Collections.emptyList;
-import static org.opendaylight.controller.md.sal.binding.api.WriteTransaction.CREATE_MISSING_PARENTS;
import static org.opendaylight.genius.infra.Datastore.CONFIGURATION;
import static org.opendaylight.genius.infra.Datastore.OPERATIONAL;
-import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import com.google.common.collect.Iterators;
import com.google.common.util.concurrent.FutureCallback;
import java.util.List;
import java.util.Map;
import java.util.Objects;
+import java.util.Optional;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.function.Consumer;
import java.util.function.Predicate;
import java.util.stream.Collectors;
-import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.eclipse.jdt.annotation.Nullable;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
-import org.opendaylight.genius.datastoreutils.AsyncDataTreeChangeListenerBase;
import org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker;
import org.opendaylight.genius.infra.Datastore.Configuration;
import org.opendaylight.genius.infra.Datastore.Operational;
import org.opendaylight.genius.infra.ManagedNewTransactionRunner;
import org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl;
-import org.opendaylight.genius.infra.TransactionAdapter;
import org.opendaylight.genius.infra.TypedReadWriteTransaction;
import org.opendaylight.genius.infra.TypedWriteTransaction;
import org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager;
import org.opendaylight.genius.utils.JvmGlobalLocks;
import org.opendaylight.infrautils.caches.CacheProvider;
import org.opendaylight.infrautils.jobcoordinator.JobCoordinator;
+import org.opendaylight.infrautils.utils.concurrent.Executors;
import org.opendaylight.infrautils.utils.concurrent.ListenableFutures;
+import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.mdsal.common.api.TransactionCommitFailedException;
import org.opendaylight.netvirt.bgpmanager.api.IBgpManager;
import org.opendaylight.netvirt.fibmanager.api.FibHelper;
import org.opendaylight.netvirt.fibmanager.api.IFibManager;
import org.opendaylight.netvirt.vpnmanager.populator.input.L3vpnInput;
import org.opendaylight.netvirt.vpnmanager.populator.intfc.VpnPopulator;
import org.opendaylight.netvirt.vpnmanager.populator.registry.L3vpnRegistry;
-import org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.VpnInterfaces;
-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.VpnInterfaceKey;
-import org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.vpn._interface.VpnInstanceNames;
+import org.opendaylight.serviceutils.tools.listener.AbstractAsyncDataTreeChangeListener;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.IdManagerService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.label.route.map.LabelRouteInfoBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.label.route.map.LabelRouteInfoKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.Adjacencies;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.AdjacenciesOp;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.NeutronRouterDpns;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.VpnInstanceOpData;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.adjacency.list.Adjacency;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.adjacency.list.Adjacency.AdjacencyType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.adjacency.list.AdjacencyBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.learnt.vpn.vip.to.port.data.LearntVpnVipToPort;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.neutron.router.dpns.RouterDpnList;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.neutron.router.dpns.RouterDpnListKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnList;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.vpntargets.VpnTarget;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ext.routers.Routers;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ext.routers.routers.ExternalIps;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.external.subnets.Subnets;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.Adjacencies;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.VpnInterfaces;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.adjacency.list.Adjacency;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.adjacency.list.Adjacency.AdjacencyType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.adjacency.list.AdjacencyBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.adjacency.list.AdjacencyKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.interfaces.VpnInterface;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.interfaces.VpnInterfaceKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.interfaces.vpn._interface.VpnInstanceNames;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.NetworkAttributes.NetworkType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.neutron.vpn.portip.port.data.VpnPortipToPort;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.LoggerFactory;
@Singleton
-public class VpnInterfaceManager extends AsyncDataTreeChangeListenerBase<VpnInterface, VpnInterfaceManager> {
+public class VpnInterfaceManager extends AbstractAsyncDataTreeChangeListener<VpnInterface> {
private static final Logger LOG = LoggerFactory.getLogger(VpnInterfaceManager.class);
private static final short DJC_MAX_RETRIES = 3;
final JobCoordinator jobCoordinator,
final CacheProvider cacheProvider,
final VpnUtil vpnUtil) {
- super(VpnInterface.class, VpnInterfaceManager.class);
+ super(dataBroker, LogicalDatastoreType.CONFIGURATION,
+ InstanceIdentifier.create(VpnInterfaces.class).child(VpnInterface.class),
+ Executors.newListeningSingleThreadExecutor("VpnInterfaceManager", LOG));
this.dataBroker = dataBroker;
this.txRunner = new ManagedNewTransactionRunnerImpl(dataBroker);
vpnInstanceOpDataEntryCache = new InstanceIdDataObjectCache<>(VpnInstanceOpDataEntry.class, dataBroker,
LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.builder(
VpnInstanceOpData.class).child(VpnInstanceOpDataEntry.class).build(), cacheProvider);
+ start();
}
public Runnable isNotifyTaskQueued(String intfName) {
return vpnIntfMap.remove(intfName);
}
- @PostConstruct
public void start() {
LOG.info("{} start", getClass().getSimpleName());
- registerListener(LogicalDatastoreType.CONFIGURATION, dataBroker);
}
@Override
public void close() {
super.close();
vpnInstanceOpDataEntryCache.close();
- }
-
- @Override
- protected InstanceIdentifier<VpnInterface> getWildCardPath() {
- return InstanceIdentifier.create(VpnInterfaces.class).child(VpnInterface.class);
- }
-
- @Override
- protected VpnInterfaceManager getDataTreeChangeListener() {
- return VpnInterfaceManager.this;
+ Executors.shutdownAndAwaitTermination(getExecutorService());
}
@Override
public void add(final InstanceIdentifier<VpnInterface> identifier, final VpnInterface vpnInterface) {
LOG.trace("Received VpnInterface add event: vpnInterface={}", vpnInterface);
LOG.info("add: intfName {} onto vpnName {}", vpnInterface.getName(),
- VpnHelper.getVpnInterfaceVpnInstanceNamesString(vpnInterface.getVpnInstanceNames()));
+ VpnHelper.getVpnInterfaceVpnInstanceNamesString(
+ new ArrayList<VpnInstanceNames>(vpnInterface.getVpnInstanceNames().values())));
addVpnInterface(identifier, vpnInterface, null, null);
}
@SuppressWarnings("checkstyle:IllegalCatch")
private void addVpnInterface(final InstanceIdentifier<VpnInterface> identifier, final VpnInterface vpnInterface,
final @Nullable List<Adjacency> oldAdjs, final @Nullable List<Adjacency> newAdjs) {
- for (VpnInstanceNames vpnInterfaceVpnInstance : vpnInterface.nonnullVpnInstanceNames()) {
+ for (VpnInstanceNames vpnInterfaceVpnInstance : vpnInterface.nonnullVpnInstanceNames().values()) {
String vpnName = vpnInterfaceVpnInstance.getVpnName();
addVpnInterfaceCall(identifier, vpnInterface, oldAdjs, newAdjs, vpnName);
}
Optional<Adjacencies> optAdjacencies = SingleTransactionDataBroker.syncReadOptional(dataBroker,
LogicalDatastoreType.CONFIGURATION, path);
if (!optAdjacencies.isPresent()) {
- LOG.trace("No config adjacencies present for vpninterface {}", vpnInterface);
+ LOG.trace("No config adjacencyKeyAdjacencyMap present for vpninterface {}", vpnInterface);
return;
}
- List<Adjacency> adjacencies = optAdjacencies.get().nonnullAdjacency();
- for (Adjacency adjacency : adjacencies) {
+ Map<AdjacencyKey, Adjacency> adjacencyKeyAdjacencyMap = optAdjacencies.get().nonnullAdjacency();
+ for (Adjacency adjacency : adjacencyKeyAdjacencyMap.values()) {
if (adjacency.getAdjacencyType() == AdjacencyType.PrimaryAdjacency) {
continue;
}
addNewAdjToVpnInterface(vpnInterfaceOpIdentifier, primaryRd, adjacency,
dpId, writeOperTxn, writeConfigTxn, writeInvTxn, prefixListForRefreshFib);
}
- } catch (ReadFailedException e) {
+ } catch (InterruptedException | ExecutionException e) {
LOG.error("processVpnInterfaceUp: Failed to read data store for interface {} vpn {} rd {} dpn {}",
interfaceName, vpnName, primaryRd, dpId);
}
if (router != null) {
if (addOrRemove == NwConstants.ADD_FLOW) {
vpnManager.addArpResponderFlowsToExternalNetworkIps(routerName,
- VpnUtil.getIpsListFromExternalIps(router.getExternalIps()), router.getExtGwMacAddress(),
+ VpnUtil.getIpsListFromExternalIps(new ArrayList<ExternalIps>(router
+ .getExternalIps().values())), router.getExtGwMacAddress(),
dpId, interfaceName, lportTag);
} else {
vpnManager.removeArpResponderFlowsToExternalNetworkIps(routerName,
- VpnUtil.getIpsListFromExternalIps(router.getExternalIps()),
+ VpnUtil.getIpsListFromExternalIps(new ArrayList<ExternalIps>(router
+ .getExternalIps().values())),
dpId, interfaceName, lportTag);
}
} else {
Optional<AdjacenciesOp> adjacencies = SingleTransactionDataBroker.syncReadOptional(dataBroker,
LogicalDatastoreType.OPERATIONAL, path);
if (adjacencies.isPresent()) {
- List<Adjacency> nextHops = adjacencies.get().getAdjacency();
- if (nextHops != null && !nextHops.isEmpty()) {
+ Map<AdjacencyKey, Adjacency> nextHopsMap = adjacencies.get().getAdjacency();
+ if (nextHopsMap != null && !nextHopsMap.isEmpty()) {
LOG.debug("advertiseAdjacenciesForVpnToBgp: NextHops are {} for interface {} on dpn {} for vpn {}"
- + " rd {}", nextHops, interfaceName, dpnId, vpnName, rd);
+ + " rd {}", nextHopsMap, interfaceName, dpnId, vpnName, rd);
VpnInstanceOpDataEntry vpnInstanceOpData = vpnUtil.getVpnInstanceOpData(rd);
Uint32 l3vni = vpnInstanceOpData.getL3vni();
VrfEntry.EncapType encapType = VpnUtil.isL3VpnOverVxLan(l3vni)
? VrfEntry.EncapType.Vxlan : VrfEntry.EncapType.Mplsgre;
- for (Adjacency nextHop : nextHops) {
+ for (Adjacency nextHop : nextHopsMap.values()) {
if (nextHop.getAdjacencyType() == AdjacencyType.ExtraRoute) {
continue;
}
}
}
}
- } catch (ReadFailedException e) {
+ } catch (InterruptedException | ExecutionException e) {
LOG.error("advertiseAdjacenciesForVpnToBgp: Failed to read data store for interface {} dpn {} nexthop {}"
+ "vpn {} rd {}", interfaceName, dpnId, nextHopIp, vpnName, rd);
}
}
LOG.info("withdrawAdjacenciesForVpnFromBgp: For interface {} in vpn {} with rd {}", interfaceName,
vpnName, rd);
- Optional<AdjacenciesOp> adjacencies = Optional.absent();
+ Optional<AdjacenciesOp> adjacencies = Optional.empty();
try {
adjacencies = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.OPERATIONAL,
path);
- } catch (ReadFailedException e) {
+ } catch (InterruptedException | ExecutionException e) {
LOG.error("withdrawAdjacenciesForVpnFromBgp: Failed to read data store for interface {} vpn {}",
interfaceName, vpnName);
}
if (adjacencies.isPresent()) {
- List<Adjacency> nextHops = adjacencies.get().getAdjacency();
+ Map<AdjacencyKey, Adjacency> nextHopsMap = adjacencies.get().getAdjacency();
- if (nextHops != null && !nextHops.isEmpty()) {
+ if (nextHopsMap != null && !nextHopsMap.isEmpty()) {
LOG.trace("withdrawAdjacenciesForVpnFromBgp: NextHops are {} for interface {} in vpn {} rd {}",
- nextHops, interfaceName, vpnName, rd);
- for (Adjacency nextHop : nextHops) {
+ nextHopsMap, interfaceName, vpnName, rd);
+ for (Adjacency nextHop : nextHopsMap.values()) {
try {
if (nextHop.getAdjacencyType() != AdjacencyType.ExtraRoute) {
LOG.info("VPN WITHDRAW: withdrawAdjacenciesForVpnFromBgp: Removing Fib Entry rd {}"
throws ExecutionException, InterruptedException {
InstanceIdentifier<VpnInterface> identifier = VpnUtil.getVpnInterfaceIdentifier(interfaceName);
// Read NextHops
- Optional<VpnInterface> vpnInteface = Optional.absent();
+ Optional<VpnInterface> vpnInteface = Optional.empty();
try {
vpnInteface = SingleTransactionDataBroker.syncReadOptional(dataBroker,
LogicalDatastoreType.CONFIGURATION, identifier);
- } catch (ReadFailedException e) {
+ } catch (InterruptedException | ExecutionException e) {
LOG.error("processVpnInterfaceAdjacencies: Failed to read data store for interface {} vpn {} rd {}"
+ "dpn {}", interfaceName, vpnName, primaryRd, dpnId);
}
LOG.debug("processVpnInterfaceAdjacencies: NextHop for interface {} on dpn {} in vpn {} is {}",
interfaceName, dpnId, vpnName, nhList);
}
- Optional<String> gwMac = Optional.absent();
+ Optional<String> gwMac = Optional.empty();
String vpnInterfaceSubnetGwMacAddress = null;
VpnInstanceOpDataEntry vpnInstanceOpData = vpnUtil.getVpnInstanceOpData(primaryRd);
Uint32 l3vni = vpnInstanceOpData.getL3vni() != null ? vpnInstanceOpData.getL3vni() : Uint32.ZERO;
boolean isL3VpnOverVxLan = VpnUtil.isL3VpnOverVxLan(l3vni);
VrfEntry.EncapType encapType = isL3VpnOverVxLan ? VrfEntry.EncapType.Vxlan : VrfEntry.EncapType.Mplsgre;
VpnPopulator registeredPopulator = L3vpnRegistry.getRegisteredPopulator(encapType);
- List<Adjacency> nextHops = adjacencies != null ? adjacencies.getAdjacency() : emptyList();
+ Map<AdjacencyKey, Adjacency> nextHopsMap = adjacencies != null ? adjacencies.getAdjacency()
+ : Collections.<AdjacencyKey, Adjacency>emptyMap();
List<Adjacency> value = new ArrayList<>();
- for (Adjacency nextHop : nextHops) {
+ for (Adjacency nextHop : nextHopsMap.values()) {
String rd = primaryRd;
String nexthopIpValue = nextHop.getIpAddress().split("/")[0];
if (vpnInstanceOpData.getBgpvpnType() == VpnInstanceOpDataEntry.BgpvpnType.BGPVPNInternet
String prefix = VpnUtil.getIpPrefix(nextHop.getIpAddress());
Prefixes.PrefixCue prefixCue = nextHop.isPhysNetworkFunc()
? Prefixes.PrefixCue.PhysNetFunc : Prefixes.PrefixCue.None;
- LOG.debug("processVpnInterfaceAdjacencies: Adding prefix {} to interface {} with nextHops {} on dpn {}"
- + " for vpn {}", prefix, interfaceName, nhList, dpnId, vpnName);
+ LOG.debug("processVpnInterfaceAdjacencies: Adding prefix {} to interface {} with nextHopsMap {} "
+ + "on dpn {} for vpn {}", prefix, interfaceName, nhList, dpnId, vpnName);
Prefixes prefixes = intfnetworkUuid != null
? VpnUtil.getPrefixToInterface(dpnId, interfaceName, prefix, intfnetworkUuid ,networkType,
segmentationId, prefixCue) :
VpnUtil.getPrefixToInterface(dpnId, interfaceName, prefix, prefixCue);
- writeOperTxn.merge(VpnUtil.getPrefixToInterfaceIdentifier(
- vpnUtil.getVpnId(vpnName), prefix), prefixes, true);
+ writeOperTxn.mergeParentStructureMerge(VpnUtil.getPrefixToInterfaceIdentifier(
+ vpnUtil.getVpnId(vpnName), prefix), prefixes);
final Uuid subnetId = nextHop.getSubnetId();
gatewayIp = nextHop.getSubnetGatewayIp();
subnetId, interfaceName, vpnName);
gwMac = InterfaceUtils.getMacAddressFromInterfaceState(interfaceState);
}
- LOG.info("processVpnInterfaceAdjacencies: Added prefix {} to interface {} with nextHops {} on dpn {}"
+ LOG.info("processVpnInterfaceAdjacencies: Added prefix {} to interface {} with nextHopsMap {} on dpn {}"
+ " for vpn {}", prefix, interfaceName, nhList, dpnId, vpnName);
} else {
//Extra route adjacency
gwMac.isPresent() ? gwMac.get() : null, gatewayIp, writeOperTxn);
L3vpnInput input = new L3vpnInput().setNextHopIp(nextHopIp).setL3vni(l3vni.longValue()).setPrimaryRd(primaryRd)
- .setGatewayMac(gwMac.orNull()).setInterfaceName(interfaceName)
+ .setGatewayMac(gwMac.orElse(null)).setInterfaceName(interfaceName)
.setVpnName(vpnName).setDpnId(dpnId).setEncapType(encapType);
- for (Adjacency nextHop : aug.getAdjacency()) {
+ for (Adjacency nextHop : aug.getAdjacency().values()) {
// Adjacencies other than primary Adjacencies are handled in the addExtraRoute call above.
if (nextHop.getAdjacencyType() == AdjacencyType.PrimaryAdjacency) {
RouteOrigin origin = VpnUtil.getRouteOrigin(nextHop.getAdjacencyType());
VpnUtil.getVpnInterfaceOpDataEntry(interfaceName, vpnName, aug, dpnId, lportTag, gwMac, gwIp);
InstanceIdentifier<VpnInterfaceOpDataEntry> interfaceId = VpnUtil
.getVpnInterfaceOpDataEntryIdentifier(interfaceName, vpnName);
- writeOperTxn.put(interfaceId, opInterface, CREATE_MISSING_PARENTS);
+ writeOperTxn.mergeParentStructurePut(interfaceId, opInterface);
LOG.info("addVpnInterfaceToOperational: Added VPN Interface {} on dpn {} vpn {} to operational datastore",
interfaceName, dpnId, vpnName);
}
String srcTepIp = stateTunnelList.getSrcInfo().getTepIp().stringValue();
Uint64 srcDpnId = Uint64.valueOf(stateTunnelList.getSrcInfo().getTepDeviceId()).intern();
AdjacenciesOp adjacencies = vpnInterface.augmentation(AdjacenciesOp.class);
- List<Adjacency> adjList =
- adjacencies != null && adjacencies.getAdjacency() != null ? adjacencies.getAdjacency() : emptyList();
- if (adjList.isEmpty()) {
+ Map<AdjacencyKey, Adjacency> keyAdjacencyMap =
+ adjacencies != null && adjacencies.getAdjacency() != null ? adjacencies.getAdjacency()
+ : Collections.<AdjacencyKey, Adjacency>emptyMap();
+ if (keyAdjacencyMap.isEmpty()) {
LOG.trace("updateVpnInterfaceOnTepAdd: Adjacencies are empty for vpnInterface {} on dpn {}",
vpnInterface, srcDpnId);
return;
}
String prefix = null;
List<Adjacency> value = new ArrayList<>();
- boolean isNextHopAddReqd = false;
+ boolean isFibNextHopAddReqd = false;
String vpnName = vpnInterface.getVpnInstanceName();
Uint32 vpnId = vpnUtil.getVpnId(vpnName);
String primaryRd = vpnUtil.getPrimaryRd(vpnName);
LOG.info("updateVpnInterfaceOnTepAdd: AdjacencyList for interface {} on dpn {} vpn {} is {}",
vpnInterface.getName(), vpnInterface.getDpnId(),
- vpnInterface.getVpnInstanceName(), adjList);
- for (Adjacency adj : adjList) {
+ vpnInterface.getVpnInstanceName(), keyAdjacencyMap);
+ for (Adjacency adj : keyAdjacencyMap.values()) {
String rd = adj.getVrfId();
rd = rd != null ? rd : vpnName;
prefix = adj.getIpAddress();
List<String> nextHopList = adj.getNextHopIpList();
// If TEP is added , update the nexthop of primary adjacency.
// Secondary adj nexthop is already pointing to primary adj IP address.
- if (nextHopList == null || nextHopList.isEmpty()) {
- isNextHopAddReqd = true;
- }
-
if (adj.getAdjacencyType() == AdjacencyType.PrimaryAdjacency) {
value.add(new AdjacencyBuilder(adj).setNextHopIpList(nhList).build());
+ if (nextHopList != null && !nextHopList.isEmpty()) {
+ /* everything right already */
+ } else {
+ isFibNextHopAddReqd = true;
+ }
} else {
Optional<VrfEntry> vrfEntryOptional = FibHelper.getVrfEntry(dataBroker, primaryRd, prefix);
if (!vrfEntryOptional.isPresent()) {
nhList = FibHelper.getNextHopListFromRoutePaths(vrfEntryOptional.get());
if (!nhList.contains(srcTepIp)) {
nhList.add(srcTepIp);
- isNextHopAddReqd = true;
+ isFibNextHopAddReqd = true;
}
value.add(adj);
}
- if (isNextHopAddReqd) {
+ if (isFibNextHopAddReqd) {
updateLabelMapper(label, nhList);
LOG.info("updateVpnInterfaceOnTepAdd: Updated label mapper : label {} dpn {} prefix {} nexthoplist {}"
+ " vpn {} vpnid {} rd {} interface {}", label, srcDpnId , prefix, nhList,
vpnInterface.getVpnInstanceName(), vpnId, rd, vpnInterface.getName());
// Update the VRF entry with nextHop
- fibManager.updateRoutePathForFibEntry(primaryRd, prefix, srcTepIp,
- label, true, TransactionAdapter.toWriteTransaction(writeConfigTxn));
+ fibManager.updateRoutePathForFibEntry(primaryRd, prefix, srcTepIp, label, true,
+ writeConfigTxn);
//Get the list of VPN's importing this route(prefix) .
// Then update the VRF entry with nhList
for (VpnInstanceOpDataEntry vpn : vpnsToImportRoute) {
String vpnRd = vpn.getVrfId();
if (vpnRd != null) {
- fibManager.updateRoutePathForFibEntry(vpnRd, prefix,
- srcTepIp, label, true, TransactionAdapter.toWriteTransaction(writeConfigTxn));
+ fibManager.updateRoutePathForFibEntry(vpnRd, prefix, srcTepIp, label, true,
+ writeConfigTxn);
LOG.info("updateVpnInterfaceOnTepAdd: Exported route with rd {} prefix {} nhList {} label {}"
+ " interface {} dpn {} from vpn {} to VPN {} vpnRd {}", rd, prefix, nhList, label,
vpnInterface.getName(), srcDpnId, vpnName,
.addAugmentation(AdjacenciesOp.class, aug).build();
InstanceIdentifier<VpnInterfaceOpDataEntry> interfaceId =
VpnUtil.getVpnInterfaceOpDataEntryIdentifier(vpnInterface.getName(), vpnName);
- writeOperTxn.put(interfaceId, opInterface, CREATE_MISSING_PARENTS);
+ writeOperTxn.mergeParentStructurePut(interfaceId, opInterface);
LOG.info("updateVpnInterfaceOnTepAdd: interface {} updated successully on tep add on dpn {} vpn {}",
vpnInterface.getName(), srcDpnId, vpnName);
TypedWriteTransaction<Operational> writeOperTxn) {
AdjacenciesOp adjacencies = vpnInterface.augmentation(AdjacenciesOp.class);
- List<Adjacency> adjList = adjacencies != null ? adjacencies.getAdjacency() : new ArrayList<>();
+ List<Adjacency> adjList = adjacencies != null ? new ArrayList<Adjacency>(adjacencies.getAdjacency().values())
+ : new ArrayList<>();
String prefix = null;
boolean isNextHopRemoveReqd = false;
String srcTepIp = stateTunnelList.getSrcInfo().getTepIp().stringValue();
prefix, nhList, vpnName,
vpnId, rd, vpnInterface.getName());
// Update the VRF entry with removed nextHop
- fibManager.updateRoutePathForFibEntry(primaryRd, prefix, srcTepIp,
- label, false, TransactionAdapter.toWriteTransaction(writeConfigTxn));
+ fibManager.updateRoutePathForFibEntry(primaryRd, prefix, srcTepIp, label, false,
+ writeConfigTxn);
//Get the list of VPN's importing this route(prefix) .
// Then update the VRF entry with nhList
for (VpnInstanceOpDataEntry vpn : vpnsToImportRoute) {
String vpnRd = vpn.getVrfId();
if (vpnRd != null) {
- fibManager.updateRoutePathForFibEntry(vpnRd, prefix,
- srcTepIp, label, false, TransactionAdapter.toWriteTransaction(writeConfigTxn));
+ fibManager.updateRoutePathForFibEntry(vpnRd, prefix, srcTepIp, label, false,
+ writeConfigTxn);
LOG.info("updateVpnInterfaceOnTepDelete: Exported route with rd {} prefix {} nhList {}"
+ " label {} interface {} dpn {} from vpn {} to VPN {} vpnRd {}", rd, prefix,
nhList, label, vpnInterface.getName(), srcDpnId,
.addAugmentation(AdjacenciesOp.class, aug).build();
InstanceIdentifier<VpnInterfaceOpDataEntry> interfaceId =
VpnUtil.getVpnInterfaceOpDataEntryIdentifier(vpnInterface.getName(), vpnName);
- writeOperTxn.put(interfaceId, opInterface, CREATE_MISSING_PARENTS);
+ writeOperTxn.mergeParentStructurePut(interfaceId, opInterface);
LOG.info("updateVpnInterfaceOnTepDelete: interface {} updated successully on tep delete on dpn {} vpn {}",
vpnInterface.getName(), srcDpnId, vpnName);
}
}
+ @SuppressWarnings("checkstyle:IllegalCatch")
private List<VpnInstanceOpDataEntry> getVpnsExportingMyRoute(final String vpnName) {
List<VpnInstanceOpDataEntry> vpnsToExportRoute = new ArrayList<>();
-
+ final VpnInstanceOpDataEntry vpnInstanceOpDataEntry;
String vpnRd = vpnUtil.getVpnRd(vpnName);
- final VpnInstanceOpDataEntry vpnInstanceOpDataEntry = vpnUtil.getVpnInstanceOpData(vpnRd);
- if (vpnInstanceOpDataEntry == null) {
- LOG.debug("getVpnsExportingMyRoute: Could not retrieve vpn instance op data for {}"
- + " to check for vpns exporting the routes", vpnName);
+ try {
+ VpnInstanceOpDataEntry opDataEntry = vpnUtil.getVpnInstanceOpData(vpnRd);
+ if (opDataEntry == null) {
+ LOG.error("getVpnsExportingMyRoute: Null vpn instance op data for vpn {} rd {}"
+ + " when check for vpns exporting the routes", vpnName, vpnRd);
+ return vpnsToExportRoute;
+ }
+ vpnInstanceOpDataEntry = opDataEntry;
+ } catch (Exception re) {
+ LOG.error("getVpnsExportingMyRoute: DSexception when retrieving vpn instance op data for vpn {} rd {}"
+ + " to check for vpns exporting the routes", vpnName, vpnRd, re);
return vpnsToExportRoute;
}
-
Predicate<VpnInstanceOpDataEntry> excludeVpn = input -> {
if (input.getVpnInstanceName() == null) {
LOG.error("getVpnsExportingMyRoute.excludeVpn: Received vpn instance with rd {} without a name",
}
String prefix = vrfEntry.getDestPrefix();
String gwMac = vrfEntry.getGatewayMacAddress();
- vrfEntry.nonnullRoutePaths().forEach(routePath -> {
+ vrfEntry.nonnullRoutePaths().values().forEach(routePath -> {
String nh = routePath.getNexthopAddress();
Uint32 label = routePath.getLabel();
if (FibHelper.isControllerManagedVpnInterfaceRoute(RouteOrigin.value(
LOG.trace("Received VpnInterface remove event: vpnInterface={}", vpnInterface);
final VpnInterfaceKey key = identifier.firstKeyOf(VpnInterface.class);
final String interfaceName = key.getName();
- for (VpnInstanceNames vpnInterfaceVpnInstance : vpnInterface.nonnullVpnInstanceNames()) {
+ for (VpnInstanceNames vpnInterfaceVpnInstance : vpnInterface.nonnullVpnInstanceNames().values()) {
String vpnName = vpnInterfaceVpnInstance.getVpnName();
removeVpnInterfaceCall(identifier, vpnInterface, vpnName, interfaceName);
}
try {
optVpnInterface = SingleTransactionDataBroker.syncReadOptional(dataBroker,
LogicalDatastoreType.OPERATIONAL, interfaceId);
- } catch (ReadFailedException e) {
+ } catch (InterruptedException | ExecutionException e) {
LOG.error("remove: Failed to read data store for interface {} vpn {}",
interfaceName, vpnName);
return;
Optional<VpnInterfaceOpDataEntry> vpnInterfaceOpDataEnteryOptional =
SingleTransactionDataBroker.syncReadOptional(dataBroker,
LogicalDatastoreType.OPERATIONAL, identifier);
- boolean isLearntIP = Boolean.FALSE;
+ boolean isNonPrimaryAdjIp = false;
String primaryRd = vpnUtil.getVpnRd(vpnName);
LOG.info("removeAdjacenciesFromVpn: For interface {} on dpn {} RD recovered for vpn {} as rd {}",
interfaceName, dpnId, vpnName, primaryRd);
AdjacenciesOp adjacencies = vpnInterfaceOpDataEnteryOptional.get().augmentation(AdjacenciesOp.class);
if (adjacencies != null && !adjacencies.getAdjacency().isEmpty()) {
- List<Adjacency> nextHops = adjacencies.getAdjacency();
+ Map<AdjacencyKey, Adjacency> nextHopsMap = adjacencies.getAdjacency();
LOG.info("removeAdjacenciesFromVpn: NextHops for interface {} on dpn {} for vpn {} are {}",
- interfaceName, dpnId, vpnName, nextHops);
- for (Adjacency nextHop : nextHops) {
+ interfaceName, dpnId, vpnName, nextHopsMap);
+ for (Adjacency nextHop : nextHopsMap.values()) {
if (nextHop.isPhysNetworkFunc()) {
LOG.info("removeAdjacenciesFromVpn: Removing PNF FIB entry rd {} prefix {}",
nextHop.getSubnetId().getValue(), nextHop.getIpAddress());
List<String> nhList;
if (nextHop.getAdjacencyType() != AdjacencyType.PrimaryAdjacency) {
nhList = getNextHopForNonPrimaryAdjacency(nextHop, vpnName, dpnId, interfaceName);
- isLearntIP = nextHop.getAdjacencyType() == AdjacencyType.LearntIp ? true : false;
+ isNonPrimaryAdjIp = Boolean.TRUE;
} else {
// This is a primary adjacency
nhList = nextHop.getNextHopIpList() != null ? nextHop.getNextHopIpList()
removeGwMacAndArpResponderFlows(nextHop, vpnId, dpnId, lportTag, gwMac,
vpnInterfaceOpDataEnteryOptional.get().getGatewayIpAddress(),
interfaceName, writeInvTxn);
+ isNonPrimaryAdjIp = Boolean.FALSE;
}
if (!nhList.isEmpty()) {
if (Objects.equals(primaryRd, vpnName)) {
interfaceName, dpnId, writeConfigTxn, writeOperTxn));
} else {
removeAdjacencyFromBgpvpn(nextHop, nhList, vpnName, primaryRd, dpnId, rd,
- interfaceName, writeConfigTxn, writeOperTxn);
+ interfaceName, isNonPrimaryAdjIp, writeConfigTxn, writeOperTxn);
}
} else {
LOG.error("removeAdjacenciesFromVpn: nextHop empty for ip {} rd {} adjacencyType {}"
vpnVipToPort.getPortName(), ip, dpnId, vpnName);
}
// Remove the MIP-IP from VpnPortIpToPort.
- if (isLearntIP) {
+ if (isNonPrimaryAdjIp) {
VpnPortipToPort persistedIp = vpnUtil.getVpnPortipToPort(vpnName, ip);
if (persistedIp != null && persistedIp.isLearntIp()
&& persistedIp.getPortName().equals(interfaceName)) {
+ " Removing it.", interfaceName, vpnName, dpnId);
writeOperTxn.delete(identifier);
}
- } catch (ReadFailedException e) {
+ } catch (InterruptedException | ExecutionException e) {
LOG.error("removeAdjacenciesFromVpn: Failed to read data store for interface {} dpn {} vpn {}",
interfaceName, dpnId, vpnName);
}
}
private void removeAdjacencyFromBgpvpn(Adjacency nextHop, List<String> nhList, String vpnName, String primaryRd,
- Uint64 dpnId, String rd, String interfaceName,
+ Uint64 dpnId, String rd, String interfaceName, boolean isNonPrimaryAdjIp,
TypedWriteTransaction<Configuration> writeConfigTxn,
TypedWriteTransaction<Operational> writeOperTx) {
List<VpnInstanceOpDataEntry> vpnsToImportRoute =
vpnUtil.getVpnsImportingMyRoute(vpnName);
nhList.forEach((nh) -> {
//IRT: remove routes from other vpns importing it
- vpnManager.removePrefixFromBGP(vpnName, primaryRd, rd, interfaceName, nextHop.getIpAddress(),
- nextHop.getNextHopIpList().get(0), nh, dpnId, writeConfigTxn, writeOperTx);
+ if (isNonPrimaryAdjIp) {
+ removeLearntPrefixFromBGP(rd, nextHop.getIpAddress(), nh, writeConfigTxn);
+ } else {
+ vpnManager.removePrefixFromBGP(vpnName, primaryRd, rd, interfaceName, nextHop.getIpAddress(),
+ nextHop.getNextHopIpList().get(0), nh, dpnId, writeConfigTxn, writeOperTx);
+ }
for (VpnInstanceOpDataEntry vpn : vpnsToImportRoute) {
String vpnRd = vpn.getVrfId();
if (vpnRd != null) {
});
}
+ @SuppressWarnings("checkstyle:IllegalCatch")
+ private void removeLearntPrefixFromBGP(String rd, String prefix, String nextHop,
+ TypedWriteTransaction<Configuration> writeConfigTxn) {
+ try {
+ if (!fibManager.checkFibEntryExist(dataBroker, rd, prefix, nextHop)) {
+ LOG.info("removeLearntPrefixFromBGP: IP {} with nexthop {} rd {} is already removed.Ignoring this"
+ + " operation", prefix, nextHop, rd);
+ return;
+ }
+ LOG.info("removeLearntPrefixFromBGP: VPN WITHDRAW: Removing Fib Entry rd {} prefix {} nexthop {}",
+ rd, prefix, nextHop);
+ fibManager.removeOrUpdateFibEntry(rd, prefix, nextHop, writeConfigTxn);
+ bgpManager.withdrawPrefix(rd, prefix); // TODO: Might be needed to include nextHop here
+ LOG.info("removeLearntPrefixFromBGP: VPN WITHDRAW: Removed Fib Entry rd {} prefix {} nexthop {}",
+ rd, prefix, nextHop);
+ } catch (Exception e) {
+ LOG.error("removeLearntPrefixFromBGP: Delete prefix {} rd {} nextHop {} failed", prefix, rd, nextHop, e);
+ }
+ }
+
private void removeGwMacAndArpResponderFlows(Adjacency nextHop, Uint32 vpnId, Uint64 dpnId,
int lportTag, String gwMac, String gwIp, String interfaceName,
TypedReadWriteTransaction<Configuration> writeInvTxn)
gwPort.getMacAddress(), ipAddress, ifName, vpnName);
return Optional.of(gwPort.getMacAddress());
}
- return Optional.absent();
+ return Optional.empty();
}
@Override
- protected void update(final InstanceIdentifier<VpnInterface> identifier, final VpnInterface original,
+ public void update(final InstanceIdentifier<VpnInterface> identifier, final VpnInterface original,
final VpnInterface update) {
LOG.trace("Received VpnInterface update event: original={}, update={}", original, update);
LOG.info("update: VPN Interface update event - intfName {} on dpn {} oldVpn {} newVpn {}", update.getName(),
LOG.info("update: handled Instance update for VPNInterface {} on dpn {} from oldVpn(s) {} "
+ "to newVpn(s) {}",
original.getName(), dpnId,
- VpnHelper.getVpnInterfaceVpnInstanceNamesString(original.getVpnInstanceNames()),
- VpnHelper.getVpnInterfaceVpnInstanceNamesString(update.getVpnInstanceNames()));
+ VpnHelper.getVpnInterfaceVpnInstanceNamesString(
+ new ArrayList<VpnInstanceNames>(original.getVpnInstanceNames().values())),
+ VpnHelper.getVpnInterfaceVpnInstanceNamesString(
+ new ArrayList<VpnInstanceNames>(update.getVpnInstanceNames().values())));
return emptyList();
}
updateVpnInstanceAdjChange(original, update, vpnInterfaceName, futures);
List<ListenableFuture<Void>> futures) {
final Adjacencies origAdjs = original.augmentation(Adjacencies.class);
final List<Adjacency> oldAdjs = origAdjs != null && origAdjs.getAdjacency() != null
- ? origAdjs.getAdjacency() : new ArrayList<>();
+ ? new ArrayList<Adjacency>(origAdjs.getAdjacency().values()) : new ArrayList<>();
final Adjacencies updateAdjs = update.augmentation(Adjacencies.class);
final List<Adjacency> newAdjs = updateAdjs != null && updateAdjs.getAdjacency() != null
- ? updateAdjs.getAdjacency() : new ArrayList<>();
+ ? new ArrayList<Adjacency>(updateAdjs.getAdjacency().values()) : new ArrayList<>();
boolean isOldVpnRemoveCallExecuted = false;
for (String oldVpnName : oldVpnList) {
List<ListenableFuture<Void>> futures) {
final Adjacencies origAdjs = original.augmentation(Adjacencies.class);
final List<Adjacency> oldAdjs = origAdjs != null && origAdjs.getAdjacency()
- != null ? origAdjs.getAdjacency() : new ArrayList<>();
+ != null ? new ArrayList<Adjacency>(origAdjs.getAdjacency().values()) : new ArrayList<>();
final Adjacencies updateAdjs = update.augmentation(Adjacencies.class);
final List<Adjacency> newAdjs = updateAdjs != null && updateAdjs.getAdjacency()
- != null ? updateAdjs.getAdjacency() : new ArrayList<>();
+ != null ? new ArrayList<Adjacency>(updateAdjs.getAdjacency().values()) : new ArrayList<>();
final Uint64 dpnId = InterfaceUtils.getDpnForInterface(ifaceMgrRpcService, vpnInterfaceName);
- for (VpnInstanceNames vpnInterfaceVpnInstance : update.nonnullVpnInstanceNames()) {
+ for (VpnInstanceNames vpnInterfaceVpnInstance : update.nonnullVpnInstanceNames().values()) {
String newVpnName = vpnInterfaceVpnInstance.getVpnName();
List<Adjacency> copyNewAdjs = new ArrayList<>(newAdjs);
List<Adjacency> copyOldAdjs = new ArrayList<>(oldAdjs);
}
LOG.info("updateLabelMapper: Updated label rotue info for label {} with nextHopList {}", label,
nextHopIpList);
- } catch (ReadFailedException e) {
+ } catch (InterruptedException | ExecutionException e) {
LOG.error("updateLabelMapper: Failed to read data store for label {} nexthopList {}", label,
nextHopIpList);
} catch (TransactionCommitFailedException e) {
InstanceIdentifier<VrfTables> vrfTableId = idBuilder.build();
VrfTables vrfTableNew = new VrfTablesBuilder().setRouteDistinguisher(rd).setVrfEntry(vrfEntryList).build();
if (writeConfigTxn != null) {
- writeConfigTxn.merge(vrfTableId, vrfTableNew, CREATE_MISSING_PARENTS);
+ writeConfigTxn.mergeParentStructureMerge(vrfTableId, vrfTableNew);
} else {
vpnUtil.syncUpdate(LogicalDatastoreType.CONFIGURATION, vrfTableId, vrfTableNew);
}
VpnPopulator populator = L3vpnRegistry.getRegisteredPopulator(encapType);
List<Adjacency> adjacencies = new ArrayList<>();
if (optAdjacencies.isPresent() && optAdjacencies.get().getAdjacency() != null) {
- adjacencies.addAll(optAdjacencies.get().getAdjacency());
+ adjacencies.addAll(optAdjacencies.get().getAdjacency().values());
}
Uint32 vpnId = vpnUtil.getVpnId(vpnName);
L3vpnInput input = new L3vpnInput().setNextHop(adj).setVpnName(vpnName)
String parentVpnRd = getParentVpnRdForExternalSubnet(adj);
- writeOperTxn.merge(
+ writeOperTxn.mergeParentStructureMerge(
VpnUtil.getPrefixToInterfaceIdentifier(vpnUtil.getVpnId(adj.getSubnetId().getValue()),
- prefix), pnfPrefix, true);
+ prefix), pnfPrefix);
fibManager.addOrUpdateFibEntry(adj.getSubnetId().getValue(), adj.getMacAddress(),
adj.getIpAddress(), emptyList(), null /* EncapType */, Uint32.ZERO /* label */,
VpnUtil.getVpnInterfaceOpDataEntry(currVpnIntf.getName(), currVpnIntf.getVpnInstanceName(),
aug, dpnId, currVpnIntf.getLportTag().toJava(),
currVpnIntf.getGatewayMacAddress(), currVpnIntf.getGatewayIpAddress());
- writeOperTxn.merge(identifier, newVpnIntf, CREATE_MISSING_PARENTS);
+ writeOperTxn.mergeParentStructureMerge(identifier, newVpnIntf);
}
- } catch (ReadFailedException e) {
+ } catch (InterruptedException | ExecutionException e) {
LOG.error("addNewAdjToVpnInterface: Failed to read data store for interface {} dpn {} vpn {} rd {} ip "
+ "{}", interfaceName, dpnId, configVpnName, primaryRd, adj.getIpAddress());
}
Optional<AdjacenciesOp> optAdjacencies = SingleTransactionDataBroker.syncReadOptional(dataBroker,
LogicalDatastoreType.OPERATIONAL, path);
if (optAdjacencies.isPresent()) {
- List<Adjacency> adjacencies = optAdjacencies.get().getAdjacency();
+ Map<AdjacencyKey, Adjacency> keyAdjacencyMap = optAdjacencies.get().getAdjacency();
- if (adjacencies != null && !adjacencies.isEmpty()) {
- LOG.trace("delAdjFromVpnInterface: Adjacencies are {}", adjacencies);
- for (Adjacency adjacency : adjacencies) {
+ if (keyAdjacencyMap != null && !keyAdjacencyMap.isEmpty()) {
+ LOG.trace("delAdjFromVpnInterface: Adjacencies are {}", keyAdjacencyMap);
+ for (Adjacency adjacency : keyAdjacencyMap.values()) {
if (Objects.equals(adjacency.getIpAddress(), adj.getIpAddress())) {
String rd = adjacency.getVrfId();
if (adj.getNextHopIpList() != null) {
+ "unavailable dpnId {} adjIP {} rd {}", dpnId, adj.getIpAddress(), adj.getVrfId());
}
}
- } catch (ReadFailedException e) {
+ } catch (InterruptedException | ExecutionException e) {
LOG.error("delAdjFromVpnInterface: Failed to read data store for ip {} interface {} dpn {} vpn {}",
adj.getIpAddress(), interfaceName, dpnId, vpnName);
}
Uint32 label = vpnUtil.getUniqueId(VpnConstants.VPN_IDPOOL_NAME,
VpnUtil.getNextHopLabelKey(primaryRd, prefix));
-
+ if (label.longValue() == VpnConstants.INVALID_LABEL) {
+ LOG.error(
+ "createFibEntryForRouterInterface: Unable to retrieve label for vpn pool {}, "
+ + "vpninterface {}, vpn {}, rd {}",
+ VpnConstants.VPN_IDPOOL_NAME, interfaceName, vpnName, primaryRd);
+ return;
+ }
RouterInterface routerInt = new RouterInterfaceBuilder().setUuid(vpnName)
.setIpAddress(primaryInterfaceIp).setMacAddress(macAddress).build();
fibManager.addFibEntryForRouterInterface(primaryRd, prefix,
Adjacencies adjs = vpnInterface.augmentation(Adjacencies.class);
String rd = vpnUtil.getVpnRd(vpnName);
if (adjs != null) {
- List<Adjacency> adjsList = adjs.nonnullAdjacency();
- for (Adjacency adj : adjsList) {
+ Map<AdjacencyKey, Adjacency> keyAdjacencyMap = adjs.nonnullAdjacency();
+ for (Adjacency adj : keyAdjacencyMap.values()) {
if (adj.getAdjacencyType() == AdjacencyType.PrimaryAdjacency) {
String primaryInterfaceIp = adj.getIpAddress();
String prefix = VpnUtil.getIpPrefix(primaryInterfaceIp);
if (vpnInstanceOpData == null) {
return;
}
- List<VpnToDpnList> vpnToDpnLists = vpnInstanceOpData.getVpnToDpnList();
+ List<VpnToDpnList> vpnToDpnLists = new ArrayList<VpnToDpnList>(vpnInstanceOpData.getVpnToDpnList().values());
if (vpnToDpnLists == null || vpnToDpnLists.isEmpty()) {
return;
}
if (vpnToDpnList.getVpnInterfaces() == null) {
return;
}
- vpnToDpnList.getVpnInterfaces().forEach(vpnInterface -> {
+ vpnToDpnList.getVpnInterfaces().values().forEach(vpnInterface -> {
try {
InstanceIdentifier<VpnInterfaceOpDataEntry> existingVpnInterfaceId =
VpnUtil.getVpnInterfaceOpDataEntryIdentifier(vpnInterface.getInterfaceName(), vpnName);
LOG.debug("There is no adjacency available for vpnInterface:{}", vpnInterface);
return;
}
- List<Adjacency> operationVpnAdjacencies = vpnInterfaceOptional.get()
- .augmentation(AdjacenciesOp.class).nonnullAdjacency();
+ List<Adjacency> operationVpnAdjacencies = new ArrayList<Adjacency>(vpnInterfaceOptional.get()
+ .augmentation(AdjacenciesOp.class).nonnullAdjacency().values());
// Due to insufficient rds, some of the extra route wont get processed when it is added.
// The unprocessed adjacencies will be present in config vpn interface DS but will be missing
// in operational DS. These unprocessed adjacencies will be handled below.
}
});
});
- } catch (ReadFailedException e) {
+ } catch (InterruptedException | ExecutionException e) {
LOG.error("updateVpnInterfacesForUnProcessAdjancencies: Failed to read data store for vpn {} rd {}",
vpnName, primaryRd);
}