Search in sources :

Example 26 with Groups

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.result.counterresult.Groups in project netvirt by opendaylight.

the class TunnelInterfaceStateListener method handleTunnelEventForDPN.

// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
private void handleTunnelEventForDPN(StateTunnelList stateTunnelList, TunnelAction tunnelAction) {
    final Uint64 srcDpnId = stateTunnelList.getSrcInfo() != null ? Uint64.valueOf(stateTunnelList.getSrcInfo().getTepDeviceId()).intern() : Uint64.ZERO;
    final String srcTepIp = stateTunnelList.getSrcInfo() != null ? stateTunnelList.getSrcInfo().getTepIp().stringValue() : "0";
    String destTepIp = stateTunnelList.getDstInfo() != null ? stateTunnelList.getDstInfo().getTepIp().stringValue() : "0";
    String rd;
    Uint64 remoteDpnId = null;
    boolean isTepDeletedOnDpn = false;
    LOG.info("handleTunnelEventForDPN: Handle tunnel event for srcDpn {} SrcTepIp {} DestTepIp {} ", srcDpnId, srcTepIp, destTepIp);
    int tunTypeVal = getTunnelType(stateTunnelList);
    LOG.trace("handleTunnelEventForDPN: tunTypeVal is {}", tunTypeVal);
    try {
        if (tunnelAction == TunnelAction.TUNNEL_EP_ADD) {
            LOG.info("handleTunnelEventForDPN: Tunnel ADD event received for Dpn {} VTEP Ip {} destTepIp {}", srcDpnId, srcTepIp, destTepIp);
            if (isTunnelInLogicalGroup(stateTunnelList)) {
                return;
            }
        } else if (tunnelAction == TunnelAction.TUNNEL_EP_DELETE) {
            LOG.info("handleTunnelEventForDPN: Tunnel DELETE event received for Dpn {} VTEP Ip {} DestTepIp {}", srcDpnId, srcTepIp, destTepIp);
            // When tunnel EP is deleted on a DPN , VPN gets two deletion event.
            // One for a DPN on which tunnel EP was deleted and another for other-end DPN.
            // Update the adj for the vpninterfaces for a DPN on which TEP is deleted.
            // Update the adj & VRF for the vpninterfaces for a DPN on which TEP is deleted.
            // Dont update the adj & VRF for vpninterfaces for a DPN on which TEP is not deleted.
            String endpointIpForDPN;
            try {
                endpointIpForDPN = InterfaceUtils.getEndpointIpAddressForDPN(dataBroker, srcDpnId);
            } catch (Exception e) {
                LOG.error("handleTunnelEventForDPN: Unable to resolve endpoint IP for srcDpn {}", srcDpnId);
                /* this dpn does not have the VTEP */
                endpointIpForDPN = null;
            }
            if (endpointIpForDPN == null) {
                LOG.info("handleTunnelEventForDPN: Tunnel TEP is deleted on Dpn {} VTEP Ip {} destTepIp {}", srcDpnId, srcTepIp, destTepIp);
                isTepDeletedOnDpn = true;
            }
        }
        // Get the list of VpnInterfaces from Intf Mgr for a SrcDPN on which TEP is added/deleted
        Future<RpcResult<GetDpnInterfaceListOutput>> result;
        List<Interfaces> srcDpninterfacelist = new ArrayList<>();
        List<Interfaces> destDpninterfacelist = new ArrayList<>();
        try {
            result = intfRpcService.getDpnInterfaceList(new GetDpnInterfaceListInputBuilder().setDpid(srcDpnId).build());
            RpcResult<GetDpnInterfaceListOutput> rpcResult = result.get();
            if (!rpcResult.isSuccessful()) {
                LOG.error("handleTunnelEventForDPN: RPC Call to GetDpnInterfaceList for srcDpnid {} srcTepIp {}" + " destTepIP {} returned with Errors {}", srcDpnId, srcTepIp, destTepIp, rpcResult.getErrors());
            } else {
                srcDpninterfacelist = rpcResult.getResult().nonnullInterfaces();
            }
        } catch (Exception e) {
            LOG.error("handleTunnelEventForDPN: Exception when querying for GetDpnInterfaceList for srcDpnid {}" + " srcTepIp {} destTepIp {}", srcDpnId, srcTepIp, destTepIp, e);
        }
        // Get the list of VpnInterfaces from Intf Mgr for a destDPN only for internal tunnel.
        if (tunTypeVal == VpnConstants.ITMTunnelLocType.Internal.getValue()) {
            remoteDpnId = Uint64.valueOf(stateTunnelList.getDstInfo() != null ? stateTunnelList.getDstInfo().getTepDeviceId() : "0").intern();
            try {
                result = intfRpcService.getDpnInterfaceList(new GetDpnInterfaceListInputBuilder().setDpid(remoteDpnId).build());
                RpcResult<GetDpnInterfaceListOutput> rpcResult = result.get();
                if (!rpcResult.isSuccessful()) {
                    LOG.error("handleTunnelEventForDPN: RPC Call to GetDpnInterfaceList for remoteDpnid {}" + " srcTepIP {} destTepIp {} returned with Errors {}", remoteDpnId, srcTepIp, destTepIp, rpcResult.getErrors());
                } else {
                    destDpninterfacelist = rpcResult.getResult().nonnullInterfaces();
                }
            } catch (Exception e) {
                LOG.error("handleTunnelEventForDPN: Exception when querying for GetDpnInterfaceList" + " for remoteDpnid {} srcTepIp {} destTepIp {}", remoteDpnId, srcTepIp, destTepIp, e);
            }
        }
        /*
             * Iterate over the list of VpnInterface for a SrcDpn on which TEP is added or deleted and read the adj.
             * Update the adjacencies with the updated nexthop.
             */
        List<Uuid> subnetList = new ArrayList<>();
        Map<Uint32, String> vpnIdRdMap = new HashMap<>();
        Set<String> listVpnName = new HashSet<>();
        for (Interfaces interfaces : srcDpninterfacelist) {
            if (!L2vlan.class.equals(interfaces.getInterfaceType())) {
                LOG.info("handleTunnelEventForDPN: Interface {} not of type L2Vlan", interfaces.getInterfaceName());
                continue;
            }
            String intfName = interfaces.getInterfaceName();
            VpnInterface vpnInterface = vpnUtil.getConfiguredVpnInterface(intfName);
            if (vpnInterface != null) {
                listVpnName.addAll(VpnHelper.getVpnInterfaceVpnInstanceNamesString(new ArrayList<VpnInstanceNames>(vpnInterface.nonnullVpnInstanceNames().values())));
                handleTunnelEventForDPNVpn(stateTunnelList, vpnIdRdMap, tunnelAction, isTepDeletedOnDpn, subnetList, TunnelEventProcessingMethod.POPULATESUBNETS, vpnInterface);
            }
        }
        /*
             * Iterate over the list of VpnInterface for destDPN and get the prefix .
             * Create remote rule for each of those prefix on srcDPN.
             */
        for (Interfaces interfaces : destDpninterfacelist) {
            if (!L2vlan.class.equals(interfaces.getInterfaceType())) {
                LOG.info("handleTunnelEventForDPN: Interface {} not of type L2Vlan", interfaces.getInterfaceName());
                continue;
            }
            String intfName = interfaces.getInterfaceName();
            VpnInterface vpnInterface = vpnUtil.getConfiguredVpnInterface(intfName);
            if (vpnInterface != null) {
                handleTunnelEventForDPNVpn(stateTunnelList, vpnIdRdMap, tunnelAction, isTepDeletedOnDpn, subnetList, TunnelEventProcessingMethod.MANAGEREMOTEROUTES, vpnInterface);
            }
        }
        // Iterate over the VpnId-to-Rd map.
        for (Map.Entry<Uint32, String> entry : vpnIdRdMap.entrySet()) {
            Uint32 vpnId = entry.getKey();
            rd = entry.getValue();
            if (tunnelAction == TunnelAction.TUNNEL_EP_ADD && tunTypeVal == VpnConstants.ITMTunnelLocType.External.getValue()) {
                fibManager.populateExternalRoutesOnDpn(srcDpnId, vpnId, rd, srcTepIp, destTepIp);
            } else if (tunnelAction == TunnelAction.TUNNEL_EP_DELETE && tunTypeVal == VpnConstants.ITMTunnelLocType.External.getValue()) {
                fibManager.cleanUpExternalRoutesOnDpn(srcDpnId, vpnId, rd, srcTepIp, destTepIp);
            }
        }
        if (listVpnName.size() >= 1) {
            if (tunnelAction == TunnelAction.TUNNEL_EP_ADD) {
                for (Uuid subnetId : subnetList) {
                    // Populate the List of subnets
                    vpnSubnetRouteHandler.updateSubnetRouteOnTunnelUpEvent(subnetId, srcDpnId);
                }
            }
            if (tunnelAction == TunnelAction.TUNNEL_EP_DELETE && isTepDeletedOnDpn) {
                for (Uuid subnetId : subnetList) {
                    // Populate the List of subnets
                    vpnSubnetRouteHandler.updateSubnetRouteOnTunnelDownEvent(subnetId, srcDpnId);
                }
            }
        }
        /*
             * Program the BGP routes of all the VPNs which have footprint on the source DPN.
             *
             * DC-GW LB groups are programmed in DJC Jobs, so DJC with same key is used here to make sure
             * groups are programmed first, then only BGP routes are programmed.
             */
        jobCoordinator.enqueueJob(FibHelper.getJobKeyForDcGwLoadBalancingGroup(srcDpnId), () -> {
            listVpnName.forEach(vpnName -> {
                Uint32 vpnId = vpnUtil.getVpnId(vpnName);
                final String vrfId = vpnIdRdMap.get(vpnId);
                if ((tunnelAction == TunnelAction.TUNNEL_EP_ADD) && (tunTypeVal == VpnConstants.ITMTunnelLocType.External.getValue())) {
                    fibManager.populateExternalRoutesOnDpn(srcDpnId, vpnId, vrfId, srcTepIp, destTepIp);
                }
            });
            return Collections.emptyList();
        }, RETRY_COUNT);
    } catch (RuntimeException e) {
        LOG.error("handleTunnelEventForDpn: Unable to handle the tunnel event for srcDpnId {} srcTepIp {}" + " remoteDpnId {} destTepIp {}", srcDpnId, srcTepIp, remoteDpnId, destTepIp, e);
    }
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) GetDpnInterfaceListOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetDpnInterfaceListOutput) Uint32(org.opendaylight.yangtools.yang.common.Uint32) HashSet(java.util.HashSet) L2vlan(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev170119.L2vlan) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) ExecutionException(java.util.concurrent.ExecutionException) Interfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.get.dpn._interface.list.output.Interfaces) GetDpnInterfaceListInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetDpnInterfaceListInputBuilder) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) VpnInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.interfaces.VpnInterface) Map(java.util.Map) HashMap(java.util.HashMap) Uint64(org.opendaylight.yangtools.yang.common.Uint64)

Example 27 with Groups

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.result.counterresult.Groups in project bgpcep by opendaylight.

the class LinkAttributesParser method parseSrlg.

private static void parseSrlg(final ByteBuf value, final LinkAttributesBuilder builder) {
    final List<SrlgId> sharedRiskLinkGroups = new ArrayList<>();
    while (value.isReadable()) {
        sharedRiskLinkGroups.add(new SrlgId(readUint32(value)));
    }
    builder.setSharedRiskLinkGroups(sharedRiskLinkGroups);
    LOG.debug("Parsed Shared Risk Link Groups {}", builder.getSharedRiskLinkGroups());
}
Also used : ArrayList(java.util.ArrayList) SrlgId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.SrlgId)

Aggregations

ArrayList (java.util.ArrayList)16 Group (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group)11 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)10 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)9 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)8 Map (java.util.Map)7 TableKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey)7 List (java.util.List)6 Meter (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter)6 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)6 GroupKey (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupKey)6 Logger (org.slf4j.Logger)6 LoggerFactory (org.slf4j.LoggerFactory)6 Futures (com.google.common.util.concurrent.Futures)5 MoreExecutors (com.google.common.util.concurrent.MoreExecutors)5 Collections (java.util.Collections)5 ItemSyncBox (org.opendaylight.openflowplugin.applications.frsync.util.ItemSyncBox)5 SyncCrudCounters (org.opendaylight.openflowplugin.applications.frsync.util.SyncCrudCounters)5 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)5 JdkFutureAdapters (com.google.common.util.concurrent.JdkFutureAdapters)4