Search in sources :

Example 61 with VpnInstanceOpDataEntry

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);
            }
        }
    }
}
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)

Example 62 with VpnInstanceOpDataEntry

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;
        });
    }
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) 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) BigInteger(java.math.BigInteger) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) Routes(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.to.extraroutes.vpn.extra.routes.Routes)

Example 63 with VpnInstanceOpDataEntry

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);
}
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) BigInteger(java.math.BigInteger) VpnNexthop(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3nexthop.rev150409.l3nexthop.vpnnexthops.VpnNexthop)

Example 64 with VpnInstanceOpDataEntry

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);
                }
            }
        }
    }
}
Also used : VpnInstanceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry) BigInteger(java.math.BigInteger)

Example 65 with VpnInstanceOpDataEntry

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;
}
Also used : VpnInstanceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry)

Aggregations

VpnInstanceOpDataEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry)61 ArrayList (java.util.ArrayList)28 BigInteger (java.math.BigInteger)26 VrfEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry)23 VpnToDpnList (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnList)23 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)21 VrfTablesKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTablesKey)17 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)14 ExecutionException (java.util.concurrent.ExecutionException)14 AdjacenciesOp (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.AdjacenciesOp)14 Adjacency (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.adjacency.list.Adjacency)13 List (java.util.List)12 Prefixes (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.prefix.to._interface.vpn.ids.Prefixes)12 Optional (com.google.common.base.Optional)11 RouteOrigin (org.opendaylight.netvirt.fibmanager.api.RouteOrigin)11 VrfTables (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTables)11 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)11 Collections (java.util.Collections)10 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)10 LogicalDatastoreType (org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType)10