Search in sources :

Example 96 with VpnInstance

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.instances.VpnInstance in project netvirt by opendaylight.

the class VrfEntryListener method manageRemoteRouteOnDPN.

public void manageRemoteRouteOnDPN(final boolean action, final Uint64 localDpnId, final Uint32 vpnId, final String rd, final String destPrefix, final String destTepIp, final Uint32 label) {
    final VpnInstanceOpDataEntry vpnInstance = fibUtil.getVpnInstance(rd);
    if (vpnInstance == null) {
        LOG.error("VpnInstance for rd {} not present for prefix {}", rd, destPrefix);
        return;
    }
    jobCoordinator.enqueueJob(FibUtil.getJobKeyForVpnIdDpnId(vpnId, localDpnId), () -> Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> {
        final ReentrantLock lock = lockFor(vpnInstance);
        lock.lock();
        try {
            VrfTablesKey vrfTablesKey = new VrfTablesKey(rd);
            VrfEntry vrfEntry = getVrfEntry(dataBroker, rd, destPrefix);
            if (vrfEntry == null) {
                return;
            }
            LOG.trace("manageRemoteRouteOnDPN :: action {}, DpnId {}, vpnId {}, rd {}, destPfx {}", action, localDpnId, vpnId, rd, destPrefix);
            Map<RoutePathsKey, RoutePaths> keyRoutePathsMap = vrfEntry.getRoutePaths();
            VrfEntry modVrfEntry;
            if (keyRoutePathsMap == null || keyRoutePathsMap.isEmpty()) {
                modVrfEntry = FibHelper.getVrfEntryBuilder(vrfEntry, label, Collections.singletonList(destTepIp), RouteOrigin.value(vrfEntry.getOrigin()), null).build();
            } else {
                modVrfEntry = vrfEntry;
            }
            if (action) {
                LOG.trace("manageRemoteRouteOnDPN updated(add)  vrfEntry :: {}", modVrfEntry);
                createRemoteFibEntry(localDpnId, vpnId, vrfTablesKey.getRouteDistinguisher(), modVrfEntry, tx);
            } else {
                LOG.trace("manageRemoteRouteOnDPN updated(remove)  vrfEntry :: {}", modVrfEntry);
                List<String> usedRds = VpnExtraRouteHelper.getUsedRds(dataBroker, vpnInstance.getVpnId(), vrfEntry.getDestPrefix());
                if (usedRds.size() > 1) {
                    LOG.debug("The extra route prefix is still present in some DPNs");
                    return;
                }
                // Is this fib route an extra route? If yes, get the nexthop which would be
                // an adjacency in the vpn
                Optional<Routes> extraRouteOptional = Optional.empty();
                if (RouteOrigin.value(vrfEntry.getOrigin()) == RouteOrigin.STATIC && usedRds.size() != 0) {
                    extraRouteOptional = VpnExtraRouteHelper.getVpnExtraroutes(dataBroker, fibUtil.getVpnNameFromId(vpnInstance.getVpnId()), usedRds.get(0), vrfEntry.getDestPrefix());
                }
                baseVrfEntryHandler.deleteRemoteRoute(null, localDpnId, vpnId, vrfTablesKey, modVrfEntry, extraRouteOptional, TransactionAdapter.toWriteTransaction(tx));
            }
        } finally {
            lock.unlock();
        }
    })));
}
Also used : ReentrantLock(java.util.concurrent.locks.ReentrantLock) VrfTablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTablesKey) VrfEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry) VpnInstanceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry) RoutePaths(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentrybase.RoutePaths) Routes(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.to.extraroutes.vpn.extra.routes.Routes) RoutePathsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentrybase.RoutePathsKey)

Example 97 with VpnInstance

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.instances.VpnInstance in project netvirt by opendaylight.

the class EvpnVrfEntryHandler method removeFlows.

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<Uint64> localDpnId = checkDeleteLocalEvpnFLows(vpnInstance.getVpnId(), rd, vrfEntry, localNextHopInfo);
    deleteRemoteEvpnFlows(rd, vrfEntry, vpnInstance, vrfTableKey, localDpnId);
    vrfEntryListener.cleanUpOpDataForFib(vpnInstance.getVpnId(), rd, vrfEntry);
}
Also used : VrfTablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTablesKey) VpnInstanceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry) VpnNexthop(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3nexthop.rev150409.l3nexthop.vpnnexthops.VpnNexthop) Uint64(org.opendaylight.yangtools.yang.common.Uint64)

Example 98 with VpnInstance

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.instances.VpnInstance 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 Map<VpnToDpnListKey, VpnToDpnList> keyVpnToDpnListMap = vpnInstance.nonnullVpnToDpnList();
    if (keyVpnToDpnListMap != 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.empty();
        }
        for (VpnToDpnList curDpn : keyVpnToDpnListMap.values()) {
            if (curDpn.getDpnState() == VpnToDpnList.DpnState.Active) {
                deleteRemoteRoute(Uint64.ZERO, curDpn.getDpnId(), vpnInstance.getVpnId(), vrfTableKey, vrfEntry, extraRouteOptional, writeTx, subTxns);
            }
        }
    }
}
Also used : VrfTablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTablesKey) VpnInstanceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry) VpnToDpnList(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnList) Routes(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.to.extraroutes.vpn.extra.routes.Routes) VpnToDpnListKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnListKey)

Example 99 with VpnInstance

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.instances.VpnInstance in project netvirt by opendaylight.

the class FibUtil method updateUsedRdAndVpnToExtraRoute.

public void updateUsedRdAndVpnToExtraRoute(TypedReadWriteTransaction<Configuration> confTx, TypedReadWriteTransaction<Operational> operTx, String tunnelIpRemoved, String primaryRd, String prefix) throws ExecutionException, InterruptedException {
    Optional<VpnInstanceOpDataEntry> optVpnInstance = getVpnInstanceOpData(operTx, primaryRd);
    if (!optVpnInstance.isPresent()) {
        return;
    }
    VpnInstanceOpDataEntry vpnInstance = optVpnInstance.get();
    String vpnName = vpnInstance.getVpnInstanceName();
    Uint32 vpnId = vpnInstance.getVpnId();
    List<String> usedRds = VpnExtraRouteHelper.getUsedRds(confTx, vpnId, prefix);
    // which rd is allocated for the particular OVS.
    for (String usedRd : usedRds) {
        Optional<Routes> vpnExtraRoutes = VpnExtraRouteHelper.getVpnExtraroutes(operTx, vpnName, usedRd, prefix);
        if (vpnExtraRoutes.isPresent()) {
            // Since all the nexthops under one OVS will be present under one rd, only 1 nexthop is read
            // to identify the OVS
            String nextHopRemoved = vpnExtraRoutes.get().getNexthopIpList().get(0);
            Prefixes prefixToInterface = getPrefixToInterface(operTx, vpnId, getIpPrefix(nextHopRemoved));
            if (prefixToInterface != null && tunnelIpRemoved.equals(getEndpointIpAddressForDPN(prefixToInterface.getDpnId()))) {
                LOG.info("updating data-stores for prefix {} with primaryRd {} for interface {} on vpn {} ", prefix, primaryRd, prefixToInterface.getVpnInterfaceName(), vpnName);
                operTx.delete(FibUtil.getAdjacencyIdentifierOp(prefixToInterface.getVpnInterfaceName(), vpnName, prefix));
                operTx.delete(VpnExtraRouteHelper.getVpnToExtrarouteVrfIdIdentifier(vpnName, usedRd, prefix));
                MDSALUtil.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, VpnExtraRouteHelper.getUsedRdsIdentifier(vpnId, prefix, nextHopRemoved));
                break;
            }
        }
    }
}
Also used : VpnInstanceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry) Routes(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.to.extraroutes.vpn.extra.routes.Routes) Prefixes(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.prefix.to._interface.vpn.ids.Prefixes) Uint32(org.opendaylight.yangtools.yang.common.Uint32)

Example 100 with VpnInstance

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.instances.VpnInstance in project netvirt by opendaylight.

the class EvpnVrfEntryHandler method deleteRemoteEvpnFlows.

// Allow deprecated TransactionRunner calls for now
@SuppressWarnings("ForbidCertainMethod")
private void deleteRemoteEvpnFlows(String rd, VrfEntry vrfEntry, VpnInstanceOpDataEntry vpnInstance, VrfTablesKey vrfTableKey, List<Uint64> localDpnIdList) {
    Map<VpnToDpnListKey, VpnToDpnList> keyVpnToDpnListMap = vpnInstance.nonnullVpnToDpnList();
    List<SubTransaction> subTxns = new ArrayList<>();
    if (keyVpnToDpnListMap != null) {
        jobCoordinator.enqueueJob("FIB" + rd + vrfEntry.getDestPrefix(), () -> Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(Datastore.CONFIGURATION, tx -> {
            final Optional<Routes> extraRouteOptional = Optional.empty();
            if (localDpnIdList.size() <= 0) {
                for (VpnToDpnList curDpn1 : keyVpnToDpnListMap.values()) {
                    if (RouteOrigin.value(vrfEntry.getOrigin()) == RouteOrigin.BGP) {
                        if (curDpn1.getDpnState() == VpnToDpnList.DpnState.Active) {
                            bgpRouteVrfEntryHandler.deleteRemoteRoute(Uint64.ZERO, curDpn1.getDpnId(), vpnInstance.getVpnId(), vrfTableKey, vrfEntry, extraRouteOptional, TransactionAdapter.toWriteTransaction(tx), subTxns);
                        }
                    } else {
                        deleteRemoteRoute(Uint64.ZERO, curDpn1.getDpnId(), vpnInstance.getVpnId(), vrfTableKey, vrfEntry, extraRouteOptional, TransactionAdapter.toWriteTransaction(tx));
                    }
                }
            } else {
                for (Uint64 localDpnId : localDpnIdList) {
                    for (VpnToDpnList curDpn2 : keyVpnToDpnListMap.values()) {
                        if (!Objects.equals(curDpn2.getDpnId(), localDpnId)) {
                            if (RouteOrigin.value(vrfEntry.getOrigin()) == RouteOrigin.BGP) {
                                if (curDpn2.getDpnState() == VpnToDpnList.DpnState.Active) {
                                    bgpRouteVrfEntryHandler.deleteRemoteRoute(localDpnId, curDpn2.getDpnId(), vpnInstance.getVpnId(), vrfTableKey, vrfEntry, extraRouteOptional, TransactionAdapter.toWriteTransaction(tx), subTxns);
                                }
                            } else {
                                deleteRemoteRoute(localDpnId, curDpn2.getDpnId(), vpnInstance.getVpnId(), vrfTableKey, vrfEntry, extraRouteOptional, TransactionAdapter.toWriteTransaction(tx));
                            }
                        }
                    }
                }
            }
        })));
    }
}
Also used : VpnToDpnList(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnList) SubTransaction(org.opendaylight.genius.utils.batching.SubTransaction) ArrayList(java.util.ArrayList) Routes(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.to.extraroutes.vpn.extra.routes.Routes) VpnToDpnListKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnListKey) Uint64(org.opendaylight.yangtools.yang.common.Uint64)

Aggregations

ArrayList (java.util.ArrayList)62 VpnInstanceOpDataEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry)40 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)37 ExecutionException (java.util.concurrent.ExecutionException)36 VpnInstance (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.instances.VpnInstance)31 Uint32 (org.opendaylight.yangtools.yang.common.Uint32)26 List (java.util.List)24 VpnToDpnList (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnList)23 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)22 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)22 Logger (org.slf4j.Logger)22 LoggerFactory (org.slf4j.LoggerFactory)22 Inject (javax.inject.Inject)21 Singleton (javax.inject.Singleton)21 VpnInterfaceOpDataEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn._interface.op.data.VpnInterfaceOpDataEntry)21 Uint64 (org.opendaylight.yangtools.yang.common.Uint64)20 FutureCallback (com.google.common.util.concurrent.FutureCallback)19 Futures (com.google.common.util.concurrent.Futures)19 MoreExecutors (com.google.common.util.concurrent.MoreExecutors)19 Collections (java.util.Collections)19