Search in sources :

Example 21 with VpnInterfaceOpDataEntry

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn._interface.op.data.VpnInterfaceOpDataEntry 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 22 with VpnInterfaceOpDataEntry

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn._interface.op.data.VpnInterfaceOpDataEntry 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 23 with VpnInterfaceOpDataEntry

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn._interface.op.data.VpnInterfaceOpDataEntry in project netvirt by opendaylight.

the class SubnetRouteInterfaceStateChangeListener method update.

// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
@Override
protected void update(InstanceIdentifier<Interface> identifier, Interface original, Interface update) {
    try {
        String interfaceName = update.getName();
        if (L2vlan.class.equals(update.getType())) {
            LOG.trace("{} update: Operation Interface update event - Old: {}, New: {}", LOGGING_PREFIX, original, update);
            List<Uuid> subnetIdList = getSubnetId(update);
            if (subnetIdList.isEmpty()) {
                LOG.error("SubnetRouteInterfaceListener update: Port {} doesn't exist in configDS", update.getName());
                return;
            }
            for (Uuid subnetId : subnetIdList) {
                jobCoordinator.enqueueJob("SUBNETROUTE-" + subnetId, () -> {
                    List<ListenableFuture<Void>> futures = new ArrayList<>();
                    BigInteger dpnId = BigInteger.ZERO;
                    try {
                        dpnId = InterfaceUtils.getDpIdFromInterface(update);
                    } catch (Exception e) {
                        LOG.error("{} remove: Unable to retrieve dpnId for interface {} in subnet  {}. " + "Fetching from vpn interface itself", LOGGING_PREFIX, update.getName(), subnetId, e);
                    }
                    InstanceIdentifier<VpnInterface> id = VpnUtil.getVpnInterfaceIdentifier(interfaceName);
                    Optional<VpnInterface> cfgVpnInterface = VpnUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, id);
                    if (!cfgVpnInterface.isPresent()) {
                        return futures;
                    }
                    boolean interfaceChangeEligible = false;
                    for (VpnInstanceNames vpnInterfaceVpnInstance : cfgVpnInterface.get().getVpnInstanceNames()) {
                        String vpnName = vpnInterfaceVpnInstance.getVpnName();
                        InstanceIdentifier<VpnInterfaceOpDataEntry> idOper = VpnUtil.getVpnInterfaceOpDataEntryIdentifier(interfaceName, vpnName);
                        Optional<VpnInterfaceOpDataEntry> optVpnInterface = VpnUtil.read(dataBroker, LogicalDatastoreType.OPERATIONAL, idOper);
                        if (optVpnInterface.isPresent()) {
                            BigInteger dpnIdLocal = dpnId;
                            if (dpnIdLocal.equals(BigInteger.ZERO)) {
                                dpnIdLocal = optVpnInterface.get().getDpnId();
                            }
                            if (!dpnIdLocal.equals(BigInteger.ZERO)) {
                                interfaceChangeEligible = true;
                                break;
                            }
                        }
                    }
                    if (interfaceChangeEligible) {
                        if (update.getOperStatus().equals(Interface.OperStatus.Up)) {
                            LOG.info("{} update: Received port UP event for interface {} in subnet {}", LOGGING_PREFIX, update.getName(), subnetId);
                            vpnSubnetRouteHandler.onInterfaceUp(dpnId, update.getName(), subnetId);
                        } else if (update.getOperStatus().equals(Interface.OperStatus.Down) || update.getOperStatus().equals(Interface.OperStatus.Unknown)) {
                            /*
                                     * If the interface went down voluntarily (or) if the interface is not
                                     * reachable from control-path involuntarily, trigger subnetRoute election
                                     */
                            LOG.info("{} update: Received port {} event for interface {} in subnet {} ", LOGGING_PREFIX, update.getOperStatus().equals(Interface.OperStatus.Unknown) ? "UNKNOWN" : "DOWN", update.getName(), subnetId);
                            vpnSubnetRouteHandler.onInterfaceDown(dpnId, update.getName(), subnetId);
                        }
                    }
                    return futures;
                });
            }
        }
        LOG.info("{} update: Processed Interface {} update event", LOGGING_PREFIX, update.getName());
    } catch (Exception e) {
        LOG.error("{} update: Exception observed in handling deletion of VPNInterface {}", LOGGING_PREFIX, update.getName(), e);
    }
}
Also used : ArrayList(java.util.ArrayList) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) 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) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) BigInteger(java.math.BigInteger) VpnInterfaceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn._interface.op.data.VpnInterfaceOpDataEntry)

Example 24 with VpnInterfaceOpDataEntry

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn._interface.op.data.VpnInterfaceOpDataEntry 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 25 with VpnInterfaceOpDataEntry

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn._interface.op.data.VpnInterfaceOpDataEntry 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

VpnInterfaceOpDataEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn._interface.op.data.VpnInterfaceOpDataEntry)21 Adjacency (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.adjacency.list.Adjacency)16 ArrayList (java.util.ArrayList)14 AdjacenciesOp (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.AdjacenciesOp)12 BigInteger (java.math.BigInteger)11 VpnInterface (org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.VpnInterface)11 VpnInstanceNames (org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.vpn._interface.VpnInstanceNames)11 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)9 ExecutionException (java.util.concurrent.ExecutionException)8 VpnInterfaceOpDataEntryKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn._interface.op.data.VpnInterfaceOpDataEntryKey)8 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)7 VrfEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry)7 VpnInstanceOpDataEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry)7 List (java.util.List)6 VpnInterfaceOpDataEntryBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn._interface.op.data.VpnInterfaceOpDataEntryBuilder)6 Optional (com.google.common.base.Optional)5 VpnInterfaceKey (org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.VpnInterfaceKey)5 FutureCallback (com.google.common.util.concurrent.FutureCallback)4 Futures (com.google.common.util.concurrent.Futures)4 PostConstruct (javax.annotation.PostConstruct)4