Search in sources :

Example 31 with Bucket

use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket in project netvirt by opendaylight.

the class FibUtil method buildBuckets.

static Buckets buildBuckets(List<BucketInfo> listBucketInfo) {
    long index = 0;
    BucketsBuilder bucketsBuilder = new BucketsBuilder();
    if (listBucketInfo != null) {
        List<Bucket> bucketList = new ArrayList<>();
        for (BucketInfo bucketInfo : listBucketInfo) {
            BucketBuilder bucketBuilder = new BucketBuilder();
            bucketBuilder.setAction(bucketInfo.buildActions());
            bucketBuilder.setWeight(bucketInfo.getWeight());
            bucketBuilder.setBucketId(new BucketId(index++));
            bucketBuilder.setWeight(bucketInfo.getWeight()).setWatchPort(bucketInfo.getWatchPort()).setWatchGroup(bucketInfo.getWatchGroup());
            bucketList.add(bucketBuilder.build());
        }
        bucketsBuilder.setBucket(bucketList);
    }
    return bucketsBuilder.build();
}
Also used : BucketBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.BucketBuilder) Bucket(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket) ArrayList(java.util.ArrayList) BucketsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.BucketsBuilder) BucketInfo(org.opendaylight.genius.mdsalutil.BucketInfo) BucketId(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.BucketId)

Example 32 with Bucket

use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket in project netvirt by opendaylight.

the class NexthopManager method getBucketsForRemoteNexthop.

private List<BucketInfo> getBucketsForRemoteNexthop(Long vpnId, BigInteger dpnId, VrfEntry vrfEntry, String rd, List<Routes> vpnExtraRoutes) {
    List<BucketInfo> listBucketInfo = new ArrayList<>();
    Map<String, List<ActionInfo>> egressActionMap = new HashMap<>();
    vpnExtraRoutes.forEach(vpnExtraRoute -> vpnExtraRoute.getNexthopIpList().forEach(nextHopIp -> {
        String nextHopPrefixIp;
        if (isIpv4Address(nextHopIp)) {
            nextHopPrefixIp = nextHopIp + NwConstants.IPV4PREFIX;
        } else {
            nextHopPrefixIp = nextHopIp + NwConstants.IPV6PREFIX;
        }
        List<String> tepIpAddresses = fibUtil.getNextHopAddresses(rd, nextHopPrefixIp);
        if (tepIpAddresses.isEmpty()) {
            return;
        }
        // There would be only one nexthop address for a VM ip which would be the tep Ip
        String tepIp = tepIpAddresses.get(0);
        AdjacencyResult adjacencyResult = getRemoteNextHopPointer(dpnId, vpnId, vrfEntry.getDestPrefix(), tepIp);
        if (adjacencyResult == null) {
            return;
        }
        String egressInterface = adjacencyResult.getInterfaceName();
        if (!FibUtil.isTunnelInterface(adjacencyResult)) {
            return;
        }
        Class<? extends TunnelTypeBase> tunnelType = VpnExtraRouteHelper.getTunnelType(interfaceManager, egressInterface);
        Interface ifState = fibUtil.getInterfaceStateFromOperDS(egressInterface);
        if (ifState == null || ifState.getOperStatus() != OperStatus.Up) {
            LOG.trace("Tunnel not up {}", egressInterface);
            return;
        }
        if (!TunnelTypeVxlan.class.equals(tunnelType)) {
            return;
        }
        Long label = FibUtil.getLabelFromRoutePaths(vrfEntry).get();
        Prefixes prefixInfo = fibUtil.getPrefixToInterface(vpnId, nextHopPrefixIp);
        BigInteger tunnelId;
        if (fibUtil.enforceVxlanDatapathSemanticsforInternalRouterVpn(prefixInfo.getSubnetId(), vpnId, rd)) {
            java.util.Optional<Long> optionalVni = fibUtil.getVniForVxlanNetwork(prefixInfo.getSubnetId());
            if (!optionalVni.isPresent()) {
                LOG.error("VNI not found for nexthop {} vrfEntry {} with subnetId {}", nextHopIp, vrfEntry, prefixInfo.getSubnetId());
                return;
            }
            tunnelId = BigInteger.valueOf(optionalVni.get());
        } else {
            tunnelId = BigInteger.valueOf(label);
        }
        List<ActionInfo> actionInfos = new ArrayList<>();
        actionInfos.add(new ActionSetFieldTunnelId(tunnelId));
        String ifName = prefixInfo.getVpnInterfaceName();
        String vpnName = fibUtil.getVpnNameFromId(vpnId);
        if (vpnName == null) {
            return;
        }
        String macAddress = fibUtil.getMacAddressFromPrefix(ifName, vpnName, nextHopPrefixIp);
        actionInfos.add(new ActionSetFieldEthernetDestination(actionInfos.size(), new MacAddress(macAddress)));
        List<ActionInfo> egressActions;
        if (egressActionMap.containsKey(egressInterface)) {
            egressActions = egressActionMap.get(egressInterface);
        } else {
            egressActions = getEgressActionsForInterface(egressInterface, actionInfos.size());
            egressActionMap.put(egressInterface, egressActions);
        }
        if (egressActions.isEmpty()) {
            LOG.error("Failed to retrieve egress action for prefix {} route-paths {}" + " interface {}." + " Aborting remote FIB entry creation.", vrfEntry.getDestPrefix(), vrfEntry.getRoutePaths(), egressInterface);
        }
        actionInfos.addAll(egressActions);
        BucketInfo bucket = new BucketInfo(actionInfos);
        bucket.setWeight(1);
        listBucketInfo.add(bucket);
    }));
    LOG.trace("LOCAL: listbucket {}, rd {}, dpnId {}, routes {}", listBucketInfo, rd, dpnId, vpnExtraRoutes);
    return listBucketInfo;
}
Also used : ActionOutput(org.opendaylight.genius.mdsalutil.actions.ActionOutput) NxActionResubmitRpcAddGroupCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.add.group.input.buckets.bucket.action.action.NxActionResubmitRpcAddGroupCase) StateTunnelList(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnels_state.StateTunnelList) GetInternalOrExternalInterfaceNameOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetInternalOrExternalInterfaceNameOutput) Future(java.util.concurrent.Future) NxActionRegLoadNodesNodeTableFlowApplyActionsCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nodes.node.table.flow.instructions.instruction.instruction.apply.actions._case.apply.actions.action.action.NxActionRegLoadNodesNodeTableFlowApplyActionsCase) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) Optional(com.google.common.base.Optional) Subnetmap(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.subnetmaps.Subnetmap) Map(java.util.Map) TunnelTypeGre(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeGre) SegmentTypeVlan(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.SegmentTypeVlan) BigInteger(java.math.BigInteger) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) Bucket(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket) CreateIdPoolInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.CreateIdPoolInput) StateTunnelListKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnels_state.StateTunnelListKey) ReleaseIdInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.ReleaseIdInput) NodeRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef) SegmentTypeFlat(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.SegmentTypeFlat) GroupId(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId) DataBroker(org.opendaylight.controller.md.sal.binding.api.DataBroker) GetTunnelInterfaceNameInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetTunnelInterfaceNameInputBuilder) GroupRef(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupRef) TunnelOperStatus(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.TunnelOperStatus) SalGroupService(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.SalGroupService) ActionSetFieldVlanVid(org.opendaylight.genius.mdsalutil.actions.ActionSetFieldVlanVid) ConfTransportTypeL3vpn(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.ConfTransportTypeL3vpn) NWUtil.isIpv4Address(org.opendaylight.genius.mdsalutil.NWUtil.isIpv4Address) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) AllocateIdOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdOutput) ActionSetFieldTunnelId(org.opendaylight.genius.mdsalutil.actions.ActionSetFieldTunnelId) OdlInterfaceRpcService(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.OdlInterfaceRpcService) PushVlanActionCase(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushVlanActionCase) IElanService(org.opendaylight.netvirt.elanmanager.api.IElanService) ArrayList(java.util.ArrayList) InstanceIdentifierBuilder(org.opendaylight.yangtools.yang.binding.InstanceIdentifier.InstanceIdentifierBuilder) TunnelTypeVxlan(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeVxlan) ConfTransportTypeL3vpnBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.ConfTransportTypeL3vpnBuilder) NxRegLoad(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.load.grouping.NxRegLoad) ActionGroup(org.opendaylight.genius.mdsalutil.actions.ActionGroup) VpnNexthops(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3nexthop.rev150409.l3nexthop.VpnNexthops) L2vlan(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.L2vlan) ExecutionException(java.util.concurrent.ExecutionException) Prefixes(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.prefix.to._interface.vpn.ids.Prefixes) AddGroupOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupOutput) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) VpnNexthopKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3nexthop.rev150409.l3nexthop.vpnnexthops.VpnNexthopKey) IMdsalApiManager(org.opendaylight.genius.mdsalutil.interfaces.IMdsalApiManager) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) Preconditions(com.google.common.base.Preconditions) GroupTypes(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupTypes) Tunnel(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.Tunnel) SegmentTypeBase(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.SegmentTypeBase) InterfaceType(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfaceType) LoggerFactory(org.slf4j.LoggerFactory) ActionNxResubmit(org.opendaylight.genius.mdsalutil.actions.ActionNxResubmit) GetInternalOrExternalInterfaceNameInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetInternalOrExternalInterfaceNameInputBuilder) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) PreDestroy(javax.annotation.PreDestroy) NxmNxReg6(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg6) Locale(java.util.Locale) AddGroupInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInputBuilder) MDSALUtil(org.opendaylight.genius.mdsalutil.MDSALUtil) Action(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action) GetTunnelInterfaceNameOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetTunnelInterfaceNameOutput) TunnelTypeMplsOverGre(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeMplsOverGre) TunnelsState(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.TunnelsState) LogicalDatastoreType(org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType) Routes(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.to.extraroutes.vpn.extra.routes.Routes) ActionPushMpls(org.opendaylight.genius.mdsalutil.actions.ActionPushMpls) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface) WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) AllocateIdInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInput) ActionPushVlan(org.opendaylight.genius.mdsalutil.actions.ActionPushVlan) ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance) List(java.util.List) Nexthops(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.l3vpn.lb.nexthops.Nexthops) ActionSetFieldEthernetDestination(org.opendaylight.genius.mdsalutil.actions.ActionSetFieldEthernetDestination) TunnelTypeBase(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeBase) ActionRegMove(org.opendaylight.genius.mdsalutil.actions.ActionRegMove) DpnLbNexthops(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.dpid.l3vpn.lb.nexthops.DpnLbNexthops) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) VpnNexthopBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3nexthop.rev150409.l3nexthop.vpnnexthops.VpnNexthopBuilder) HashMap(java.util.HashMap) VrfEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry) Singleton(javax.inject.Singleton) ActionSetFieldEthernetSource(org.opendaylight.genius.mdsalutil.actions.ActionSetFieldEthernetSource) L3nexthop(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3nexthop.rev150409.L3nexthop) Inject(javax.inject.Inject) CreateIdPoolInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.CreateIdPoolInputBuilder) AddGroupInput(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInput) VpnNexthopsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3nexthop.rev150409.l3nexthop.VpnNexthopsKey) ActionRegLoad(org.opendaylight.genius.mdsalutil.actions.ActionRegLoad) NwConstants(org.opendaylight.genius.mdsalutil.NwConstants) VpnNexthop(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3nexthop.rev150409.l3nexthop.vpnnexthops.VpnNexthop) SetFieldCase(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetFieldCase) VpnExtraRouteHelper(org.opendaylight.netvirt.vpnmanager.api.VpnExtraRouteHelper) Logger(org.slf4j.Logger) OperStatus(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus) Group(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group) Buckets(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.Buckets) JobCoordinator(org.opendaylight.infrautils.jobcoordinator.JobCoordinator) ReleaseIdInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.ReleaseIdInputBuilder) GroupEntity(org.opendaylight.genius.mdsalutil.GroupEntity) IdManagerService(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.IdManagerService) L3VPNTransportTypes(org.opendaylight.netvirt.fibmanager.api.L3VPNTransportTypes) GetEgressActionsForInterfaceOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetEgressActionsForInterfaceOutput) OutputActionCase(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCase) AllocateIdInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInputBuilder) ITMConstants(org.opendaylight.genius.itm.globals.ITMConstants) GetEgressActionsForInterfaceInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetEgressActionsForInterfaceInputBuilder) BucketInfo(org.opendaylight.genius.mdsalutil.BucketInfo) Collections(java.util.Collections) ItmRpcService(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.ItmRpcService) Optional(com.google.common.base.Optional) HashMap(java.util.HashMap) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ArrayList(java.util.ArrayList) Prefixes(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.prefix.to._interface.vpn.ids.Prefixes) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) ActionSetFieldTunnelId(org.opendaylight.genius.mdsalutil.actions.ActionSetFieldTunnelId) TunnelTypeBase(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeBase) ActionSetFieldEthernetDestination(org.opendaylight.genius.mdsalutil.actions.ActionSetFieldEthernetDestination) BigInteger(java.math.BigInteger) StateTunnelList(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnels_state.StateTunnelList) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ArrayList(java.util.ArrayList) List(java.util.List) BucketInfo(org.opendaylight.genius.mdsalutil.BucketInfo) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface)

Example 33 with Bucket

use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket in project netvirt by opendaylight.

the class NexthopManager method buildBucketForDcGwLbGroup.

private Bucket buildBucketForDcGwLbGroup(String ipAddress, BigInteger dpnId, int index) {
    List<Action> listAction = new ArrayList<>();
    // ActionKey 0 goes to mpls label.
    int actionKey = 1;
    listAction.add(new ActionPushMpls().buildAction());
    listAction.add(new ActionRegMove(actionKey++, FibConstants.NXM_REG_MAPPING.get(index), 0, 19).buildAction());
    String tunnelInterfaceName = getTunnelInterfaceName(dpnId, new IpAddress(ipAddress.toCharArray()));
    List<Action> egressActions = getEgressActions(tunnelInterfaceName, actionKey++);
    if (!egressActions.isEmpty()) {
        listAction.addAll(getEgressActions(tunnelInterfaceName, actionKey++));
    } else {
        // clear off actions if there is no egress actions.
        listAction = Collections.emptyList();
    }
    return MDSALUtil.buildBucket(listAction, MDSALUtil.GROUP_WEIGHT, index, MDSALUtil.WATCH_PORT, MDSALUtil.WATCH_GROUP);
}
Also used : ActionPushMpls(org.opendaylight.genius.mdsalutil.actions.ActionPushMpls) Action(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action) ActionRegMove(org.opendaylight.genius.mdsalutil.actions.ActionRegMove) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ArrayList(java.util.ArrayList) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)

Example 34 with Bucket

use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket in project netvirt by opendaylight.

the class NexthopManager method updateDcGwLoadBalancingGroup.

/**
 * This method is invoked when the tunnel status is updated.
 * The bucket is directly removed/added based on the operational status of the tunnel.
 */
public void updateDcGwLoadBalancingGroup(List<String> availableDcGws, BigInteger dpnId, String destinationIp, boolean isTunnelUp) {
    Preconditions.checkNotNull(availableDcGws, "There are no dc-gws present");
    WriteTransaction configTx = dataBroker.newWriteOnlyTransaction();
    // TODO : Place the logic to construct all possible DC-GW combination here.
    int bucketId = availableDcGws.indexOf(destinationIp);
    Optional<DpnLbNexthops> dpnLbNextHops = fibUtil.getDpnLbNexthops(dpnId, destinationIp);
    if (!dpnLbNextHops.isPresent()) {
        return;
    }
    List<String> nextHopKeys = dpnLbNextHops.get().getNexthopKey();
    nextHopKeys.forEach(nextHopKey -> {
        Optional<Nexthops> optionalNextHops = fibUtil.getNexthops(nextHopKey);
        if (!optionalNextHops.isPresent()) {
            return;
        }
        Nexthops nexthops = optionalNextHops.get();
        final String groupId = nexthops.getGroupId();
        final long groupIdValue = Long.parseLong(groupId);
        if (isTunnelUp) {
            Bucket bucket = buildBucketForDcGwLbGroup(destinationIp, dpnId, bucketId);
            LOG.trace("Added bucket {} to group {} on dpn {}.", bucket, groupId, dpnId);
            mdsalApiManager.addBucketToTx(dpnId, groupIdValue, bucket, configTx);
        } else {
            LOG.trace("Removed bucketId {} from group {} on dpn {}.", bucketId, groupId, dpnId);
            mdsalApiManager.removeBucketToTx(dpnId, groupIdValue, bucketId, configTx);
        }
    });
    configTx.submit();
    return;
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) DpnLbNexthops(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.dpid.l3vpn.lb.nexthops.DpnLbNexthops) Bucket(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket) VpnNexthops(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3nexthop.rev150409.l3nexthop.VpnNexthops) Nexthops(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.l3vpn.lb.nexthops.Nexthops) DpnLbNexthops(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.dpid.l3vpn.lb.nexthops.DpnLbNexthops)

Example 35 with Bucket

use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket in project netvirt by opendaylight.

the class NexthopManager method getBucketsForLocalNexthop.

private List<BucketInfo> getBucketsForLocalNexthop(Long vpnId, BigInteger dpnId, VrfEntry vrfEntry, Routes routes) {
    List<BucketInfo> listBucketInfo = new CopyOnWriteArrayList<>();
    routes.getNexthopIpList().parallelStream().forEach(nextHopIp -> {
        String localNextHopIP;
        if (isIpv4Address(nextHopIp)) {
            localNextHopIP = nextHopIp + NwConstants.IPV4PREFIX;
        } else {
            localNextHopIP = nextHopIp + NwConstants.IPV6PREFIX;
        }
        Prefixes localNextHopInfo = fibUtil.getPrefixToInterface(vpnId, localNextHopIP);
        if (localNextHopInfo != null) {
            long groupId = getLocalNextHopGroup(vpnId, localNextHopIP);
            if (groupId == FibConstants.INVALID_GROUP_ID) {
                LOG.error("Unable to allocate groupId for vpnId {} , prefix {} , interface {}", vpnId, vrfEntry.getDestPrefix(), localNextHopInfo.getVpnInterfaceName());
                return;
            }
            List<ActionInfo> actionsInfos = Collections.singletonList(new ActionGroup(groupId));
            BucketInfo bucket = new BucketInfo(actionsInfos);
            bucket.setWeight(1);
            listBucketInfo.add(bucket);
        }
    });
    LOG.trace("LOCAL: listbucket {}, vpnId {}, dpnId {}, routes {}", listBucketInfo, vpnId, dpnId, routes);
    return listBucketInfo;
}
Also used : ActionGroup(org.opendaylight.genius.mdsalutil.actions.ActionGroup) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) BucketInfo(org.opendaylight.genius.mdsalutil.BucketInfo) Prefixes(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.prefix.to._interface.vpn.ids.Prefixes) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList)

Aggregations

ArrayList (java.util.ArrayList)41 Bucket (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket)41 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action)16 BucketBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.BucketBuilder)14 BucketsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.BucketsBuilder)13 ActionGroup (org.opendaylight.genius.mdsalutil.actions.ActionGroup)12 Group (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group)12 BigInteger (java.math.BigInteger)11 GroupId (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId)11 Test (org.junit.Test)10 ActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder)8 BucketId (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.BucketId)8 BucketsList (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.grouping.BucketsList)8 List (java.util.List)6 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)5 Buckets (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.Buckets)5 ActionInfo (org.opendaylight.genius.mdsalutil.ActionInfo)4 BucketInfo (org.opendaylight.genius.mdsalutil.BucketInfo)4 VersionConvertorData (org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData)4 GroupActionCase (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCase)4