Search in sources :

Example 46 with VpnInstance

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

the class EvpnUtils method advertisePrefix.

@SuppressWarnings("checkstyle:IllegalCatch")
public void advertisePrefix(ElanInstance elanInfo, String rd, String macAddress, String prefix, String interfaceName, BigInteger dpnId) {
    if (rd == null) {
        LOG.debug("advertisePrefix : rd is NULL for elanInfo {}, macAddress {}", elanInfo, macAddress);
        return;
    }
    String nextHop = getEndpointIpAddressForDPN(dpnId);
    if (nextHop == null) {
        LOG.debug("Failed to get the dpn tep ip for dpn {}", dpnId);
        return;
    }
    int vpnLabel = 0;
    long l2vni = elanUtils.getVxlanSegmentationId(elanInfo);
    long l3vni = 0;
    String gatewayMacAddr = null;
    String l3VpName = getL3vpnNameFromElan(elanInfo);
    if (l3VpName != null) {
        VpnInstance l3VpnInstance = vpnManager.getVpnInstance(broker, l3VpName);
        l3vni = l3VpnInstance.getL3vni();
        com.google.common.base.Optional<String> gatewayMac = getGatewayMacAddressForInterface(l3VpName, interfaceName, prefix);
        gatewayMacAddr = gatewayMac.isPresent() ? gatewayMac.get() : null;
    }
    LOG.info("Advertising routes with rd {},  macAddress {}, prefix {}, nextHop {}," + " vpnLabel {}, l3vni {}, l2vni {}, gatewayMac {}", rd, macAddress, prefix, nextHop, vpnLabel, l3vni, l2vni, gatewayMacAddr);
    try {
        bgpManager.advertisePrefix(rd, macAddress, prefix, nextHop, VrfEntryBase.EncapType.Vxlan, vpnLabel, l3vni, l2vni, gatewayMacAddr);
    } catch (Exception e) {
        LOG.error("Failed to advertisePrefix", e);
    }
}
Also used : VpnInstance(org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.instances.VpnInstance) ExecutionException(java.util.concurrent.ExecutionException) ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)

Example 47 with VpnInstance

use of org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.instances.VpnInstance 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)

Example 48 with VpnInstance

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

the class TunnelInterfaceStateListener method handleTunnelEventForDPNVpn.

// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
private void handleTunnelEventForDPNVpn(StateTunnelList stateTunnelList, Map<Long, String> vpnIdRdMap, TunnelAction tunnelAction, boolean isTepDeletedOnDpn, List<Uuid> subnetList, TunnelEventProcessingMethod method, VpnInterface cfgVpnInterface) {
    String rd;
    String intfName = cfgVpnInterface.getName();
    final BigInteger srcDpnId = new BigInteger(stateTunnelList.getSrcInfo().getTepDeviceId());
    String destTepIp = String.valueOf(stateTunnelList.getDstInfo().getTepIp().getValue());
    String srcTepIp = String.valueOf(stateTunnelList.getSrcInfo().getTepIp().getValue());
    int tunTypeVal = getTunnelType(stateTunnelList);
    BigInteger remoteDpnId = null;
    if (tunTypeVal == VpnConstants.ITMTunnelLocType.Internal.getValue()) {
        remoteDpnId = new BigInteger(stateTunnelList.getDstInfo().getTepDeviceId());
    }
    if (cfgVpnInterface.getVpnInstanceNames() == null) {
        LOG.warn("handleTunnelEventForDpn: no vpnName found for interface {}", intfName);
        return;
    }
    for (VpnInstanceNames vpnInstance : cfgVpnInterface.getVpnInstanceNames()) {
        String vpnName = vpnInstance.getVpnName();
        if (method == TunnelEventProcessingMethod.POPULATESUBNETS) {
            Optional<VpnInterfaceOpDataEntry> opVpnInterface = VpnUtil.getVpnInterfaceOpDataEntry(dataBroker, intfName, vpnName);
            if (opVpnInterface.isPresent() && !opVpnInterface.get().isScheduledForRemove()) {
                VpnInterfaceOpDataEntry vpnInterface = opVpnInterface.get();
                jobCoordinator.enqueueJob("VPNINTERFACE-" + intfName, new UpdateVpnInterfaceOnTunnelEvent(tunnelAction, vpnInterface, stateTunnelList, isTepDeletedOnDpn));
                // Populate the List of subnets
                InstanceIdentifier<PortOpDataEntry> portOpIdentifier = InstanceIdentifier.builder(PortOpData.class).child(PortOpDataEntry.class, new PortOpDataEntryKey(intfName)).build();
                Optional<PortOpDataEntry> optionalPortOp = VpnUtil.read(dataBroker, LogicalDatastoreType.OPERATIONAL, portOpIdentifier);
                if (optionalPortOp.isPresent()) {
                    List<Uuid> subnetIdList = optionalPortOp.get().getSubnetIds();
                    if (subnetIdList != null) {
                        for (Uuid subnetId : subnetIdList) {
                            if (!subnetList.contains(subnetId)) {
                                subnetList.add(subnetId);
                            }
                        }
                    }
                }
                // Populate the map for VpnId-to-Rd
                long vpnId = VpnUtil.getVpnId(dataBroker, vpnName);
                rd = VpnUtil.getVpnRd(dataBroker, vpnName);
                vpnIdRdMap.put(vpnId, rd);
            }
        } else if (method == TunnelEventProcessingMethod.MANAGEREMOTEROUTES) {
            Optional<VpnInterfaceOpDataEntry> opVpnInterface = VpnUtil.getVpnInterfaceOpDataEntry(dataBroker, intfName, vpnName);
            if (opVpnInterface.isPresent()) {
                VpnInterfaceOpDataEntry vpnInterface = opVpnInterface.get();
                AdjacenciesOp adjacencies = vpnInterface.getAugmentation(AdjacenciesOp.class);
                List<Adjacency> adjList = adjacencies != null ? adjacencies.getAdjacency() : Collections.emptyList();
                String prefix = null;
                long vpnId = VpnUtil.getVpnId(dataBroker, vpnInterface.getVpnInstanceName());
                if (vpnIdRdMap.containsKey(vpnId)) {
                    rd = vpnIdRdMap.get(vpnId);
                    LOG.info("handleTunnelEventForDPN: Remote DpnId {} VpnId {} rd {} VpnInterface {} srcTepIp " + "{} destTepIp {}", remoteDpnId, vpnId, rd, vpnInterface, srcTepIp, destTepIp);
                    for (Adjacency adj : adjList) {
                        prefix = adj.getIpAddress();
                        long label = adj.getLabel();
                        if (tunnelAction == TunnelAction.TUNNEL_EP_ADD && tunTypeVal == VpnConstants.ITMTunnelLocType.Internal.getValue()) {
                            fibManager.manageRemoteRouteOnDPN(true, srcDpnId, vpnId, rd, prefix, destTepIp, label);
                        }
                        if (tunnelAction == TunnelAction.TUNNEL_EP_DELETE && tunTypeVal == VpnConstants.ITMTunnelLocType.Internal.getValue()) {
                            fibManager.manageRemoteRouteOnDPN(false, srcDpnId, vpnId, rd, prefix, destTepIp, label);
                        }
                    }
                }
            }
        }
    }
}
Also used : Optional(com.google.common.base.Optional) PortOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.port.op.data.PortOpDataEntry) PortOpDataEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.port.op.data.PortOpDataEntryKey) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) VpnInstanceNames(org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.vpn._interface.VpnInstanceNames) AdjacenciesOp(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.AdjacenciesOp) BigInteger(java.math.BigInteger) StateTunnelList(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnels_state.StateTunnelList) DcGatewayIpList(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.DcGatewayIpList) List(java.util.List) ArrayList(java.util.ArrayList) Collectors.toList(java.util.stream.Collectors.toList) 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 49 with VpnInstance

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

the class VPNServiceChainHandler method programScfToVpnPipeline.

/**
 * L3VPN Service chaining: It moves traffic from a ServiceChain to a L3VPN.
 *
 * @param vpnName Vpn Instance Name. Typicall the UUID
 * @param scfTag ServiceChainForwarding Tag
 * @param servChainTag ServiceChain Tag
 * @param dpnId DpnId in which the egress pseudo logical port belongs
 * @param vpnPseudoLportTag VpnPseudo Logical port tag
 * @param isLastServiceChain Flag stating if there is no other ServiceChain
 *        using this VpnPseudoPort
 * @param addOrRemove States if pipeline must be installed or removed
 */
public void programScfToVpnPipeline(String vpnName, long scfTag, int servChainTag, long dpnId, int vpnPseudoLportTag, boolean isLastServiceChain, int addOrRemove) {
    // These Flows must be installed in the DPN where the last SF in the ServiceChain is located
    // + ScForwardingTable (75):  (This one is created and maintained by ScHopManager)
    // - Match:  scfTag + servChainId + lportTagOfvVSF    Instr: VpnPseudoPortTag + SI=L3VPN + GOTO LPortDisp
    // And these 2 flows must be installed in all Dpns where the Vpn is present:
    // + LPortDisp (17):
    // - Match:  VpnPseudoPortTag + SI==L3VPN    Instr: setVpnTag + GOTO FIB
    // + FIB (21): (one entry per VrfEntry, and it is maintained by FibManager)
    // - Match:  vrfTag==vpnTag + eth_type=IPv4  + dst_ip   Instr:  Output DC-GW
    // 
    LOG.info("L3VPN: Service Chaining programScfToVpnPipeline [Started]: Parameters Vpn Name: {} ", vpnName);
    String rd = VpnServiceChainUtils.getVpnRd(dataBroker, vpnName);
    if (rd == null || rd.isEmpty()) {
        LOG.warn("programScfToVpnPipeline: Could not find Router-distinguisher for VPN {}. No further actions", vpnName);
        return;
    }
    VpnInstanceOpDataEntry vpnInstance = getVpnInstance(rd);
    LOG.debug("programScfToVpnPipeline: rd={}, lportTag={} ", rd, vpnPseudoLportTag);
    // Find out the set of DPNs for the given VPN ID
    if (vpnInstance != null) {
        if (addOrRemove == NwConstants.ADD_FLOW || addOrRemove == NwConstants.DEL_FLOW && isLastServiceChain) {
            Long vpnId = vpnInstance.getVpnId();
            List<VpnToDpnList> vpnToDpnList = vpnInstance.getVpnToDpnList();
            if (vpnToDpnList != null) {
                List<BigInteger> dpns = new ArrayList<>();
                for (VpnToDpnList dpnInVpn : vpnToDpnList) {
                    dpns.add(dpnInVpn.getDpnId());
                }
                if (!dpns.contains(BigInteger.valueOf(dpnId))) {
                    LOG.debug("Dpn {} is not included in the current VPN Footprint", dpnId);
                    dpns.add(BigInteger.valueOf(dpnId));
                }
                for (BigInteger dpn : dpns) {
                    VpnServiceChainUtils.programLPortDispatcherFlowForScfToVpn(mdsalManager, vpnId, dpn, vpnPseudoLportTag, addOrRemove);
                }
            } else {
                LOG.debug("Could not find VpnToDpn list for VPN {} with rd {}", vpnName, rd);
            }
        }
        // We need to keep a fake VpnInterface in the DPN where the last vSF (before the VpnPseudoPort) is
        // located, because in case the last real VpnInterface is removed from that DPN, we still need
        // the Fib table programmed there
        String intfName = VpnServiceChainUtils.buildVpnPseudoPortIfName(dpnId, scfTag, servChainTag, vpnPseudoLportTag);
        vpnFootprintService.updateVpnToDpnMapping(BigInteger.valueOf(dpnId), vpnName, rd, intfName, null, /*ipAddressSourceValuePair*/
        addOrRemove == NwConstants.ADD_FLOW);
    }
    LOG.info("L3VPN: Service Chaining programScfToVpnPipeline [End]");
}
Also used : VpnInstanceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry) 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) BigInteger(java.math.BigInteger)

Example 50 with VpnInstance

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

the class EvpnDnatFlowProgrammer method onRemoveFloatingIp.

public void onRemoveFloatingIp(final BigInteger dpnId, final String vpnName, final String externalIp, final String floatingIpInterface, final String floatingIpPortMacAddress, final long routerId, WriteTransaction removeFlowInvTx) {
    /*
     *  1) Remove the flow INTERNAL_TUNNEL_TABLE (table=36)-> PDNAT_TABLE (table=25) (SNAT VM on DPN1 is
     *     responding back to FIP VM on DPN2) {SNAT to DNAT traffic on different Hypervisor}
     *
     *  2) Remove the flow L3_FIB_TABLE (table=21)-> PDNAT_TABLE (table=25) (FIP VM1 to FIP VM2
     *    Traffic on Same Hypervisor) {DNAT to DNAT on Same Hypervisor}
     *
     *  3) Remove the flow L3_GW_MAC_TABLE (table=19)-> PDNAT_TABLE (table=25)
     *    (DC-GW is responding back to FIP VM) {DNAT Reverse traffic})
     *
     */
    String rd = NatUtil.getVpnRd(dataBroker, vpnName);
    if (rd == null) {
        LOG.error("onRemoveFloatingIp : Could not retrieve RD value from VPN Name {}  ", vpnName);
        return;
    }
    long vpnId = NatUtil.getVpnId(dataBroker, vpnName);
    if (vpnId == NatConstants.INVALID_ID) {
        LOG.error("onRemoveFloatingIp : Invalid Vpn Id is found for Vpn Name {}", vpnName);
        return;
    }
    long l3Vni = NatEvpnUtil.getL3Vni(dataBroker, rd);
    if (l3Vni == NatConstants.DEFAULT_L3VNI_VALUE) {
        LOG.debug("onRemoveFloatingIp : L3VNI value is not configured in Internet VPN {} and RD {} " + "Carve-out L3VNI value from OpenDaylight VXLAN VNI Pool and continue with installing " + "DNAT flows for FloatingIp {}", vpnName, rd, externalIp);
        l3Vni = NatOverVxlanUtil.getInternetVpnVni(idManager, vpnName, routerId).longValue();
    }
    String fibExternalIp = NatUtil.validateAndAddNetworkMask(externalIp);
    // Remove Prefix from BGP
    NatUtil.removePrefixFromBGP(bgpManager, fibManager, rd, fibExternalIp, vpnName, LOG);
    // Remove custom FIB routes flow for L3_FIB_TABLE (table=21)-> PDNAT_TABLE (table=25)
    RemoveFibEntryInput input = new RemoveFibEntryInputBuilder().setVpnName(vpnName).setSourceDpid(dpnId).setIpAddress(fibExternalIp).setServiceId(l3Vni).setIpAddressSource(RemoveFibEntryInput.IpAddressSource.FloatingIP).build();
    Future<RpcResult<Void>> future = fibService.removeFibEntry(input);
    ListenableFuture<RpcResult<Void>> futureVxlan = JdkFutureAdapters.listenInPoolThread(future);
    final long finalL3Vni = l3Vni;
    Futures.addCallback(futureVxlan, new FutureCallback<RpcResult<Void>>() {

        @Override
        public void onFailure(@Nonnull Throwable error) {
            LOG.error("onRemoveFloatingIp : Error {} in custom fib routes remove process for Floating " + "IP Prefix {} on DPN {}", error, externalIp, dpnId);
        }

        @Override
        public void onSuccess(@Nonnull RpcResult<Void> result) {
            if (result.isSuccessful()) {
                LOG.info("onRemoveFloatingIp : Successfully removed custom FIB routes for Floating " + "IP Prefix {} on DPN {}", externalIp, dpnId);
                /*  check if any floating IP information is available in vpn-to-dpn-list for given dpn id.
                      *  If exist any floating IP then do not remove
                      *  INTERNAL_TUNNEL_TABLE (table=36) -> PDNAT_TABLE (table=25) flow entry.
                      */
                if (!NatUtil.isFloatingIpPresentForDpn(dataBroker, dpnId, rd, vpnName, externalIp, false)) {
                    // Remove the flow for INTERNAL_TUNNEL_TABLE (table=36)-> PDNAT_TABLE (table=25)
                    removeTunnelTableEntry(dpnId, finalL3Vni, removeFlowInvTx);
                }
                // Remove the flow for L3_GW_MAC_TABLE (table=19)-> PDNAT_TABLE (table=25)
                NatEvpnUtil.removeL3GwMacTableEntry(dpnId, vpnId, floatingIpPortMacAddress, mdsalManager, removeFlowInvTx);
                NatUtil.waitForTransactionToComplete(removeFlowInvTx);
            } else {
                LOG.error("onRemoveFloatingIp : Error {} in rpc call to remove custom Fib entries for Floating " + "IP Prefix {} on DPN {}", result.getErrors(), externalIp, dpnId);
            }
        }
    }, MoreExecutors.directExecutor());
    // Read the FIP vpn-interface details from Operational l3vpn:vpn-interfaces model and delete from Operational DS
    InstanceIdentifier<VpnInterface> vpnIfIdentifier = NatUtil.getVpnInterfaceIdentifier(floatingIpInterface);
    Optional<VpnInterface> optionalVpnInterface = SingleTransactionDataBroker.syncReadOptionalAndTreatReadFailedExceptionAsAbsentOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, vpnIfIdentifier);
    if (optionalVpnInterface.isPresent()) {
        WriteTransaction writeOperTxn = dataBroker.newWriteOnlyTransaction();
        for (VpnInstanceNames vpnInstance : optionalVpnInterface.get().getVpnInstanceNames()) {
            if (!vpnName.equals(vpnInstance.getVpnName())) {
                continue;
            }
            InstanceIdentifier<VpnInterfaceOpDataEntry> vpnOpIfIdentifier = NatUtil.getVpnInterfaceOpDataEntryIdentifier(floatingIpInterface, vpnName);
            writeOperTxn.delete(LogicalDatastoreType.OPERATIONAL, vpnOpIfIdentifier);
            break;
        }
        ListenableFuture<Void> futures = writeOperTxn.submit();
        String errorText = "onRemoveFloatingIp : Could not remove vpnInterface " + floatingIpInterface + " vpnName " + vpnName + " from Operational odl-l3vpn:vpn-interface-op-data";
        ListenableFutures.addErrorLogging(futures, LOG, errorText);
        LOG.debug("onRemoveFloatingIp : Remove vpnInterface {} vpnName {} " + "to Operational odl-l3vpn:vpn-interface-op-data", floatingIpInterface, vpnName);
    } else {
        LOG.debug("onRemoveFloatingIp : No vpnInterface {} found " + "in Operational odl-l3vpn:vpn-interface-op-data", floatingIpInterface);
    }
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) RemoveFibEntryInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fib.rpc.rev160121.RemoveFibEntryInputBuilder) 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) RemoveFibEntryInput(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fib.rpc.rev160121.RemoveFibEntryInput) VpnInterfaceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn._interface.op.data.VpnInterfaceOpDataEntry)

Aggregations

ArrayList (java.util.ArrayList)39 VpnInstanceOpDataEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry)23 VpnInstance (org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.instances.VpnInstance)19 BigInteger (java.math.BigInteger)18 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)17 VpnToDpnList (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnList)16 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)15 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)14 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)14 VpnInterface (org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.VpnInterface)13 VpnInstanceNames (org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.vpn._interface.VpnInstanceNames)13 VpnInterfaceOpDataEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn._interface.op.data.VpnInterfaceOpDataEntry)13 VrfTablesKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTablesKey)12 List (java.util.List)10 Routes (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.to.extraroutes.vpn.extra.routes.Routes)9 Optional (com.google.common.base.Optional)7 PostConstruct (javax.annotation.PostConstruct)7 Inject (javax.inject.Inject)7 Singleton (javax.inject.Singleton)7 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)7