Search in sources :

Example 36 with VpnInterface

use of org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.VpnInterface in project netvirt by opendaylight.

the class VpnInterfaceManager method updateVpnInterfacesForUnProcessAdjancencies.

public void updateVpnInterfacesForUnProcessAdjancencies(String vpnName) {
    String primaryRd = VpnUtil.getVpnRd(dataBroker, vpnName);
    VpnInstanceOpDataEntry vpnInstanceOpData = VpnUtil.getVpnInstanceOpData(dataBroker, primaryRd);
    if (vpnInstanceOpData == null) {
        return;
    }
    List<VpnToDpnList> vpnToDpnLists = vpnInstanceOpData.getVpnToDpnList();
    if (vpnToDpnLists == null || vpnToDpnLists.isEmpty()) {
        return;
    }
    LOG.debug("Update the VpnInterfaces for Unprocessed Adjancencies for vpnName:{}", vpnName);
    vpnToDpnLists.forEach(vpnToDpnList -> vpnToDpnList.getVpnInterfaces().forEach(vpnInterface -> {
        InstanceIdentifier<VpnInterfaceOpDataEntry> existingVpnInterfaceId = VpnUtil.getVpnInterfaceOpDataEntryIdentifier(vpnInterface.getInterfaceName(), vpnName);
        Optional<VpnInterfaceOpDataEntry> vpnInterfaceOptional = VpnUtil.read(dataBroker, LogicalDatastoreType.OPERATIONAL, existingVpnInterfaceId);
        if (!vpnInterfaceOptional.isPresent()) {
            return;
        }
        List<Adjacency> configVpnAdjacencies = VpnUtil.getAdjacenciesForVpnInterfaceFromConfig(dataBroker, vpnInterface.getInterfaceName());
        if (configVpnAdjacencies == null) {
            LOG.debug("There is no adjacency available for vpnInterface:{}", vpnInterface);
            return;
        }
        List<Adjacency> operationVpnAdjacencies = vpnInterfaceOptional.get().getAugmentation(AdjacenciesOp.class).getAdjacency();
        // Due to insufficient rds,  some of the extra route wont get processed when it is added.
        // The unprocessed adjacencies will be present in config vpn interface DS but will be missing
        // in operational DS. These unprocessed adjacencies will be handled below.
        // To obtain unprocessed adjacencies, filtering is done by which the missing adjacencies in operational
        // DS are retrieved which is used to call addNewAdjToVpnInterface method.
        configVpnAdjacencies.stream().filter(adjacency -> operationVpnAdjacencies.stream().noneMatch(operationalAdjacency -> operationalAdjacency.getIpAddress().equals(adjacency.getIpAddress()))).forEach(adjacency -> {
            LOG.debug("Processing the vpnInterface{} for the Ajacency:{}", vpnInterface, adjacency);
            jobCoordinator.enqueueJob("VPNINTERFACE-" + vpnInterface.getInterfaceName(), () -> {
                WriteTransaction writeConfigTxn = dataBroker.newWriteOnlyTransaction();
                WriteTransaction writeOperTxn = dataBroker.newWriteOnlyTransaction();
                if (VpnUtil.isAdjacencyEligibleToVpn(dataBroker, adjacency, vpnName)) {
                    addNewAdjToVpnInterface(existingVpnInterfaceId, primaryRd, adjacency, vpnInterfaceOptional.get().getDpnId(), writeConfigTxn, writeOperTxn);
                    ListenableFuture<Void> operFuture = writeOperTxn.submit();
                    try {
                        operFuture.get();
                    } catch (ExecutionException | InterruptedException e) {
                        LOG.error("Exception encountered while submitting operational" + " future for vpnInterface {}", vpnInterface, e);
                    }
                    List<ListenableFuture<Void>> futures = new ArrayList<>();
                    futures.add(writeConfigTxn.submit());
                    return futures;
                } else {
                    return Collections.emptyList();
                }
            });
        });
    }));
}
Also used : StateTunnelList(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnels_state.StateTunnelList) VpnInterfaceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn._interface.op.data.VpnInterfaceOpDataEntry) CacheProvider(org.opendaylight.infrautils.caches.CacheProvider) RouterInterfacesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.neutron.router.dpns.router.dpn.list.dpn.vpninterfaces.list.RouterInterfacesBuilder) Optional(com.google.common.base.Optional) Map(java.util.Map) IBgpManager(org.opendaylight.netvirt.bgpmanager.api.IBgpManager) BigInteger(java.math.BigInteger) LabelRouteInfoBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.label.route.map.LabelRouteInfoBuilder) DataBroker(org.opendaylight.controller.md.sal.binding.api.DataBroker) DpnVpninterfacesList(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.neutron.router.dpns.router.dpn.list.DpnVpninterfacesList) VpnHelper(org.opendaylight.netvirt.vpnmanager.api.VpnHelper) VpnInstanceOpData(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.VpnInstanceOpData) ArpResponderHandler(org.opendaylight.netvirt.vpnmanager.arp.responder.ArpResponderHandler) LabelRouteMap(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.LabelRouteMap) OdlInterfaceRpcService(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.OdlInterfaceRpcService) VpnInterfaceOpDataEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn._interface.op.data.VpnInterfaceOpDataEntryKey) ArrayList(java.util.ArrayList) InstanceIdentifierBuilder(org.opendaylight.yangtools.yang.binding.InstanceIdentifier.InstanceIdentifierBuilder) LabelRouteInfoKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.label.route.map.LabelRouteInfoKey) VpnInstanceNames(org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.vpn._interface.VpnInstanceNames) Adjacency(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.adjacency.list.Adjacency) RouterDpnList(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.neutron.router.dpns.RouterDpnList) RouterInterfacesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.neutron.router.dpns.router.dpn.list.dpn.vpninterfaces.list.RouterInterfacesKey) VpnInterfaces(org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.VpnInterfaces) DpnVpninterfacesListBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.neutron.router.dpns.router.dpn.list.DpnVpninterfacesListBuilder) RouterDpnListKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.neutron.router.dpns.RouterDpnListKey) L3vpnInput(org.opendaylight.netvirt.vpnmanager.populator.input.L3vpnInput) RouterInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.RouterInterface) VrfTablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTablesKey) VpnPopulator(org.opendaylight.netvirt.vpnmanager.populator.intfc.VpnPopulator) VrfTables(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTables) FutureCallback(com.google.common.util.concurrent.FutureCallback) ExecutionException(java.util.concurrent.ExecutionException) ListenableFutures(org.opendaylight.infrautils.utils.concurrent.ListenableFutures) Futures(com.google.common.util.concurrent.Futures) Prefixes(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.prefix.to._interface.vpn.ids.Prefixes) VpnToDpnList(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnList) VpnPortipToPort(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.neutron.vpn.portip.port.data.VpnPortipToPort) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) RouterInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.neutron.router.dpns.router.dpn.list.dpn.vpninterfaces.list.RouterInterfaces) IMdsalApiManager(org.opendaylight.genius.mdsalutil.interfaces.IMdsalApiManager) Preconditions(com.google.common.base.Preconditions) LearntVpnVipToPort(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.learnt.vpn.vip.to.port.data.LearntVpnVipToPort) RouterInterfaceBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.RouterInterfaceBuilder) FibHelper(org.opendaylight.netvirt.fibmanager.api.FibHelper) Adjacencies(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.Adjacencies) IFibManager(org.opendaylight.netvirt.fibmanager.api.IFibManager) NeutronRouterDpns(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.NeutronRouterDpns) VpnInterfaceOpDataEntryBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn._interface.op.data.VpnInterfaceOpDataEntryBuilder) FibEntries(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.FibEntries) LoggerFactory(org.slf4j.LoggerFactory) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) PreDestroy(javax.annotation.PreDestroy) MDSALUtil(org.opendaylight.genius.mdsalutil.MDSALUtil) Routers(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ext.routers.Routers) Subnets(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.external.subnets.Subnets) VrfTablesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTablesBuilder) L3vpnRegistry(org.opendaylight.netvirt.vpnmanager.populator.registry.L3vpnRegistry) Predicate(java.util.function.Predicate) ManagedNewTransactionRunner(org.opendaylight.genius.infra.ManagedNewTransactionRunner) LabelRouteInfo(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.label.route.map.LabelRouteInfo) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) LogicalDatastoreType(org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType) RouterDpnListBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.neutron.router.dpns.RouterDpnListBuilder) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface) Collectors(java.util.stream.Collectors) WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) Objects(java.util.Objects) List(java.util.List) VrfEntryBase(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.VrfEntryBase) VpnInstanceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry) PostConstruct(javax.annotation.PostConstruct) SubnetRoute(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.SubnetRoute) AdjacenciesOp(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.AdjacenciesOp) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue) VpnTarget(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.vpntargets.VpnTarget) NWUtil(org.opendaylight.genius.mdsalutil.NWUtil) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) VrfEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry) Singleton(javax.inject.Singleton) Iterators(com.google.common.collect.Iterators) Inject(javax.inject.Inject) AdjacencyType(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.adjacency.list.Adjacency.AdjacencyType) InterfaceUtils(org.opendaylight.netvirt.vpnmanager.api.InterfaceUtils) ManagedNewTransactionRunnerImpl(org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl) NwConstants(org.opendaylight.genius.mdsalutil.NwConstants) InstanceIdDataObjectCache(org.opendaylight.genius.mdsalutil.cache.InstanceIdDataObjectCache) IInterfaceManager(org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) AdjacencyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.adjacency.list.AdjacencyBuilder) RouteOrigin(org.opendaylight.netvirt.fibmanager.api.RouteOrigin) JobCoordinator(org.opendaylight.infrautils.jobcoordinator.JobCoordinator) IVpnManager(org.opendaylight.netvirt.vpnmanager.api.IVpnManager) VpnInterfaceKey(org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.VpnInterfaceKey) AsyncDataTreeChangeListenerBase(org.opendaylight.genius.datastoreutils.AsyncDataTreeChangeListenerBase) IdManagerService(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.IdManagerService) VpnInterface(org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.VpnInterface) Consumer(java.util.function.Consumer) DpnVpninterfacesListKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.neutron.router.dpns.router.dpn.list.DpnVpninterfacesListKey) Collections(java.util.Collections) WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) VpnInstanceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry) Optional(com.google.common.base.Optional) VpnToDpnList(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnList) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) StateTunnelList(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnels_state.StateTunnelList) DpnVpninterfacesList(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.neutron.router.dpns.router.dpn.list.DpnVpninterfacesList) ArrayList(java.util.ArrayList) RouterDpnList(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.neutron.router.dpns.RouterDpnList) VpnToDpnList(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnList) List(java.util.List)

Example 37 with VpnInterface

use of org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.VpnInterface in project netvirt by opendaylight.

the class VpnInterfaceManager method addVpnInterfaceCall.

private void addVpnInterfaceCall(final InstanceIdentifier<VpnInterface> identifier, final VpnInterface vpnInterface, final List<Adjacency> oldAdjs, final List<Adjacency> newAdjs, String vpnName) {
    final VpnInterfaceKey key = identifier.firstKeyOf(VpnInterface.class, VpnInterfaceKey.class);
    final String interfaceName = key.getName();
    if (!canHandleNewVpnInterface(identifier, vpnInterface, vpnName)) {
        LOG.error("add: VpnInstance {} for vpnInterface {} not ready, holding on ", vpnName, vpnInterface.getName());
        return;
    }
    InstanceIdentifier<VpnInterfaceOpDataEntry> vpnInterfaceOpIdentifier = VpnUtil.getVpnInterfaceOpDataEntryIdentifier(interfaceName, vpnName);
    List<Adjacency> copyOldAdjs = null;
    if (oldAdjs != null) {
        copyOldAdjs = new ArrayList<>();
        copyOldAdjs.addAll(oldAdjs);
    }
    List<Adjacency> copyNewAdjs = null;
    if (newAdjs != null) {
        copyNewAdjs = new ArrayList<>();
        copyNewAdjs.addAll(newAdjs);
    }
    addVpnInterfaceToVpn(vpnInterfaceOpIdentifier, vpnInterface, copyOldAdjs, copyNewAdjs, identifier, vpnName);
}
Also used : VpnInterfaceKey(org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.VpnInterfaceKey) Adjacency(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.adjacency.list.Adjacency) VpnInterfaceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn._interface.op.data.VpnInterfaceOpDataEntry)

Example 38 with VpnInterface

use of org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.VpnInterface in project netvirt by opendaylight.

the class VpnInterfaceOpListener method postProcessVpnInterfaceRemoval.

private void postProcessVpnInterfaceRemoval(InstanceIdentifier<VpnInterfaceOpDataEntry> identifier, VpnInterfaceOpDataEntry del, WriteTransaction writeOperTxn) {
    final VpnInterfaceOpDataEntryKey key = identifier.firstKeyOf(VpnInterfaceOpDataEntry.class, VpnInterfaceOpDataEntryKey.class);
    String interfaceName = key.getName();
    String vpnName = del.getVpnInstanceName();
    LOG.info("postProcessVpnInterfaceRemoval: interface name {} vpnName {} dpn {}", interfaceName, vpnName, del.getDpnId());
    // decrement the vpn interface count in Vpn Instance Op Data
    Optional<VpnInstance> vpnInstance = VpnUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, VpnOperDsUtils.getVpnInstanceToVpnIdIdentifier(vpnName));
    if (vpnInstance.isPresent()) {
        String rd = null;
        rd = vpnInstance.get().getVrfId();
        VpnInstanceOpDataEntry vpnInstOp = VpnUtil.getVpnInstanceOpData(dataBroker, rd);
        AdjacenciesOp adjs = del.getAugmentation(AdjacenciesOp.class);
        List<Adjacency> adjList = adjs != null ? adjs.getAdjacency() : null;
        if (vpnInstOp != null && adjList != null && adjList.size() > 0) {
            /*
                 * When a VPN Interface is removed by FibManager (aka VrfEntryListener and its cohorts),
                 * one adjacency for that VPN Interface will be hanging around along with that
                 * VPN Interface.   That adjacency could be primary (or) non-primary.
                 * If its a primary adjacency, then a prefix-to-interface entry will be available for the
                 * same.  If its a non-primary adjacency, then a prefix-to-interface entry will not be
                 * available for the same, instead we will have vpn-to-extraroutes filled in for them.
                 *
                 * Here we try to remove prefix-to-interface entry for pending adjacency in the deleted
                 * vpnInterface.   More importantly, we also update the vpnInstanceOpData by removing this
                 * vpnInterface from it.
                 */
            List<Prefixes> prefixToInterface = new ArrayList<>();
            for (Adjacency adjacency : adjs.getAdjacency()) {
                List<Prefixes> prefixToInterfaceLocal = new ArrayList<>();
                Optional<Prefixes> prefix = VpnUtil.read(dataBroker, LogicalDatastoreType.OPERATIONAL, VpnUtil.getPrefixToInterfaceIdentifier(vpnInstOp.getVpnId(), VpnUtil.getIpPrefix(adjacency.getIpAddress())));
                if (prefix.isPresent()) {
                    prefixToInterfaceLocal.add(prefix.get());
                }
                if (prefixToInterfaceLocal.isEmpty()) {
                    for (String nh : adjacency.getNextHopIpList()) {
                        prefix = VpnUtil.read(dataBroker, LogicalDatastoreType.OPERATIONAL, VpnUtil.getPrefixToInterfaceIdentifier(vpnInstOp.getVpnId(), VpnUtil.getIpPrefix(nh)));
                        if (prefix.isPresent()) {
                            prefixToInterfaceLocal.add(prefix.get());
                        }
                    }
                }
                if (!prefixToInterfaceLocal.isEmpty()) {
                    prefixToInterface.addAll(prefixToInterfaceLocal);
                }
            }
            /*
                 * In VPN Migration scenarios, there is a race condition where we use the new DPNID
                 * for the migrated VM instead of old DPNID because when we read prefix-to-interface to cleanup
                 * old DPNID, we actually get the new DPNID.
                 *
                 * More dangerously, we tend to alter the new prefix-to-interface which should be retained intac
                 * for the migration to succeed in L3VPN.  As a workaround, here we are going to use the dpnId in
                 * the deleted vpnInterface itself instead of tinkering with the prefix-to-interface.  Further we
                 * will tinker prefix-to-interface only when are damn sure if its value matches our
                 * deleted vpnInterface.
                 *
                 */
            for (Prefixes pref : prefixToInterface) {
                if (isMatchedPrefixToInterface(pref, del)) {
                    if (writeOperTxn != null) {
                        writeOperTxn.delete(LogicalDatastoreType.OPERATIONAL, VpnUtil.getPrefixToInterfaceIdentifier(vpnInstOp.getVpnId(), pref.getIpAddress()));
                    } else {
                        VpnUtil.delete(dataBroker, LogicalDatastoreType.OPERATIONAL, VpnUtil.getPrefixToInterfaceIdentifier(vpnInstOp.getVpnId(), pref.getIpAddress()), VpnUtil.DEFAULT_CALLBACK);
                    }
                }
            }
        }
        if (del.getDpnId() != null) {
            vpnFootprintService.updateVpnToDpnMapping(del.getDpnId(), del.getVpnInstanceName(), rd, interfaceName, null, /*ipAddressSourceValuePair*/
            false);
        }
        LOG.info("postProcessVpnInterfaceRemoval: Removed vpn operational data and updated vpn footprint" + " for interface {} on dpn {} vpn {}", interfaceName, del.getDpnId(), vpnName);
    } else {
        LOG.error("postProcessVpnInterfaceRemoval: rd not retrievable as vpninstancetovpnid for vpn {} is absent," + " trying rd as {}. interface {} dpn {}", vpnName, vpnName, interfaceName, del.getDpnId());
    }
    notifyTaskIfRequired(interfaceName);
}
Also used : VpnInstanceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry) VpnInterfaceOpDataEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn._interface.op.data.VpnInterfaceOpDataEntryKey) AdjacenciesOp(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.AdjacenciesOp) VpnInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.to.vpn.id.VpnInstance) ArrayList(java.util.ArrayList) Adjacency(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.adjacency.list.Adjacency) Prefixes(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.prefix.to._interface.vpn.ids.Prefixes)

Example 39 with VpnInterface

use of org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.VpnInterface in project netvirt by opendaylight.

the class VpnUtil method getVpnHandlingIpv4AssociatedWithInterface.

static Optional<List<String>> getVpnHandlingIpv4AssociatedWithInterface(DataBroker broker, String interfaceName) {
    InstanceIdentifier<VpnInterface> interfaceId = getVpnInterfaceIdentifier(interfaceName);
    Optional<List<String>> vpnOptional = Optional.absent();
    Optional<VpnInterface> optConfiguredVpnInterface = read(broker, LogicalDatastoreType.CONFIGURATION, interfaceId);
    if (optConfiguredVpnInterface.isPresent()) {
        VpnInterface cfgVpnInterface = optConfiguredVpnInterface.get();
        java.util.Optional<List<VpnInstanceNames>> optVpnInstanceList = java.util.Optional.ofNullable(cfgVpnInterface.getVpnInstanceNames());
        if (optVpnInstanceList.isPresent()) {
            List<String> vpnList = new ArrayList<>();
            for (VpnInstanceNames vpnInstance : optVpnInstanceList.get()) {
                if (vpnInstance.getAssociatedSubnetType().equals(AssociatedSubnetType.V6Subnet)) {
                    continue;
                }
                vpnList.add(vpnInstance.getVpnName());
            }
            vpnOptional = Optional.of(vpnList);
        }
    }
    return vpnOptional;
}
Also used : VpnInterface(org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.VpnInterface) VpnInstanceNames(org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.vpn._interface.VpnInstanceNames) ArrayList(java.util.ArrayList) ElanDpnInterfacesList(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.ElanDpnInterfacesList) ArrayList(java.util.ArrayList) VpnToDpnList(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnList) List(java.util.List)

Example 40 with VpnInterface

use of org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.VpnInterface in project netvirt by opendaylight.

the class InterfaceStateChangeListener method add.

@Override
// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
protected void add(InstanceIdentifier<Interface> identifier, Interface intrf) {
    try {
        if (L2vlan.class.equals(intrf.getType())) {
            LOG.info("VPN Interface add event - intfName {} from InterfaceStateChangeListener", intrf.getName());
            jobCoordinator.enqueueJob("VPNINTERFACE-" + intrf.getName(), () -> {
                List<ListenableFuture<Void>> futures = new ArrayList<>(3);
                futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(writeInvTxn -> {
                    ListenableFuture<Void> configFuture = txRunner.callWithNewWriteOnlyTransactionAndSubmit(writeConfigTxn -> {
                        ListenableFuture<Void> operFuture = txRunner.callWithNewWriteOnlyTransactionAndSubmit(writeOperTxn -> {
                            final String interfaceName = intrf.getName();
                            LOG.info("Detected interface add event for interface {}", interfaceName);
                            final VpnInterface vpnIf = VpnUtil.getConfiguredVpnInterface(dataBroker, interfaceName);
                            if (vpnIf != null) {
                                for (VpnInstanceNames vpnInterfaceVpnInstance : vpnIf.getVpnInstanceNames()) {
                                    String vpnName = vpnInterfaceVpnInstance.getVpnName();
                                    String primaryRd = VpnUtil.getPrimaryRd(dataBroker, vpnName);
                                    if (!vpnInterfaceManager.isVpnInstanceReady(vpnName)) {
                                        LOG.info("VPN Interface add event - intfName {} onto vpnName {} " + "running oper-driven, VpnInstance not ready, holding" + " on", vpnIf.getName(), vpnName);
                                    } else if (VpnUtil.isVpnPendingDelete(dataBroker, primaryRd)) {
                                        LOG.error("add: Ignoring addition of vpnInterface {}, as" + " vpnInstance {} with primaryRd {} is already marked for" + " deletion", interfaceName, vpnName, primaryRd);
                                    } else {
                                        BigInteger intfDpnId = BigInteger.ZERO;
                                        try {
                                            intfDpnId = InterfaceUtils.getDpIdFromInterface(intrf);
                                        } catch (Exception e) {
                                            LOG.error("Unable to retrieve dpnId for interface {}. " + "Process vpn interface add failed", intrf.getName(), e);
                                            return;
                                        }
                                        final BigInteger dpnId = intfDpnId;
                                        final int ifIndex = intrf.getIfIndex();
                                        LOG.info("VPN Interface add event - intfName {} onto vpnName {}" + " running oper-driven", vpnIf.getName(), vpnName);
                                        vpnInterfaceManager.processVpnInterfaceUp(dpnId, vpnIf, primaryRd, ifIndex, false, writeConfigTxn, writeOperTxn, writeInvTxn, intrf, vpnName);
                                    }
                                }
                            }
                        });
                        futures.add(operFuture);
                        // Synchronous submit of operTxn
                        operFuture.get();
                    });
                    futures.add(configFuture);
                    // TODO: Allow immediateFailedFuture from writeCfgTxn to cancel writeInvTxn as well.
                    Futures.addCallback(configFuture, new PostVpnInterfaceThreadWorker(intrf.getName(), true, "Operational"));
                }));
                return futures;
            });
        }
    } catch (Exception e) {
        LOG.error("Exception caught in Interface {} Operational State Up event", intrf.getName(), e);
    }
}
Also used : InterfacesState(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfacesState) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) LoggerFactory(org.slf4j.LoggerFactory) Singleton(javax.inject.Singleton) VpnInterfaceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn._interface.op.data.VpnInterfaceOpDataEntry) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) InterfaceUtils(org.opendaylight.netvirt.vpnmanager.api.InterfaceUtils) VpnInstanceNames(org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.vpn._interface.VpnInstanceNames) Optional(com.google.common.base.Optional) ManagedNewTransactionRunnerImpl(org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl) BigInteger(java.math.BigInteger) Logger(org.slf4j.Logger) OperStatus(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus) ManagedNewTransactionRunner(org.opendaylight.genius.infra.ManagedNewTransactionRunner) LogicalDatastoreType(org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType) JobCoordinator(org.opendaylight.infrautils.jobcoordinator.JobCoordinator) AsyncDataTreeChangeListenerBase(org.opendaylight.genius.datastoreutils.AsyncDataTreeChangeListenerBase) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface) FutureCallback(com.google.common.util.concurrent.FutureCallback) DataBroker(org.opendaylight.controller.md.sal.binding.api.DataBroker) VpnInterface(org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.VpnInterface) L2vlan(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.L2vlan) Futures(com.google.common.util.concurrent.Futures) List(java.util.List) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) PostConstruct(javax.annotation.PostConstruct) VpnInterface(org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.VpnInterface) VpnInstanceNames(org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.vpn._interface.VpnInstanceNames) ArrayList(java.util.ArrayList) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) BigInteger(java.math.BigInteger)

Aggregations

VpnInterface (org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.VpnInterface)33 ArrayList (java.util.ArrayList)32 VpnInstanceNames (org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.vpn._interface.VpnInstanceNames)24 Adjacency (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.adjacency.list.Adjacency)23 Adjacencies (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.Adjacencies)17 VpnInterfaceOpDataEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn._interface.op.data.VpnInterfaceOpDataEntry)17 BigInteger (java.math.BigInteger)16 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)14 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)12 VpnInterfaceKey (org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.VpnInterfaceKey)12 ExecutionException (java.util.concurrent.ExecutionException)11 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)10 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)10 VpnInterfaceBuilder (org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.VpnInterfaceBuilder)10 List (java.util.List)9 AdjacencyBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.adjacency.list.AdjacencyBuilder)8 Interface (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface)7 VpnInterfaceOpDataEntryKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn._interface.op.data.VpnInterfaceOpDataEntryKey)7 Optional (com.google.common.base.Optional)6 PostConstruct (javax.annotation.PostConstruct)6