import static org.opendaylight.genius.infra.Datastore.CONFIGURATION;
import static org.opendaylight.genius.infra.Datastore.OPERATIONAL;
import static org.opendaylight.genius.infra.Datastore.CONFIGURATION;
import static org.opendaylight.genius.infra.Datastore.OPERATIONAL;
import com.google.common.base.Preconditions;
import com.google.common.collect.Iterators;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.base.Preconditions;
import com.google.common.collect.Iterators;
import com.google.common.util.concurrent.FutureCallback;
import java.util.function.Consumer;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import java.util.function.Consumer;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import javax.annotation.PreDestroy;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.eclipse.jdt.annotation.Nullable;
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.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.TypedReadWriteTransaction;
import org.opendaylight.genius.infra.TypedWriteTransaction;
import org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager;
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.genius.utils.JvmGlobalLocks;
import org.opendaylight.infrautils.caches.CacheProvider;
import org.opendaylight.infrautils.jobcoordinator.JobCoordinator;
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.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.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.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.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.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.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.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.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.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.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;
private static final Logger LOG = LoggerFactory.getLogger(VpnInterfaceManager.class);
private static final short DJC_MAX_RETRIES = 3;
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) {
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));
vpnInstanceOpDataEntryCache = new InstanceIdDataObjectCache<>(VpnInstanceOpDataEntry.class, dataBroker,
LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.builder(
VpnInstanceOpData.class).child(VpnInstanceOpDataEntry.class).build(), cacheProvider);
vpnInstanceOpDataEntryCache = new InstanceIdDataObjectCache<>(VpnInstanceOpDataEntry.class, dataBroker,
LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.builder(
VpnInstanceOpData.class).child(VpnInstanceOpDataEntry.class).build(), cacheProvider);
- }
-
- @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(),
}
@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(),
addVpnInterface(identifier, vpnInterface, null, null);
}
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) {
@SuppressWarnings("checkstyle:IllegalCatch")
private void addVpnInterface(final InstanceIdentifier<VpnInterface> identifier, final VpnInterface vpnInterface,
final @Nullable List<Adjacency> oldAdjs, final @Nullable List<Adjacency> newAdjs) {
String vpnName = vpnInterfaceVpnInstance.getVpnName();
addVpnInterfaceCall(identifier, vpnInterface, oldAdjs, newAdjs, vpnName);
}
String vpnName = vpnInterfaceVpnInstance.getVpnName();
addVpnInterfaceCall(identifier, vpnInterface, oldAdjs, newAdjs, vpnName);
}
Optional<Adjacencies> optAdjacencies = SingleTransactionDataBroker.syncReadOptional(dataBroker,
LogicalDatastoreType.CONFIGURATION, path);
if (!optAdjacencies.isPresent()) {
Optional<Adjacencies> optAdjacencies = SingleTransactionDataBroker.syncReadOptional(dataBroker,
LogicalDatastoreType.CONFIGURATION, path);
if (!optAdjacencies.isPresent()) {
- List<Adjacency> adjacencies = optAdjacencies.get().nonnullAdjacency();
- for (Adjacency adjacency : adjacencies) {
+ Map<AdjacencyKey, Adjacency> adjacencyKeyAdjacencyMap = optAdjacencies.get().nonnullAdjacency();
+ for (Adjacency adjacency : adjacencyKeyAdjacencyMap.values()) {
addNewAdjToVpnInterface(vpnInterfaceOpIdentifier, primaryRd, adjacency,
dpId, writeOperTxn, writeConfigTxn, writeInvTxn, prefixListForRefreshFib);
}
addNewAdjToVpnInterface(vpnInterfaceOpIdentifier, primaryRd, adjacency,
dpId, writeOperTxn, writeConfigTxn, writeInvTxn, prefixListForRefreshFib);
}
LOG.error("processVpnInterfaceUp: Failed to read data store for interface {} vpn {} rd {} dpn {}",
interfaceName, vpnName, primaryRd, dpId);
}
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,
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,
dpId, interfaceName, lportTag);
} else {
vpnManager.removeArpResponderFlowsToExternalNetworkIps(routerName,
Optional<AdjacenciesOp> adjacencies = SingleTransactionDataBroker.syncReadOptional(dataBroker,
LogicalDatastoreType.OPERATIONAL, path);
if (adjacencies.isPresent()) {
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()) {
- + " 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;
VpnInstanceOpDataEntry vpnInstanceOpData = vpnUtil.getVpnInstanceOpData(rd);
Uint32 l3vni = vpnInstanceOpData.getL3vni();
VrfEntry.EncapType encapType = VpnUtil.isL3VpnOverVxLan(l3vni)
? VrfEntry.EncapType.Vxlan : VrfEntry.EncapType.Mplsgre;
LOG.error("advertiseAdjacenciesForVpnToBgp: Failed to read data store for interface {} dpn {} nexthop {}"
+ "vpn {} rd {}", interfaceName, dpnId, nextHopIp, vpnName, rd);
}
LOG.error("advertiseAdjacenciesForVpnToBgp: Failed to read data store for interface {} dpn {} nexthop {}"
+ "vpn {} rd {}", interfaceName, dpnId, nextHopIp, vpnName, rd);
}
try {
adjacencies = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.OPERATIONAL,
path);
try {
adjacencies = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.OPERATIONAL,
path);
LOG.error("withdrawAdjacenciesForVpnFromBgp: Failed to read data store for interface {} vpn {}",
interfaceName, vpnName);
}
if (adjacencies.isPresent()) {
LOG.error("withdrawAdjacenciesForVpnFromBgp: Failed to read data store for interface {} vpn {}",
interfaceName, vpnName);
}
if (adjacencies.isPresent()) {
- 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 {}"
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
throws ExecutionException, InterruptedException {
InstanceIdentifier<VpnInterface> identifier = VpnUtil.getVpnInterfaceIdentifier(interfaceName);
// Read NextHops
try {
vpnInteface = SingleTransactionDataBroker.syncReadOptional(dataBroker,
LogicalDatastoreType.CONFIGURATION, identifier);
try {
vpnInteface = SingleTransactionDataBroker.syncReadOptional(dataBroker,
LogicalDatastoreType.CONFIGURATION, identifier);
LOG.error("processVpnInterfaceAdjacencies: Failed to read data store for interface {} vpn {} rd {}"
+ "dpn {}", interfaceName, vpnName, primaryRd, dpnId);
}
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);
}
LOG.debug("processVpnInterfaceAdjacencies: NextHop for interface {} on dpn {} in vpn {} is {}",
interfaceName, dpnId, vpnName, nhList);
}
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);
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();
String rd = primaryRd;
String nexthopIpValue = nextHop.getIpAddress().split("/")[0];
if (vpnInstanceOpData.getBgpvpnType() == VpnInstanceOpDataEntry.BgpvpnType.BGPVPNInternet
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;
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);
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);
subnetId, interfaceName, vpnName);
gwMac = InterfaceUtils.getMacAddressFromInterfaceState(interfaceState);
}
subnetId, interfaceName, vpnName);
gwMac = InterfaceUtils.getMacAddressFromInterfaceState(interfaceState);
}
+ " for vpn {}", prefix, interfaceName, nhList, dpnId, vpnName);
} else {
//Extra route adjacency
+ " 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)
gwMac.isPresent() ? gwMac.get() : null, gatewayIp, writeOperTxn);
L3vpnInput input = new L3vpnInput().setNextHopIp(nextHopIp).setL3vni(l3vni.longValue()).setPrimaryRd(primaryRd)
// Adjacencies other than primary Adjacencies are handled in the addExtraRoute call above.
if (nextHop.getAdjacencyType() == AdjacencyType.PrimaryAdjacency) {
RouteOrigin origin = VpnUtil.getRouteOrigin(nextHop.getAdjacencyType());
// 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);
VpnUtil.getVpnInterfaceOpDataEntry(interfaceName, vpnName, aug, dpnId, lportTag, gwMac, gwIp);
InstanceIdentifier<VpnInterfaceOpDataEntry> interfaceId = VpnUtil
.getVpnInterfaceOpDataEntryIdentifier(interfaceName, vpnName);
LOG.info("addVpnInterfaceToOperational: Added VPN Interface {} on dpn {} vpn {} to operational datastore",
interfaceName, dpnId, vpnName);
}
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);
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()) {
String primaryRd = vpnUtil.getPrimaryRd(vpnName);
LOG.info("updateVpnInterfaceOnTepAdd: AdjacencyList for interface {} on dpn {} vpn {} is {}",
vpnInterface.getName(), vpnInterface.getDpnId(),
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();
String rd = adj.getVrfId();
rd = rd != null ? rd : vpnName;
prefix = adj.getIpAddress();
+ " vpn {} vpnid {} rd {} interface {}", label, srcDpnId , prefix, nhList,
vpnInterface.getVpnInstanceName(), vpnId, rd, vpnInterface.getName());
// Update the VRF entry with nextHop
+ " 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);
- 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,
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);
.addAugmentation(AdjacenciesOp.class, aug).build();
InstanceIdentifier<VpnInterfaceOpDataEntry> interfaceId =
VpnUtil.getVpnInterfaceOpDataEntryIdentifier(vpnInterface.getName(), vpnName);
LOG.info("updateVpnInterfaceOnTepAdd: interface {} updated successully on tep add on dpn {} vpn {}",
vpnInterface.getName(), srcDpnId, vpnName);
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);
TypedWriteTransaction<Operational> writeOperTxn) {
AdjacenciesOp adjacencies = vpnInterface.augmentation(AdjacenciesOp.class);
String prefix = null;
boolean isNextHopRemoveReqd = false;
String srcTepIp = stateTunnelList.getSrcInfo().getTepIp().stringValue();
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
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);
- 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,
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);
.addAugmentation(AdjacenciesOp.class, aug).build();
InstanceIdentifier<VpnInterfaceOpDataEntry> interfaceId =
VpnUtil.getVpnInterfaceOpDataEntryIdentifier(vpnInterface.getName(), vpnName);
LOG.info("updateVpnInterfaceOnTepDelete: interface {} updated successully on tep delete on dpn {} vpn {}",
vpnInterface.getName(), srcDpnId, vpnName);
}
LOG.info("updateVpnInterfaceOnTepDelete: interface {} updated successully on tep delete on dpn {} vpn {}",
vpnInterface.getName(), srcDpnId, vpnName);
}
String nh = routePath.getNexthopAddress();
Uint32 label = routePath.getLabel();
if (FibHelper.isControllerManagedVpnInterfaceRoute(RouteOrigin.value(
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();
LOG.trace("Received VpnInterface remove event: vpnInterface={}", vpnInterface);
final VpnInterfaceKey key = identifier.firstKeyOf(VpnInterface.class);
final String interfaceName = key.getName();
String vpnName = vpnInterfaceVpnInstance.getVpnName();
removeVpnInterfaceCall(identifier, vpnInterface, vpnName, interfaceName);
}
String vpnName = vpnInterfaceVpnInstance.getVpnName();
removeVpnInterfaceCall(identifier, vpnInterface, vpnName, interfaceName);
}
try {
optVpnInterface = SingleTransactionDataBroker.syncReadOptional(dataBroker,
LogicalDatastoreType.OPERATIONAL, interfaceId);
try {
optVpnInterface = SingleTransactionDataBroker.syncReadOptional(dataBroker,
LogicalDatastoreType.OPERATIONAL, interfaceId);
AdjacenciesOp adjacencies = vpnInterfaceOpDataEnteryOptional.get().augmentation(AdjacenciesOp.class);
if (adjacencies != null && !adjacencies.getAdjacency().isEmpty()) {
AdjacenciesOp adjacencies = vpnInterfaceOpDataEnteryOptional.get().augmentation(AdjacenciesOp.class);
if (adjacencies != null && !adjacencies.getAdjacency().isEmpty()) {
- 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());
if (nextHop.isPhysNetworkFunc()) {
LOG.info("removeAdjacenciesFromVpn: Removing PNF FIB entry rd {} prefix {}",
nextHop.getSubnetId().getValue(), nextHop.getIpAddress());
+ " Removing it.", interfaceName, vpnName, dpnId);
writeOperTxn.delete(identifier);
}
+ " Removing it.", interfaceName, vpnName, dpnId);
writeOperTxn.delete(identifier);
}
LOG.error("removeAdjacenciesFromVpn: Failed to read data store for interface {} dpn {} vpn {}",
interfaceName, dpnId, vpnName);
}
LOG.error("removeAdjacenciesFromVpn: Failed to read data store for interface {} dpn {} vpn {}",
interfaceName, dpnId, vpnName);
}
gwPort.getMacAddress(), ipAddress, ifName, vpnName);
return Optional.of(gwPort.getMacAddress());
}
gwPort.getMacAddress(), ipAddress, ifName, vpnName);
return Optional.of(gwPort.getMacAddress());
}
- 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(),
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,
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);
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
List<ListenableFuture<Void>> futures) {
final Adjacencies origAdjs = original.augmentation(Adjacencies.class);
final List<Adjacency> oldAdjs = origAdjs != null && origAdjs.getAdjacency() != null
final Adjacencies updateAdjs = update.augmentation(Adjacencies.class);
final List<Adjacency> newAdjs = updateAdjs != null && updateAdjs.getAdjacency() != null
final Adjacencies updateAdjs = update.augmentation(Adjacencies.class);
final List<Adjacency> newAdjs = updateAdjs != null && updateAdjs.getAdjacency() != null
List<ListenableFuture<Void>> futures) {
final Adjacencies origAdjs = original.augmentation(Adjacencies.class);
final List<Adjacency> oldAdjs = origAdjs != null && origAdjs.getAdjacency()
List<ListenableFuture<Void>> futures) {
final Adjacencies origAdjs = original.augmentation(Adjacencies.class);
final List<Adjacency> oldAdjs = origAdjs != null && origAdjs.getAdjacency()
final Adjacencies updateAdjs = update.augmentation(Adjacencies.class);
final List<Adjacency> newAdjs = updateAdjs != null && updateAdjs.getAdjacency()
final Adjacencies updateAdjs = update.augmentation(Adjacencies.class);
final List<Adjacency> newAdjs = updateAdjs != null && updateAdjs.getAdjacency()
String newVpnName = vpnInterfaceVpnInstance.getVpnName();
List<Adjacency> copyNewAdjs = new ArrayList<>(newAdjs);
List<Adjacency> copyOldAdjs = new ArrayList<>(oldAdjs);
String newVpnName = vpnInterfaceVpnInstance.getVpnName();
List<Adjacency> copyNewAdjs = new ArrayList<>(newAdjs);
List<Adjacency> copyOldAdjs = new ArrayList<>(oldAdjs);
LOG.error("updateLabelMapper: Failed to read data store for label {} nexthopList {}", label,
nextHopIpList);
} catch (TransactionCommitFailedException 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) {
InstanceIdentifier<VrfTables> vrfTableId = idBuilder.build();
VrfTables vrfTableNew = new VrfTablesBuilder().setRouteDistinguisher(rd).setVrfEntry(vrfEntryList).build();
if (writeConfigTxn != null) {
VpnPopulator populator = L3vpnRegistry.getRegisteredPopulator(encapType);
List<Adjacency> adjacencies = new ArrayList<>();
if (optAdjacencies.isPresent() && optAdjacencies.get().getAdjacency() != null) {
VpnPopulator populator = L3vpnRegistry.getRegisteredPopulator(encapType);
List<Adjacency> adjacencies = new ArrayList<>();
if (optAdjacencies.isPresent() && optAdjacencies.get().getAdjacency() != null) {
}
Uint32 vpnId = vpnUtil.getVpnId(vpnName);
L3vpnInput input = new L3vpnInput().setNextHop(adj).setVpnName(vpnName)
}
Uint32 vpnId = vpnUtil.getVpnId(vpnName);
L3vpnInput input = new L3vpnInput().setNextHop(adj).setVpnName(vpnName)
fibManager.addOrUpdateFibEntry(adj.getSubnetId().getValue(), adj.getMacAddress(),
adj.getIpAddress(), emptyList(), null /* EncapType */, Uint32.ZERO /* label */,
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());
VpnUtil.getVpnInterfaceOpDataEntry(currVpnIntf.getName(), currVpnIntf.getVpnInstanceName(),
aug, dpnId, currVpnIntf.getLportTag().toJava(),
currVpnIntf.getGatewayMacAddress(), currVpnIntf.getGatewayIpAddress());
LOG.error("addNewAdjToVpnInterface: Failed to read data store for interface {} dpn {} vpn {} rd {} ip "
+ "{}", interfaceName, dpnId, configVpnName, primaryRd, adj.getIpAddress());
}
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()) {
Optional<AdjacenciesOp> optAdjacencies = SingleTransactionDataBroker.syncReadOptional(dataBroker,
LogicalDatastoreType.OPERATIONAL, path);
if (optAdjacencies.isPresent()) {
- 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) {
if (Objects.equals(adjacency.getIpAddress(), adj.getIpAddress())) {
String rd = adjacency.getVrfId();
if (adj.getNextHopIpList() != null) {
+ "unavailable dpnId {} adjIP {} rd {}", dpnId, adj.getIpAddress(), adj.getVrfId());
}
}
+ "unavailable dpnId {} adjIP {} rd {}", dpnId, adj.getIpAddress(), adj.getVrfId());
}
}
LOG.error("delAdjFromVpnInterface: Failed to read data store for ip {} interface {} dpn {} vpn {}",
adj.getIpAddress(), interfaceName, dpnId, vpnName);
}
LOG.error("delAdjFromVpnInterface: Failed to read data store for ip {} interface {} dpn {} vpn {}",
adj.getIpAddress(), interfaceName, dpnId, vpnName);
}
Adjacencies adjs = vpnInterface.augmentation(Adjacencies.class);
String rd = vpnUtil.getVpnRd(vpnName);
if (adjs != null) {
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 (adj.getAdjacencyType() == AdjacencyType.PrimaryAdjacency) {
String primaryInterfaceIp = adj.getIpAddress();
String prefix = VpnUtil.getIpPrefix(primaryInterfaceIp);
try {
InstanceIdentifier<VpnInterfaceOpDataEntry> existingVpnInterfaceId =
VpnUtil.getVpnInterfaceOpDataEntryIdentifier(vpnInterface.getInterfaceName(), vpnName);
try {
InstanceIdentifier<VpnInterfaceOpDataEntry> existingVpnInterfaceId =
VpnUtil.getVpnInterfaceOpDataEntryIdentifier(vpnInterface.getInterfaceName(), vpnName);
- 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.
// 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.