use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry in project netvirt by opendaylight.
the class BgpRouteVrfEntryHandler method deleteFibEntries.
/*
Please note that the following deleteFibEntries will be invoked only for BGP Imported Routes.
The invocation of the following method is via delete() callback from the MDSAL Batching Infrastructure
provided by ResourceBatchingManager
*/
private void deleteFibEntries(WriteTransaction writeTx, final InstanceIdentifier<VrfEntry> identifier, final VrfEntry vrfEntry, List<SubTransaction> subTxns) {
final VrfTablesKey vrfTableKey = identifier.firstKeyOf(VrfTables.class);
String rd = vrfTableKey.getRouteDistinguisher();
final VpnInstanceOpDataEntry vpnInstance = getFibUtil().getVpnInstance(vrfTableKey.getRouteDistinguisher());
if (vpnInstance == null) {
LOG.debug("VPN Instance for rd {} is not available from VPN Op Instance Datastore", rd);
return;
}
String vpnName = getFibUtil().getVpnNameFromId(vpnInstance.getVpnId());
final Collection<VpnToDpnList> vpnToDpnList = vpnInstance.getVpnToDpnList();
if (vpnToDpnList != null) {
List<String> usedRds = VpnExtraRouteHelper.getUsedRds(dataBroker, vpnInstance.getVpnId(), vrfEntry.getDestPrefix());
Optional<Routes> extraRouteOptional;
// Is this fib route an extra route? If yes, get the nexthop which would be an adjacency in the vpn
if (usedRds != null && !usedRds.isEmpty()) {
if (usedRds.size() > 1) {
LOG.error("The extra route prefix is still present in some DPNs");
return;
} else {
extraRouteOptional = VpnExtraRouteHelper.getVpnExtraroutes(dataBroker, vpnName, usedRds.get(0), vrfEntry.getDestPrefix());
}
} else {
extraRouteOptional = Optional.absent();
}
for (VpnToDpnList curDpn : vpnToDpnList) {
if (curDpn.getDpnState() == VpnToDpnList.DpnState.Active) {
deleteRemoteRoute(BigInteger.ZERO, curDpn.getDpnId(), vpnInstance.getVpnId(), vrfTableKey, vrfEntry, extraRouteOptional, writeTx, subTxns);
}
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry in project netvirt by opendaylight.
the class EvpnVrfEntryHandler method deleteRemoteEvpnFlows.
private void deleteRemoteEvpnFlows(String rd, VrfEntry vrfEntry, VpnInstanceOpDataEntry vpnInstance, VrfTablesKey vrfTableKey, List<BigInteger> localDpnIdList) {
List<VpnToDpnList> vpnToDpnList = vpnInstance.getVpnToDpnList();
List<SubTransaction> subTxns = new ArrayList<>();
if (vpnToDpnList != null) {
jobCoordinator.enqueueJob("FIB" + rd + vrfEntry.getDestPrefix(), () -> {
WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
final Optional<Routes> extraRouteOptional = Optional.absent();
if (localDpnIdList.size() <= 0) {
for (VpnToDpnList curDpn1 : vpnToDpnList) {
if (RouteOrigin.value(vrfEntry.getOrigin()) == RouteOrigin.BGP) {
if (curDpn1.getDpnState() == VpnToDpnList.DpnState.Active) {
bgpRouteVrfEntryHandler.deleteRemoteRoute(BigInteger.ZERO, curDpn1.getDpnId(), vpnInstance.getVpnId(), vrfTableKey, vrfEntry, extraRouteOptional, tx, subTxns);
}
} else {
deleteRemoteRoute(BigInteger.ZERO, curDpn1.getDpnId(), vpnInstance.getVpnId(), vrfTableKey, vrfEntry, extraRouteOptional, tx);
}
}
} else {
for (BigInteger localDpnId : localDpnIdList) {
for (VpnToDpnList curDpn2 : vpnToDpnList) {
if (!curDpn2.getDpnId().equals(localDpnId)) {
if (RouteOrigin.value(vrfEntry.getOrigin()) == RouteOrigin.BGP) {
if (curDpn2.getDpnState() == VpnToDpnList.DpnState.Active) {
bgpRouteVrfEntryHandler.deleteRemoteRoute(localDpnId, curDpn2.getDpnId(), vpnInstance.getVpnId(), vrfTableKey, vrfEntry, extraRouteOptional, tx, subTxns);
}
} else {
deleteRemoteRoute(localDpnId, curDpn2.getDpnId(), vpnInstance.getVpnId(), vrfTableKey, vrfEntry, extraRouteOptional, tx);
}
}
}
}
}
List<ListenableFuture<Void>> futures = new ArrayList<>();
futures.add(tx.submit());
return futures;
});
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry in project netvirt by opendaylight.
the class EvpnVrfEntryHandler method removeFlows.
@Override
public void removeFlows(InstanceIdentifier<VrfEntry> identifier, VrfEntry vrfEntry, String rd) {
final VrfTablesKey vrfTableKey = identifier.firstKeyOf(VrfTables.class);
final VpnInstanceOpDataEntry vpnInstance = getFibUtil().getVpnInstanceOpData(vrfTableKey.getRouteDistinguisher()).get();
if (vpnInstance == null) {
LOG.error("VPN Instance for rd {} is not available from VPN Op Instance Datastore", rd);
return;
}
VpnNexthop localNextHopInfo = nexthopManager.getVpnNexthop(vpnInstance.getVpnId(), vrfEntry.getDestPrefix());
List<BigInteger> localDpnId = checkDeleteLocalEvpnFLows(vpnInstance.getVpnId(), rd, vrfEntry, localNextHopInfo);
deleteRemoteEvpnFlows(rd, vrfEntry, vpnInstance, vrfTableKey, localDpnId);
vrfEntryListener.cleanUpOpDataForFib(vpnInstance.getVpnId(), rd, vrfEntry);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry in project netvirt by opendaylight.
the class NeutronvpnUtils method updateVpnInstanceWithFallback.
public void updateVpnInstanceWithFallback(String vpnName, boolean add) {
VpnInstanceOpDataEntry vpnInstanceOpDataEntry = getVpnInstanceOpDataEntryFromVpnId(vpnName);
if (vpnInstanceOpDataEntry == null) {
// BGPVPN context not found
return;
}
String routerIdUuid = getRouterIdfromVpnInstance(vpnInstanceOpDataEntry.getVrfId());
if (routerIdUuid != null) {
List<BigInteger> dpnIds = getDpnsForRouter(routerIdUuid);
if (!dpnIds.isEmpty()) {
Long vpnId = vpnInstanceOpDataEntry.getVpnId();
VpnInstanceOpDataEntry vpnOpDataEntry = getVpnInstanceOpDataEntryFromVpnId(routerIdUuid);
Long routerIdAsLong = vpnOpDataEntry.getVpnId();
if (routerIdAsLong == null) {
return;
}
for (BigInteger dpnId : dpnIds) {
if (add) {
ipV6InternetDefRt.installDefaultRoute(dpnId, vpnId, routerIdAsLong);
} else {
ipV6InternetDefRt.removeDefaultRoute(dpnId, vpnId, routerIdAsLong);
}
}
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry in project netvirt by opendaylight.
the class NeutronvpnUtils method shouldVpnHandleIpVersionChoiceChangeToAdd.
public boolean shouldVpnHandleIpVersionChoiceChangeToAdd(IpVersionChoice ipVersion, Uuid vpnId) {
VpnInstanceOpDataEntry vpnInstanceOpDataEntry = getVpnInstanceOpDataEntryFromVpnId(vpnId.getValue());
if (vpnInstanceOpDataEntry == null) {
return false;
}
if (vpnInstanceOpDataEntry.getType() == VpnInstanceOpDataEntry.Type.L2) {
LOG.error("shouldVpnHandleIpVersionChangeToAdd: {} " + "VpnInstanceOpDataEntry is L2 instance. Do nothing.", vpnId.getValue());
return false;
}
boolean isIpv4Configured = vpnInstanceOpDataEntry.isIpv4Configured();
boolean isVpnInstanceIpv4Changed = false;
if (ipVersion.isIpVersionChosen(IpVersionChoice.IPV4) && !isIpv4Configured) {
isVpnInstanceIpv4Changed = true;
}
boolean isIpv6Configured = vpnInstanceOpDataEntry.isIpv6Configured();
boolean isVpnInstanceIpv6Changed = false;
if (ipVersion.isIpVersionChosen(IpVersionChoice.IPV6) && !isIpv6Configured) {
isVpnInstanceIpv6Changed = true;
}
if (!isVpnInstanceIpv4Changed && !isVpnInstanceIpv6Changed) {
LOG.debug("shouldVpnHandleIpVersionChangeToAdd: VPN {} did not change with IpFamily {}", vpnId.getValue(), ipVersion.toString());
return false;
}
return true;
}
Aggregations