Search in sources :

Example 1 with Evpn

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.createevpn.input.Evpn in project netvirt by opendaylight.

the class EvpnVrfEntryHandler method createRemoteEvpnFlows.

private void createRemoteEvpnFlows(String rd, VrfEntry vrfEntry, VpnInstanceOpDataEntry vpnInstance, List<BigInteger> localDpnId, VrfTablesKey vrfTableKey, boolean isNatPrefix) {
    LOG.info("Creating remote EVPN flows for prefix {} rd {} route-paths {} evi {}", vrfEntry.getDestPrefix(), rd, vrfEntry.getRoutePaths(), vrfEntry.getL3vni());
    List<VpnToDpnList> vpnToDpnList = vpnInstance.getVpnToDpnList();
    if (vpnToDpnList != null) {
        jobCoordinator.enqueueJob("FIB" + rd + vrfEntry.getDestPrefix(), () -> {
            WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
            List<ListenableFuture<Void>> futures = new ArrayList<>();
            for (VpnToDpnList vpnDpn : vpnToDpnList) {
                if (!localDpnId.contains(vpnDpn.getDpnId())) {
                    if (vpnDpn.getDpnState() == VpnToDpnList.DpnState.Active) {
                        createRemoteFibEntry(vpnDpn.getDpnId(), vpnInstance.getVpnId(), vrfTableKey, vrfEntry, isNatPrefix, tx);
                    }
                }
            }
            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) ArrayList(java.util.ArrayList) ListenableFuture(com.google.common.util.concurrent.ListenableFuture)

Example 2 with Evpn

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.createevpn.input.Evpn in project netvirt by opendaylight.

the class EvpnVrfEntryHandler method createFlows.

@Override
public void createFlows(InstanceIdentifier<VrfEntry> identifier, VrfEntry vrfEntry, String rd) {
    LOG.info("Initiating creation of Evpn Flows");
    final VrfTablesKey vrfTableKey = identifier.firstKeyOf(VrfTables.class);
    final VpnInstanceOpDataEntry vpnInstance = getFibUtil().getVpnInstanceOpData(vrfTableKey.getRouteDistinguisher()).get();
    Long vpnId = vpnInstance.getVpnId();
    Preconditions.checkNotNull(vpnInstance, "Vpn Instance not available " + vrfTableKey.getRouteDistinguisher());
    Preconditions.checkNotNull(vpnId, "Vpn Instance with rd " + vpnInstance.getVrfId() + " has null vpnId!");
    if (RouteOrigin.value(vrfEntry.getOrigin()) == RouteOrigin.CONNECTED) {
        SubnetRoute subnetRoute = vrfEntry.getAugmentation(SubnetRoute.class);
        final List<VpnToDpnList> vpnToDpnList = vpnInstance.getVpnToDpnList();
        final long elanTag = subnetRoute.getElantag();
        LOG.trace("SubnetRoute augmented vrfentry found for rd {} prefix {} with elantag {}", rd, vrfEntry.getDestPrefix(), elanTag);
        if (vpnToDpnList != null) {
            jobCoordinator.enqueueJob("FIB-" + rd + "-" + vrfEntry.getDestPrefix(), () -> {
                WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
                for (final VpnToDpnList curDpn : vpnToDpnList) {
                    if (curDpn.getDpnState() == VpnToDpnList.DpnState.Active) {
                        vrfEntryListener.installSubnetRouteInFib(curDpn.getDpnId(), elanTag, rd, vpnId, vrfEntry, tx);
                    }
                }
                List<ListenableFuture<Void>> futures = new ArrayList<>();
                futures.add(tx.submit());
                return futures;
            });
        }
        return;
    }
    Prefixes localNextHopInfo = getFibUtil().getPrefixToInterface(vpnInstance.getVpnId(), vrfEntry.getDestPrefix());
    List<BigInteger> localDpnId = new ArrayList<>();
    boolean isNatPrefix = false;
    if (Prefixes.PrefixCue.Nat.equals(localNextHopInfo.getPrefixCue())) {
        LOG.info("NAT Prefix {} with vpnId {} rd {}. Skip local dpn {} FIB processing", vrfEntry.getDestPrefix(), vpnId, rd, localNextHopInfo.getDpnId());
        localDpnId.add(localNextHopInfo.getDpnId());
        isNatPrefix = true;
    } else {
        localDpnId = createLocalEvpnFlows(vpnInstance.getVpnId(), rd, vrfEntry, localNextHopInfo);
    }
    createRemoteEvpnFlows(rd, vrfEntry, vpnInstance, localDpnId, vrfTableKey, isNatPrefix);
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) SubnetRoute(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.SubnetRoute) VpnToDpnList(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnList) ArrayList(java.util.ArrayList) Prefixes(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.prefix.to._interface.vpn.ids.Prefixes) 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) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) BigInteger(java.math.BigInteger)

Example 3 with Evpn

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.createevpn.input.Evpn in project netvirt by opendaylight.

the class EvpnVrfEntryHandler method createLocalEvpnFlows.

private List<BigInteger> createLocalEvpnFlows(long vpnId, String rd, VrfEntry vrfEntry, Prefixes localNextHopInfo) {
    List<BigInteger> returnLocalDpnId = new ArrayList<>();
    String localNextHopIP = vrfEntry.getDestPrefix();
    if (localNextHopInfo == null) {
        // Handle extra routes and imported routes
        Routes extraRoute = getVpnToExtraroute(vpnId, rd, vrfEntry.getDestPrefix());
        if (extraRoute != null) {
            for (String nextHopIp : extraRoute.getNexthopIpList()) {
                LOG.info("NextHop IP for destination {} is {}", vrfEntry.getDestPrefix(), nextHopIp);
                if (nextHopIp != null) {
                    localNextHopInfo = getFibUtil().getPrefixToInterface(vpnId, nextHopIp + "/32");
                    if (localNextHopInfo != null) {
                        localNextHopIP = nextHopIp + "/32";
                        BigInteger dpnId = checkCreateLocalEvpnFlows(localNextHopInfo, localNextHopIP, vpnId, rd, vrfEntry);
                        returnLocalDpnId.add(dpnId);
                    }
                }
            }
        }
    } else {
        LOG.info("Creating local EVPN flows for prefix {} rd {} route-paths {} evi {}.", vrfEntry.getDestPrefix(), rd, vrfEntry.getRoutePaths(), vrfEntry.getL3vni());
        BigInteger dpnId = checkCreateLocalEvpnFlows(localNextHopInfo, localNextHopIP, vpnId, rd, vrfEntry);
        returnLocalDpnId.add(dpnId);
    }
    return returnLocalDpnId;
}
Also used : ArrayList(java.util.ArrayList) BigInteger(java.math.BigInteger) Routes(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.to.extraroutes.vpn.extra.routes.Routes)

Example 4 with Evpn

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.createevpn.input.Evpn in project netvirt by opendaylight.

the class ElanServiceTest method createElanInstanceAndInterfaceAndAttachEvpn.

public void createElanInstanceAndInterfaceAndAttachEvpn() throws ReadFailedException, TransactionCommitFailedException {
    // Create Elan instance
    createElanInstance(ExpectedObjects.ELAN1, ExpectedObjects.ELAN1_SEGMENT_ID);
    awaitForElanTag(ExpectedObjects.ELAN1);
    // Read Elan Instance
    InstanceIdentifier<ElanInstance> elanInstanceIid = InstanceIdentifier.builder(ElanInstances.class).child(ElanInstance.class, new ElanInstanceKey(ExpectedObjects.ELAN1)).build();
    ElanInstance elanInstance = singleTxdataBroker.syncRead(CONFIGURATION, elanInstanceIid);
    // Add Elan interface
    addElanInterface(ExpectedObjects.ELAN1, ELAN_INTERFACES.get(ELAN1 + ":" + DPN1MAC1).getLeft(), DPN1IP1);
    // Attach EVPN to networks
    evpnTestHelper.attachEvpnToNetwork(elanInstance);
}
Also used : ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance) ElanInstanceKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstanceKey)

Example 5 with Evpn

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.createevpn.input.Evpn in project netvirt by opendaylight.

the class EvpnTestHelper method updateRdtoNetworks.

public void updateRdtoNetworks(ElanInstance actualElanInstances) throws TransactionCommitFailedException {
    EvpnRdToNetworkBuilder evpnRdToNetworkBuilder = new EvpnRdToNetworkBuilder().setKey(new EvpnRdToNetworkKey(RD));
    evpnRdToNetworkBuilder.setRd(RD);
    evpnRdToNetworkBuilder.setNetworkId(ELAN1);
    LOG.info("updating Evpn {} with elaninstance {} and rd {}", "evpn1", actualElanInstances, RD);
    singleTxdataBroker.syncWrite(LogicalDatastoreType.CONFIGURATION, getRdToNetworkIdentifier(RD), evpnRdToNetworkBuilder.build());
}
Also used : EvpnRdToNetworkKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.evpn.rd.to.networks.EvpnRdToNetworkKey) EvpnRdToNetworkBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.evpn.rd.to.networks.EvpnRdToNetworkBuilder)

Aggregations

ArrayList (java.util.ArrayList)8 ByteBuf (io.netty.buffer.ByteBuf)5 VpnInstance (org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.instances.VpnInstance)4 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)3 BigInteger (java.math.BigInteger)3 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)3 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)3 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)3 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)2 NlriModelUtil.extractMplsLabel (org.opendaylight.protocol.bgp.evpn.impl.nlri.NlriModelUtil.extractMplsLabel)2 MplsLabelUtil.byteBufForMplsLabel (org.opendaylight.protocol.util.MplsLabelUtil.byteBufForMplsLabel)2 MplsLabelUtil.mplsLabelForByteBuf (org.opendaylight.protocol.util.MplsLabelUtil.mplsLabelForByteBuf)2 ElanInstance (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance)2 RouterInterface (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.RouterInterface)2 SubnetRoute (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.SubnetRoute)2 VrfTablesKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTablesKey)2 EvpnRdToNetworkBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.evpn.rd.to.networks.EvpnRdToNetworkBuilder)2 EvpnRdToNetworkKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.evpn.rd.to.networks.EvpnRdToNetworkKey)2 VpnInstanceOpDataEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry)2 VpnToDpnList (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnList)2