Search in sources :

Example 1 with VrfTablesKey

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

the class EvpnMacVrfUtils method updateEvpnDmacFlows.

public void updateEvpnDmacFlows(final ElanInstance elanInstance, final boolean install) {
    String rd = evpnUtils.getEvpnRd(elanInstance);
    if (rd == null) {
        return;
    }
    final InstanceIdentifier<VrfTables> iid = InstanceIdentifier.create(FibEntries.class).child(VrfTables.class, new VrfTablesKey(rd));
    evpnUtils.asyncReadAndExecute(LogicalDatastoreType.CONFIGURATION, iid, new StringBuilder(elanInstance.getElanInstanceName()).append(":").append(rd).toString(), (vrfTablesOptional) -> {
        if (!vrfTablesOptional.isPresent()) {
            return null;
        }
        List<MacVrfEntry> macVrfEntries = vrfTablesOptional.get().getMacVrfEntry();
        if (macVrfEntries == null || macVrfEntries.isEmpty()) {
            return null;
        }
        for (MacVrfEntry macVrfEntry : macVrfEntries) {
            InstanceIdentifier<MacVrfEntry> macVrfEntryIid = getMacVrfEntryIid(rd, macVrfEntry);
            if (install) {
                addEvpnDmacFlowOnAttach(macVrfEntryIid, macVrfEntry, elanInstance);
            } else {
                removeEvpnDmacFlowOnDetach(macVrfEntryIid, macVrfEntry, elanInstance);
            }
        }
        return null;
    });
}
Also used : 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) FibEntries(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.FibEntries) MacVrfEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.macvrfentries.MacVrfEntry)

Example 2 with VrfTablesKey

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

the class VpnInterfaceManager method importSubnetRouteForNewVpn.

public synchronized void importSubnetRouteForNewVpn(String rd, String prefix, String nextHop, int label, SubnetRoute route, WriteTransaction writeConfigTxn) {
    RouteOrigin origin = RouteOrigin.SELF_IMPORTED;
    VrfEntry vrfEntry = FibHelper.getVrfEntryBuilder(prefix, label, nextHop, origin, null).addAugmentation(SubnetRoute.class, route).build();
    List<VrfEntry> vrfEntryList = Collections.singletonList(vrfEntry);
    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();
    if (writeConfigTxn != null) {
        writeConfigTxn.merge(LogicalDatastoreType.CONFIGURATION, vrfTableId, vrfTableNew, true);
    } else {
        VpnUtil.syncUpdate(dataBroker, LogicalDatastoreType.CONFIGURATION, vrfTableId, vrfTableNew);
    }
    LOG.info("SUBNETROUTE: importSubnetRouteForNewVpn: Created vrfEntry for rd {} prefix {} nexthop {} label {}" + " and elantag {}", rd, prefix, nextHop, label, route.getElantag());
}
Also used : 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) VrfTablesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTablesBuilder) VrfTables(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTables) 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)

Example 3 with VrfTablesKey

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

the class FibEntriesListener method add.

@Override
protected void add(InstanceIdentifier<VrfEntry> identifier, VrfEntry add) {
    LOG.trace("Add Vrf Entry event - Key : {}, value : {}", identifier, add);
    final VrfTablesKey key = identifier.firstKeyOf(VrfTables.class, VrfTablesKey.class);
    String rd = key.getRouteDistinguisher();
    addLabelToVpnInstance(rd, add.getRoutePaths());
}
Also used : VrfTablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTablesKey)

Example 4 with VrfTablesKey

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

the class FibDSWriter method removeOrUpdateFibEntryFromDS.

public synchronized void removeOrUpdateFibEntryFromDS(String rd, String prefix, String nextHop) {
    if (rd == null || rd.isEmpty()) {
        LOG.error("Prefix {} not associated with vpn", prefix);
        return;
    }
    LOG.debug("Removing fib entry with destination prefix {} from vrf table for rd {} and nextHop {}", prefix, rd, nextHop);
    try {
        InstanceIdentifier<VrfEntry> vrfEntryId = InstanceIdentifier.builder(FibEntries.class).child(VrfTables.class, new VrfTablesKey(rd)).child(VrfEntry.class, new VrfEntryKey(prefix)).build();
        Optional<VrfEntry> existingVrfEntry = singleTxDB.syncReadOptional(LogicalDatastoreType.CONFIGURATION, vrfEntryId);
        List<RoutePaths> routePaths = existingVrfEntry.toJavaUtil().map(VrfEntry::getRoutePaths).orElse(Collections.emptyList());
        if (routePaths.size() == 1) {
            if (routePaths.get(0).getNexthopAddress().equals(nextHop)) {
                bgpUtil.delete(vrfEntryId);
            }
        } else {
            routePaths.stream().map(RoutePaths::getNexthopAddress).filter(nextHopAddress -> nextHopAddress.equals(nextHop)).findFirst().ifPresent(nh -> {
                InstanceIdentifier<RoutePaths> routePathId = FibHelper.buildRoutePathId(rd, prefix, nextHop);
                bgpUtil.delete(routePathId);
            });
        }
    } catch (ReadFailedException e) {
        LOG.error("Error while reading vrfEntry for rd {}, prefix {}", rd, prefix);
        return;
    }
}
Also used : MacVrfEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.macvrfentries.MacVrfEntry) 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) ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) FibEntries(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.FibEntries) RoutePaths(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentrybase.RoutePaths) MacVrfEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.macvrfentries.MacVrfEntryKey) VrfEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntryKey)

Example 5 with VrfTablesKey

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

the class FibDSWriter method removeVrfSubFamilyFromDS.

public synchronized void removeVrfSubFamilyFromDS(String rd, AddressFamily addressFamily) {
    if (rd == null) {
        return;
    }
    LOG.debug("removeVrfSubFamilyFromDS : addressFamily {} from vrf rd {}", addressFamily, rd);
    InstanceIdentifier<VrfTables> id = InstanceIdentifier.create(FibEntries.class).child(VrfTables.class, new VrfTablesKey(rd));
    try {
        VrfTables vrfTable = singleTxDB.syncRead(LogicalDatastoreType.CONFIGURATION, id);
        if (vrfTable != null) {
            List<VrfEntry> vrfEntries = vrfTable.getVrfEntry();
            if (vrfEntries == null) {
                LOG.error("removeVrfSubFamilyFromDS : VrfEntry not found for rd {}", rd);
                return;
            }
            for (VrfEntry vrfEntry : vrfEntries) {
                boolean found = false;
                if (vrfEntry.getEncapType() != null) {
                    if (!vrfEntry.getEncapType().equals(EncapType.Mplsgre) && addressFamily == AddressFamily.L2VPN) {
                        found = true;
                    } else if (vrfEntry.getEncapType().equals(EncapType.Mplsgre)) {
                        if (addressFamily == AddressFamily.IPV4 && FibHelper.isIpv4Prefix(vrfEntry.getDestPrefix())) {
                            found = true;
                        } else if (addressFamily == AddressFamily.IPV6 && FibHelper.isIpv6Prefix(vrfEntry.getDestPrefix())) {
                            found = true;
                        }
                    }
                }
                if (found == false) {
                    continue;
                }
                bgpUtil.removeVrfEntry(rd, vrfEntry);
            }
        }
    } catch (ReadFailedException rfe) {
        LOG.error("removeVrfSubFamilyFromDS : Internal Error rd {}", rd, rfe);
    }
    return;
}
Also used : VrfTablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTablesKey) MacVrfEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.macvrfentries.MacVrfEntry) VrfEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry) ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) VrfTables(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTables) FibEntries(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.FibEntries)

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