Search in sources :

Example 31 with Object

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object in project netvirt by opendaylight.

the class VpnManagerImpl method addArpResponderFlowsToExternalNetworkIps.

@Override
public void addArpResponderFlowsToExternalNetworkIps(String id, Collection<String> fixedIps, String macAddress, Uint64 dpnId, Uuid extNetworkId) {
    if (dpnId == null || Uint64.ZERO.equals(dpnId)) {
        LOG.warn("Failed to install arp responder flows for router {}. DPN id is missing.", id);
        return;
    }
    String extInterfaceName = elanService.getExternalElanInterface(extNetworkId.getValue(), dpnId);
    if (extInterfaceName != null) {
        doAddArpResponderFlowsToExternalNetworkIps(id, fixedIps, macAddress, dpnId, extInterfaceName);
        return;
    }
    LOG.warn("Failed to install responder flows for {}. No external interface found for DPN id {}", id, dpnId);
    if (!upgradeState.isUpgradeInProgress()) {
        return;
    }
    // The following through the end of the function deals with an upgrade scenario where the neutron configuration
    // is restored before the OVS switches reconnect. In such a case, the elan-dpn-interfaces entries will be
    // missing from the operational data store. In order to mitigate this we use DataTreeEventCallbackRegistrar
    // to wait for the exact operational md-sal object we need to contain the external interface we need.
    LOG.info("Upgrade in process, waiting for an external interface to appear on dpn {} for elan {}", dpnId, extNetworkId.getValue());
    InstanceIdentifier<DpnInterfaces> dpnInterfacesIid = elanService.getElanDpnInterfaceOperationalDataPath(extNetworkId.getValue(), dpnId);
    eventCallbacks.onAddOrUpdate(LogicalDatastoreType.OPERATIONAL, dpnInterfacesIid, (unused, alsoUnused) -> {
        LOG.info("Reattempting write of arp responder for external interfaces for external network {}", extNetworkId);
        DpnInterfaces dpnInterfaces = elanService.getElanInterfaceInfoByElanDpn(extNetworkId.getValue(), dpnId);
        if (dpnInterfaces == null) {
            LOG.error("Could not retrieve DpnInterfaces for {}, {}", extNetworkId.getValue(), dpnId);
            return DataTreeEventCallbackRegistrar.NextAction.UNREGISTER;
        }
        String extIfc = null;
        @Nullable List<String> interfaces = dpnInterfaces.getInterfaces();
        if (interfaces != null) {
            for (String dpnInterface : interfaces) {
                if (interfaceManager.isExternalInterface(dpnInterface)) {
                    extIfc = dpnInterface;
                    break;
                }
            }
        }
        if (extIfc == null) {
            if (upgradeState.isUpgradeInProgress()) {
                LOG.info("External interface not found yet in elan {} on dpn {}, keep waiting", extNetworkId.getValue(), dpnInterfaces);
                return DataTreeEventCallbackRegistrar.NextAction.CALL_AGAIN;
            } else {
                return DataTreeEventCallbackRegistrar.NextAction.UNREGISTER;
            }
        }
        final String extIfcFinal = extIfc;
        doAddArpResponderFlowsToExternalNetworkIps(id, fixedIps, macAddress, dpnId, extIfcFinal);
        return DataTreeEventCallbackRegistrar.NextAction.UNREGISTER;
    });
}
Also used : DpnInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfaces) Nullable(org.eclipse.jdt.annotation.Nullable)

Example 32 with Object

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object in project netvirt by opendaylight.

the class TunnelEndPointChangeListener method add.

@Override
public void add(InstanceIdentifier<TunnelEndPoints> key, TunnelEndPoints tep) {
    Uint64 dpnId = key.firstIdentifierOf(DPNTEPsInfo.class).firstKeyOf(DPNTEPsInfo.class).getDPNID();
    if (Uint64.ZERO.equals(dpnId)) {
        LOG.warn("add: Invalid DPN id for TEP {}", tep.getInterfaceName());
        return;
    }
    List<VpnInstance> vpnInstances = VpnHelper.getAllVpnInstances(broker);
    if (vpnInstances == null || vpnInstances.isEmpty()) {
        LOG.warn("add: dpnId: {}: tep: {}: No VPN instances defined", dpnId, tep.getInterfaceName());
        return;
    }
    for (VpnInstance vpnInstance : vpnInstances) {
        final String vpnName = vpnInstance.getVpnInstanceName();
        final Uint32 vpnId = vpnUtil.getVpnId(vpnName);
        LOG.info("add: Handling TEP {} add for VPN instance {}", tep.getInterfaceName(), vpnName);
        final String primaryRd = vpnUtil.getPrimaryRd(vpnName);
        if (!vpnUtil.isVpnPendingDelete(primaryRd)) {
            List<VpnInterfaces> vpnInterfaces = vpnUtil.getDpnVpnInterfaces(vpnInstance, dpnId);
            if (vpnInterfaces != null) {
                for (VpnInterfaces vpnInterface : vpnInterfaces) {
                    String vpnInterfaceName = vpnInterface.getInterfaceName();
                    jobCoordinator.enqueueJob("VPNINTERFACE-" + vpnInterfaceName, () -> {
                        final org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface interfaceState = InterfaceUtils.getInterfaceStateFromOperDS(broker, vpnInterfaceName);
                        if (interfaceState == null) {
                            LOG.debug("add: Cannot retrieve interfaceState for vpnInterfaceName {}, " + "cannot generate lPortTag and process adjacencies", vpnInterfaceName);
                            return Collections.emptyList();
                        }
                        final int lPortTag = interfaceState.getIfIndex();
                        List<ListenableFuture<?>> futures = new ArrayList<>();
                        Set<String> prefixesForRefreshFib = new HashSet<>();
                        ListenableFuture<?> writeConfigFuture = txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, writeConfigTxn -> futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(OPERATIONAL, writeOperTxn -> futures.add(txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION, writeInvTxn -> vpnInterfaceManager.processVpnInterfaceAdjacencies(dpnId, lPortTag, vpnName, primaryRd, vpnInterfaceName, vpnId, writeConfigTxn, writeOperTxn, writeInvTxn, interfaceState, prefixesForRefreshFib))))));
                        Futures.addCallback(writeConfigFuture, new FutureCallback<Object>() {

                            @Override
                            public void onSuccess(Object voidObj) {
                                prefixesForRefreshFib.forEach(prefix -> {
                                    fibManager.refreshVrfEntry(primaryRd, prefix);
                                });
                            }

                            @Override
                            public void onFailure(Throwable throwable) {
                                LOG.debug("addVpnInterface: write Tx config execution failed", throwable);
                            }
                        }, MoreExecutors.directExecutor());
                        futures.add(writeConfigFuture);
                        LOG.trace("add: Handled TEP {} add for VPN instance {} VPN interface {}", tep.getInterfaceName(), vpnName, vpnInterfaceName);
                        return futures;
                    });
                }
            }
        } else {
            LOG.error("add: Ignoring addition of tunnel interface {} dpn {} for vpnInstance {} with primaryRd {}," + " as the VPN is already marked for deletion", tep.getInterfaceName(), dpnId, vpnName, primaryRd);
        }
    }
}
Also used : CONFIGURATION(org.opendaylight.mdsal.binding.util.Datastore.CONFIGURATION) IFibManager(org.opendaylight.netvirt.fibmanager.api.IFibManager) MoreExecutors(com.google.common.util.concurrent.MoreExecutors) Uint64(org.opendaylight.yangtools.yang.common.Uint64) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) VpnInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.vpn.to.dpn.list.VpnInterfaces) LoggerFactory(org.slf4j.LoggerFactory) Executors(org.opendaylight.infrautils.utils.concurrent.Executors) ManagedNewTransactionRunner(org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunner) DpnEndpoints(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.DpnEndpoints) Singleton(javax.inject.Singleton) VpnInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.instances.VpnInstance) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Inject(javax.inject.Inject) PreDestroy(javax.annotation.PreDestroy) InterfaceUtils(org.opendaylight.netvirt.vpnmanager.api.InterfaceUtils) DPNTEPsInfo(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfo) Uint32(org.opendaylight.yangtools.yang.common.Uint32) Logger(org.slf4j.Logger) AbstractAsyncDataTreeChangeListener(org.opendaylight.serviceutils.tools.listener.AbstractAsyncDataTreeChangeListener) JobCoordinator(org.opendaylight.infrautils.jobcoordinator.JobCoordinator) Set(java.util.Set) TunnelEndPoints(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.dpn.teps.info.TunnelEndPoints) FutureCallback(com.google.common.util.concurrent.FutureCallback) VpnHelper(org.opendaylight.netvirt.vpnmanager.api.VpnHelper) Futures(com.google.common.util.concurrent.Futures) List(java.util.List) ManagedNewTransactionRunnerImpl(org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunnerImpl) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) LogicalDatastoreType(org.opendaylight.mdsal.common.api.LogicalDatastoreType) Collections(java.util.Collections) OPERATIONAL(org.opendaylight.mdsal.binding.util.Datastore.OPERATIONAL) DataBroker(org.opendaylight.mdsal.binding.api.DataBroker) VpnInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.vpn.to.dpn.list.VpnInterfaces) Collections(java.util.Collections) VpnInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.instances.VpnInstance) ArrayList(java.util.ArrayList) DPNTEPsInfo(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfo) Uint32(org.opendaylight.yangtools.yang.common.Uint32) HashSet(java.util.HashSet) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) Uint64(org.opendaylight.yangtools.yang.common.Uint64)

Example 33 with Object

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object in project netvirt by opendaylight.

the class ElanServiceChainUtils method getElanServiceChainState.

/**
 * Read from ElanToLportTagMap the PsuedoLogicalPort related with a given elan.
 *
 * @param broker dataBroker service reference
 * @param elanInstanceName the name of the Elan
 * @return the ElanToPseudoPortData object or Optional.empty() if it
 *     cannot be found
 */
public static Optional<ElanServiceChainState> getElanServiceChainState(final DataBroker broker, final String elanInstanceName) {
    InstanceIdentifier<ElanServiceChainState> path = InstanceIdentifier.builder(ElanInstances.class).child(ElanInstance.class, new ElanInstanceKey(elanInstanceName)).augmentation(ElanServiceChainState.class).build();
    Optional<ElanServiceChainState> elanServiceChainStateOpc = MDSALUtil.read(broker, LogicalDatastoreType.CONFIGURATION, path);
    return elanServiceChainStateOpc;
}
Also used : ElanInstanceKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstanceKey) ElanInstances(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanInstances) ElanServiceChainState(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.cloud.servicechain.state.rev160711.ElanServiceChainState)

Example 34 with Object

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object in project netvirt by opendaylight.

the class VpnServiceChainUtils method buildLPortDispFromScfToL3VpnFlow.

/**
 * Build the flow that must be inserted when there is a ScHop whose
 * egressPort is a VPN Pseudo Port. In that case, packets must be moved
 * from the SCF to VPN Pipeline.
 * <p>
 * Flow matches:  VpnPseudo port lPortTag + SI=L3VPN
 * Actions: Write vrfTag in Metadata + goto FIB Table
 * </p>
 * @param vpnId Dataplane identifier of the VPN, the Vrf Tag.
 * @param dpId The DPN where the flow must be installed/removed
 * @param lportTag Dataplane identifier for the VpnPseudoPort
 * @param addOrRemove States if it must build a Flow to be created or
 *     removed
 *
 * @return the Flow object
 */
public static Flow buildLPortDispFromScfToL3VpnFlow(Long vpnId, BigInteger dpId, Integer lportTag, int addOrRemove) {
    LOG.info("buildLPortDispFlowForScf vpnId={} dpId={} lportTag={} addOrRemove={} ", vpnId, dpId, lportTag, addOrRemove);
    List<MatchInfo> matches = buildMatchOnLportTagAndSI(lportTag, ServiceIndex.getIndex(NwConstants.L3VPN_SERVICE_NAME, NwConstants.L3VPN_SERVICE_INDEX));
    List<Instruction> instructions = buildSetVrfTagAndGotoFibInstructions(vpnId.intValue());
    String flowRef = getScfToL3VpnLportDispatcherFlowRef(lportTag);
    Flow result;
    if (addOrRemove == NwConstants.ADD_FLOW) {
        result = MDSALUtil.buildFlowNew(NwConstants.LPORT_DISPATCHER_TABLE, flowRef, CloudServiceChainConstants.DEFAULT_SCF_FLOW_PRIORITY, flowRef, 0, 0, VpnServiceChainUtils.getCookieL3(vpnId.intValue()), matches, instructions);
    } else {
        result = new FlowBuilder().setTableId(NwConstants.LPORT_DISPATCHER_TABLE).setId(new FlowId(flowRef)).build();
    }
    return result;
}
Also used : FlowId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId) FlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder) MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo) Instruction(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)

Example 35 with Object

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object in project netvirt by opendaylight.

the class ExternalNetworksChangeListener method disassociateExternalNetworkFromVPN.

private void disassociateExternalNetworkFromVPN(Networks network, String vpnName) {
    if (network.getRouterIds() != null) {
        for (Uuid routerId : network.getRouterIds()) {
            InstanceIdentifier<RouterPorts> routerPortsId = NatUtil.getRouterPortsId(routerId.getValue());
            Optional<RouterPorts> optRouterPorts = Optional.empty();
            try {
                optRouterPorts = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, routerPortsId);
            } catch (ExecutionException | InterruptedException e) {
                LOG.error("disassociateExternalNetworkFromVPN: Exception while reading RouterPorts DS for the " + "router {} network {} vpn {}", routerId, network.getId().getValue(), vpnName, e);
            }
            if (!optRouterPorts.isPresent()) {
                LOG.debug("disassociateExternalNetworkFromVPN : Could not read Router Ports data object with id: {} " + "to handle disassociate ext nw {}", routerId, network.getId());
                continue;
            }
            RouterPorts routerPorts = optRouterPorts.get();
            for (Ports port : routerPorts.nonnullPorts().values()) {
                String portName = port.getPortName();
                Uint64 dpnId = NatUtil.getDpnForInterface(interfaceManager, portName);
                if (dpnId.equals(Uint64.ZERO)) {
                    LOG.debug("disassociateExternalNetworkFromVPN : DPN not found for {}," + "skip handling of ext nw {} disassociation", portName, network.getId());
                    continue;
                }
                for (InternalToExternalPortMap intExtPortMap : port.nonnullInternalToExternalPortMap().values()) {
                    coordinator.enqueueJob(NatConstants.NAT_DJC_PREFIX + intExtPortMap.key(), () -> Collections.singletonList(txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION, tx -> floatingIpListener.removeNATFlowEntries(dpnId, portName, vpnName, routerId.getValue(), intExtPortMap, tx))), NatConstants.NAT_DJC_MAX_RETRIES);
                }
            }
        }
    }
}
Also used : Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) RouterPorts(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.RouterPorts) RouterPorts(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.RouterPorts) Ports(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.router.ports.Ports) ExecutionException(java.util.concurrent.ExecutionException) InternalToExternalPortMap(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.router.ports.ports.InternalToExternalPortMap) Uint64(org.opendaylight.yangtools.yang.common.Uint64)

Aggregations

ArrayList (java.util.ArrayList)94 ByteBuf (io.netty.buffer.ByteBuf)82 Test (org.junit.Test)62 PCEPDeserializerException (org.opendaylight.protocol.pcep.spi.PCEPDeserializerException)34 Object (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object)33 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)33 ExecutionException (java.util.concurrent.ExecutionException)30 Eid (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid)29 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)25 Attributes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.Attributes)25 List (java.util.List)21 HashMap (java.util.HashMap)19 Object (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object)18 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)17 Nullable (org.eclipse.jdt.annotation.Nullable)16 UnknownObject (org.opendaylight.protocol.pcep.spi.UnknownObject)16 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)15 Uint32 (org.opendaylight.yangtools.yang.common.Uint32)15 FutureCallback (com.google.common.util.concurrent.FutureCallback)14 BigInteger (java.math.BigInteger)14