Search in sources :

Example 1 with LabelRouteInfoBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.label.route.map.LabelRouteInfoBuilder in project netvirt by opendaylight.

the class VpnInterfaceManager method updateLabelMapper.

private void updateLabelMapper(Long label, List<String> nextHopIpList) {
    Preconditions.checkNotNull(label, "updateLabelMapper: label cannot be null or empty!");
    synchronized (label.toString().intern()) {
        InstanceIdentifier<LabelRouteInfo> lriIid = InstanceIdentifier.builder(LabelRouteMap.class).child(LabelRouteInfo.class, new LabelRouteInfoKey(label)).build();
        Optional<LabelRouteInfo> opResult = VpnUtil.read(dataBroker, LogicalDatastoreType.OPERATIONAL, lriIid);
        if (opResult.isPresent()) {
            LabelRouteInfo labelRouteInfo = new LabelRouteInfoBuilder(opResult.get()).setNextHopIpList(nextHopIpList).build();
            MDSALUtil.syncWrite(dataBroker, LogicalDatastoreType.OPERATIONAL, lriIid, labelRouteInfo);
        }
    }
    LOG.info("updateLabelMapper: Updated label rotue info for label {} with nextHopList {}", label, nextHopIpList);
}
Also used : LabelRouteInfo(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.label.route.map.LabelRouteInfo) LabelRouteInfoBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.label.route.map.LabelRouteInfoBuilder) LabelRouteInfoKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.label.route.map.LabelRouteInfoKey)

Example 2 with LabelRouteInfoBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.label.route.map.LabelRouteInfoBuilder in project netvirt by opendaylight.

the class L3vpnPopulator method addToLabelMapper.

public void addToLabelMapper(Long label, BigInteger dpnId, String prefix, List<String> nextHopIpList, Long vpnId, String vpnInterfaceName, Long elanTag, boolean isSubnetRoute, String rd) {
    Preconditions.checkNotNull(label, "addToLabelMapper: label cannot be null or empty!");
    Preconditions.checkNotNull(prefix, "addToLabelMapper: prefix cannot be null or empty!");
    Preconditions.checkNotNull(vpnId, "addToLabelMapper: vpnId cannot be null or empty!");
    Preconditions.checkNotNull(rd, "addToLabelMapper: rd cannot be null or empty!");
    if (!isSubnetRoute) {
        // NextHop must be present for non-subnetroute entries
        Preconditions.checkNotNull(nextHopIpList, "addToLabelMapper: nextHopIp cannot be null or empty!");
    }
    synchronized (label.toString().intern()) {
        addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
            LOG.info("addToLabelMapper: label {} dpn {} prefix {} nexthoplist {} vpnid {} vpnIntfcName {} rd {}" + " elanTag {}", label, dpnId, prefix, nextHopIpList, vpnId, vpnInterfaceName, rd, elanTag);
            if (dpnId != null) {
                LabelRouteInfoBuilder lriBuilder = new LabelRouteInfoBuilder();
                lriBuilder.setLabel(label).setDpnId(dpnId).setPrefix(prefix).setNextHopIpList(nextHopIpList).setParentVpnid(vpnId).setIsSubnetRoute(isSubnetRoute);
                if (elanTag != null) {
                    lriBuilder.setElanTag(elanTag);
                } else {
                    LOG.warn("addToLabelMapper: elanTag is null for label {} prefix {} rd {} vpnId {}", label, prefix, rd, vpnId);
                }
                if (vpnInterfaceName != null) {
                    lriBuilder.setVpnInterfaceName(vpnInterfaceName);
                } else {
                    LOG.warn("addToLabelMapper: vpn interface is null for label {} prefix {} rd {} vpnId {}", label, prefix, rd, vpnId);
                }
                lriBuilder.setParentVpnRd(rd);
                VpnInstanceOpDataEntry vpnInstanceOpDataEntry = VpnUtil.getVpnInstanceOpData(broker, rd);
                if (vpnInstanceOpDataEntry != null) {
                    List<String> vpnInstanceNames = Collections.singletonList(vpnInstanceOpDataEntry.getVpnInstanceName());
                    lriBuilder.setVpnInstanceList(vpnInstanceNames);
                }
                LabelRouteInfo lri = lriBuilder.build();
                InstanceIdentifier<LabelRouteInfo> lriIid = InstanceIdentifier.builder(LabelRouteMap.class).child(LabelRouteInfo.class, new LabelRouteInfoKey(label)).build();
                tx.merge(LogicalDatastoreType.OPERATIONAL, lriIid, lri, true);
                LOG.info("addToLabelMapper: Added label route info to label {} prefix {} nextHopList {} vpnId {}" + " interface {} rd {} elantag {}", label, prefix, nextHopIpList, vpnId, vpnInterfaceName, rd, elanTag);
            } else {
                LOG.warn("addToLabelMapper: Can't add entry to label map for label {} prefix {} nextHopList {}" + " vpnId {} interface {} rd {} elantag {}, dpnId is null", label, prefix, nextHopIpList, vpnId, vpnInterfaceName, rd, elanTag);
            }
        }), LOG, "addToLabelMapper");
    }
}
Also used : IFibManager(org.opendaylight.netvirt.fibmanager.api.IFibManager) VpnUtil(org.opendaylight.netvirt.vpnmanager.VpnUtil) LabelRouteMap(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.LabelRouteMap) FibEntries(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.FibEntries) LoggerFactory(org.slf4j.LoggerFactory) VrfEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry) ListenableFutures.addErrorLogging(org.opendaylight.infrautils.utils.concurrent.ListenableFutures.addErrorLogging) LabelRouteInfoKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.label.route.map.LabelRouteInfoKey) Optional(com.google.common.base.Optional) ManagedNewTransactionRunnerImpl(org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl) IBgpManager(org.opendaylight.netvirt.bgpmanager.api.IBgpManager) Adjacency(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.adjacency.list.Adjacency) BigInteger(java.math.BigInteger) LabelRouteInfoBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.label.route.map.LabelRouteInfoBuilder) MDSALUtil(org.opendaylight.genius.mdsalutil.MDSALUtil) L3vpnInput(org.opendaylight.netvirt.vpnmanager.populator.input.L3vpnInput) VrfTablesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTablesBuilder) Logger(org.slf4j.Logger) ManagedNewTransactionRunner(org.opendaylight.genius.infra.ManagedNewTransactionRunner) VrfTablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTablesKey) LabelRouteInfo(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.label.route.map.LabelRouteInfo) AdjacencyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.adjacency.list.AdjacencyBuilder) RouteOrigin(org.opendaylight.netvirt.fibmanager.api.RouteOrigin) LogicalDatastoreType(org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType) VpnPopulator(org.opendaylight.netvirt.vpnmanager.populator.intfc.VpnPopulator) VrfTables(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTables) WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) DataBroker(org.opendaylight.controller.md.sal.binding.api.DataBroker) List(java.util.List) VrfEntryBase(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.VrfEntryBase) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) VpnInstanceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry) SubnetRouteBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.SubnetRouteBuilder) SubnetRoute(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.SubnetRoute) Preconditions(com.google.common.base.Preconditions) VrfEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntryKey) Collections(java.util.Collections) FibHelper(org.opendaylight.netvirt.fibmanager.api.FibHelper) LabelRouteMap(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.LabelRouteMap) VpnInstanceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry) LabelRouteInfo(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.label.route.map.LabelRouteInfo) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) List(java.util.List) LabelRouteInfoBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.label.route.map.LabelRouteInfoBuilder) LabelRouteInfoKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.label.route.map.LabelRouteInfoKey)

Example 3 with LabelRouteInfoBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.label.route.map.LabelRouteInfoBuilder in project netvirt by opendaylight.

the class VrfEntryListener method deleteLabelRouteInfo.

private boolean deleteLabelRouteInfo(LabelRouteInfo lri, String vpnInstanceName, WriteTransaction tx) {
    if (lri == null) {
        return true;
    }
    LOG.debug("deleting LRI : for label {} vpninstancename {}", lri.getLabel(), vpnInstanceName);
    InstanceIdentifier<LabelRouteInfo> lriId = InstanceIdentifier.builder(LabelRouteMap.class).child(LabelRouteInfo.class, new LabelRouteInfoKey(lri.getLabel())).build();
    List<String> vpnInstancesList = lri.getVpnInstanceList() != null ? lri.getVpnInstanceList() : new ArrayList<>();
    if (vpnInstancesList.contains(vpnInstanceName)) {
        LOG.debug("vpninstance {} name is present", vpnInstanceName);
        vpnInstancesList.remove(vpnInstanceName);
    }
    if (vpnInstancesList.isEmpty()) {
        LOG.debug("deleting LRI instance object for label {}", lri.getLabel());
        if (tx != null) {
            tx.delete(LogicalDatastoreType.OPERATIONAL, lriId);
        } else {
            MDSALUtil.syncDelete(dataBroker, LogicalDatastoreType.OPERATIONAL, lriId);
        }
        return true;
    } else {
        LOG.debug("updating LRI instance object for label {}", lri.getLabel());
        LabelRouteInfoBuilder builder = new LabelRouteInfoBuilder(lri).setVpnInstanceList(vpnInstancesList);
        MDSALUtil.syncWrite(dataBroker, LogicalDatastoreType.OPERATIONAL, lriId, builder.build());
    }
    return false;
}
Also used : LabelRouteInfo(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.label.route.map.LabelRouteInfo) LabelRouteInfoBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.label.route.map.LabelRouteInfoBuilder) LabelRouteInfoKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.label.route.map.LabelRouteInfoKey)

Example 4 with LabelRouteInfoBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.label.route.map.LabelRouteInfoBuilder in project netvirt by opendaylight.

the class VrfEntryListener method updateVpnReferencesInLri.

private Prefixes updateVpnReferencesInLri(LabelRouteInfo lri, String vpnInstanceName, boolean isPresentInList) {
    LOG.debug("updating LRI : for label {} vpninstancename {}", lri.getLabel(), vpnInstanceName);
    PrefixesBuilder prefixBuilder = new PrefixesBuilder();
    prefixBuilder.setDpnId(lri.getDpnId());
    prefixBuilder.setVpnInterfaceName(lri.getVpnInterfaceName());
    prefixBuilder.setIpAddress(lri.getPrefix());
    // Increment the refCount here
    InstanceIdentifier<LabelRouteInfo> lriId = InstanceIdentifier.builder(LabelRouteMap.class).child(LabelRouteInfo.class, new LabelRouteInfoKey(lri.getLabel())).build();
    LabelRouteInfoBuilder builder = new LabelRouteInfoBuilder(lri);
    if (!isPresentInList) {
        LOG.debug("vpnName {} is not present in LRI with label {}..", vpnInstanceName, lri.getLabel());
        List<String> vpnInstanceNames = lri.getVpnInstanceList();
        vpnInstanceNames.add(vpnInstanceName);
        builder.setVpnInstanceList(vpnInstanceNames);
        MDSALUtil.syncWrite(dataBroker, LogicalDatastoreType.OPERATIONAL, lriId, builder.build());
    } else {
        LOG.debug("vpnName {} is present in LRI with label {}..", vpnInstanceName, lri.getLabel());
    }
    return prefixBuilder.build();
}
Also used : LabelRouteInfo(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.label.route.map.LabelRouteInfo) PrefixesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.prefix.to._interface.vpn.ids.PrefixesBuilder) LabelRouteInfoBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.label.route.map.LabelRouteInfoBuilder) LabelRouteInfoKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.label.route.map.LabelRouteInfoKey)

Aggregations

LabelRouteInfo (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.label.route.map.LabelRouteInfo)4 LabelRouteInfoBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.label.route.map.LabelRouteInfoBuilder)4 LabelRouteInfoKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.label.route.map.LabelRouteInfoKey)4 Optional (com.google.common.base.Optional)1 Preconditions (com.google.common.base.Preconditions)1 BigInteger (java.math.BigInteger)1 Collections (java.util.Collections)1 List (java.util.List)1 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)1 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)1 LogicalDatastoreType (org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType)1 ManagedNewTransactionRunner (org.opendaylight.genius.infra.ManagedNewTransactionRunner)1 ManagedNewTransactionRunnerImpl (org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl)1 MDSALUtil (org.opendaylight.genius.mdsalutil.MDSALUtil)1 ListenableFutures.addErrorLogging (org.opendaylight.infrautils.utils.concurrent.ListenableFutures.addErrorLogging)1 IBgpManager (org.opendaylight.netvirt.bgpmanager.api.IBgpManager)1 FibHelper (org.opendaylight.netvirt.fibmanager.api.FibHelper)1 IFibManager (org.opendaylight.netvirt.fibmanager.api.IFibManager)1 RouteOrigin (org.opendaylight.netvirt.fibmanager.api.RouteOrigin)1 VpnUtil (org.opendaylight.netvirt.vpnmanager.VpnUtil)1