Search in sources :

Example 16 with VrfTablesKey

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTablesKey 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 17 with VrfTablesKey

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTablesKey in project netvirt by opendaylight.

the class VpnUtil method findVrfEntriesByNexthop.

public static List<VrfEntry> findVrfEntriesByNexthop(DataBroker broker, String rd, String nexthop) {
    InstanceIdentifier<VrfTables> vpnVrfTableIid = InstanceIdentifier.builder(FibEntries.class).child(VrfTables.class, new VrfTablesKey(rd)).build();
    Optional<VrfTables> vrfTablesOpc = read(broker, LogicalDatastoreType.CONFIGURATION, vpnVrfTableIid);
    List<VrfEntry> matches = new ArrayList<>();
    if (vrfTablesOpc.isPresent()) {
        VrfTables vrfTables = vrfTablesOpc.get();
        for (VrfEntry vrfEntry : vrfTables.getVrfEntry()) {
            vrfEntry.getRoutePaths().stream().filter(routePath -> routePath.getNexthopAddress() != null && routePath.getNexthopAddress().equals(nexthop)).findFirst().ifPresent(routePath -> matches.add(vrfEntry));
        }
    }
    return matches;
}
Also used : 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) VrfTables(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTables) ArrayList(java.util.ArrayList)

Example 18 with VrfTablesKey

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTablesKey in project netvirt by opendaylight.

the class VpnUtil method removeVrfEntries.

public static void removeVrfEntries(DataBroker broker, String rd, List<VrfEntry> vrfEntries) {
    InstanceIdentifier<VrfTables> vpnVrfTableIid = InstanceIdentifier.builder(FibEntries.class).child(VrfTables.class, new VrfTablesKey(rd)).build();
    WriteTransaction tx = broker.newWriteOnlyTransaction();
    for (VrfEntry vrfEntry : vrfEntries) {
        tx.delete(LogicalDatastoreType.CONFIGURATION, vpnVrfTableIid.child(VrfEntry.class, vrfEntry.getKey()));
    }
    tx.submit();
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) 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) VrfTables(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTables)

Example 19 with VrfTablesKey

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTablesKey in project netvirt by opendaylight.

the class L3vpnPopulator method addSubnetRouteFibEntry.

public void addSubnetRouteFibEntry(L3vpnInput input) {
    String rd = input.getRd();
    String vpnName = input.getVpnName();
    String prefix = input.getSubnetIp();
    String nextHop = input.getNextHopIp();
    long label = input.getLabel();
    long l3vni = input.getL3vni();
    long elantag = input.getElanTag();
    BigInteger dpnId = input.getDpnId();
    String networkName = input.getNetworkName();
    String gwMacAddress = input.getGatewayMac();
    SubnetRoute route = new SubnetRouteBuilder().setElantag(elantag).build();
    // Only case when a route is considered as directly connected
    RouteOrigin origin = RouteOrigin.CONNECTED;
    VrfEntry vrfEntry = FibHelper.getVrfEntryBuilder(prefix, label, nextHop, origin, networkName).addAugmentation(SubnetRoute.class, route).setL3vni(l3vni).setGatewayMacAddress(gwMacAddress).build();
    LOG.debug("Created vrfEntry for {} nexthop {} label {} and elantag {}", prefix, nextHop, label, elantag);
    InstanceIdentifier<VrfEntry> vrfEntryId = InstanceIdentifier.builder(FibEntries.class).child(VrfTables.class, new VrfTablesKey(rd)).child(VrfEntry.class, new VrfEntryKey(prefix)).build();
    Optional<VrfEntry> entry = MDSALUtil.read(broker, LogicalDatastoreType.CONFIGURATION, vrfEntryId);
    if (!entry.isPresent()) {
        List<VrfEntry> vrfEntryList = Collections.singletonList(vrfEntry);
        InstanceIdentifier.InstanceIdentifierBuilder<VrfTables> idBuilder = InstanceIdentifier.builder(FibEntries.class).child(VrfTables.class, new VrfTablesKey(rd));
        InstanceIdentifier<VrfTables> vrfTableId = idBuilder.build();
        VrfTables vrfTableNew = new VrfTablesBuilder().setRouteDistinguisher(rd).setVrfEntry(vrfEntryList).build();
        VpnUtil.syncUpdate(broker, LogicalDatastoreType.CONFIGURATION, vrfTableId, vrfTableNew);
        LOG.info("SUBNETROUTE: addSubnetRouteFibEntryToDS: Added vrfEntry for {} nexthop {} label {} rd {}" + " vpnName {}", prefix, nextHop, label, rd, vpnName);
    } else {
        // Found in MDSAL database
        VpnUtil.syncWrite(broker, LogicalDatastoreType.CONFIGURATION, vrfEntryId, vrfEntry);
        LOG.info("SUBNETROUTE: addSubnetRouteFibEntryToDS: Updated vrfEntry for {} nexthop {} label {} rd {}" + " vpnName {}", prefix, nextHop, label, rd, vpnName);
    }
    // Will be handled appropriately with the iRT patch for EVPN
    if (input.getEncapType().equals(VrfEntryBase.EncapType.Mplsgre)) {
        long vpnId = VpnUtil.getVpnId(broker, vpnName);
        addToLabelMapper(label, dpnId, prefix, Collections.singletonList(nextHop), vpnId, null, elantag, true, rd);
        List<VpnInstanceOpDataEntry> vpnsToImportRoute = VpnUtil.getVpnsImportingMyRoute(broker, vpnName);
        if (vpnsToImportRoute.size() > 0) {
            VrfEntry importingVrfEntry = FibHelper.getVrfEntryBuilder(prefix, label, nextHop, RouteOrigin.SELF_IMPORTED, networkName).addAugmentation(SubnetRoute.class, route).build();
            List<VrfEntry> importingVrfEntryList = Collections.singletonList(importingVrfEntry);
            for (VpnInstanceOpDataEntry vpnInstance : vpnsToImportRoute) {
                String importingRd = vpnInstance.getVrfId();
                InstanceIdentifier<VrfTables> importingVrfTableId = InstanceIdentifier.builder(FibEntries.class).child(VrfTables.class, new VrfTablesKey(importingRd)).build();
                VrfTables importingVrfTable = new VrfTablesBuilder().setRouteDistinguisher(importingRd).setVrfEntry(importingVrfEntryList).build();
                VpnUtil.syncUpdate(broker, LogicalDatastoreType.CONFIGURATION, importingVrfTableId, importingVrfTable);
                LOG.info("SUBNETROUTE: addSubnetRouteFibEntryToDS: Exported route rd {} prefix {} nexthop {}" + " label {} to vpn {} importingRd {}", rd, prefix, nextHop, label, vpnInstance.getVpnInstanceName(), importingRd);
            }
        }
    }
    LOG.info("SUBNETROUTE: addSubnetRouteFibEntryToDS: Created vrfEntry for {} nexthop {} label {} and elantag {}" + "rd {} vpnName {}", prefix, nextHop, label, elantag, rd, vpnName);
}
Also used : VrfTablesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTablesBuilder) SubnetRoute(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.SubnetRoute) FibEntries(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.FibEntries) RouteOrigin(org.opendaylight.netvirt.fibmanager.api.RouteOrigin) SubnetRouteBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.SubnetRouteBuilder) VrfEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntryKey) VrfEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry) 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) VrfTables(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTables) BigInteger(java.math.BigInteger) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier)

Example 20 with VrfTablesKey

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTablesKey in project netvirt by opendaylight.

the class VPNServiceChainHandlerTest method stubGetVrfEntries.

private void stubGetVrfEntries(String rd, List<VrfEntry> vrfEntryList) throws Exception {
    VrfTables tables = new VrfTablesBuilder().setKey(new VrfTablesKey(rd)).setRouteDistinguisher(rd).setVrfEntry(vrfEntryList).build();
    CheckedFuture chkdFuture = mock(CheckedFuture.class);
    when(chkdFuture.checkedGet()).thenReturn(Optional.of(tables));
    when(readTx.read(eq(LogicalDatastoreType.CONFIGURATION), eq(VpnServiceChainUtils.buildVrfId(rd)))).thenReturn(chkdFuture);
}
Also used : VrfTablesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTablesBuilder) VrfTablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTablesKey) VrfTables(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTables) CheckedFuture(com.google.common.util.concurrent.CheckedFuture)

Aggregations

VrfTablesKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTablesKey)40 VrfEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry)22 FibEntries (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.FibEntries)21 VrfTables (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTables)19 VrfEntryKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntryKey)16 ArrayList (java.util.ArrayList)11 BigInteger (java.math.BigInteger)10 MacVrfEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.macvrfentries.MacVrfEntry)9 VpnInstanceOpDataEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry)9 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)8 MacVrfEntryKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.macvrfentries.MacVrfEntryKey)7 VpnToDpnList (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnList)7 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)6 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)5 SubnetRoute (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.SubnetRoute)5 RoutePaths (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentrybase.RoutePaths)5 Routes (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.to.extraroutes.vpn.extra.routes.Routes)5 RouteOrigin (org.opendaylight.netvirt.fibmanager.api.RouteOrigin)4 ExecutionException (java.util.concurrent.ExecutionException)3 VrfTablesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTablesBuilder)3