Search in sources :

Example 16 with Bucket

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

the class ItmTunnelAggregationHelper method updateTunnelAggregationGroup.

private void updateTunnelAggregationGroup(InterfaceParentEntry parentEntry) {
    String logicTunnelName = parentEntry.getParentInterface();
    InternalTunnel logicInternalTunnel = ItmUtils.ITM_CACHE.getInternalTunnel(logicTunnelName);
    if (logicInternalTunnel == null) {
        LOG.debug("MULTIPLE_VxLAN_TUNNELS: {} not found in internal tunnels list", logicTunnelName);
        return;
    }
    InterfaceInfo ifLogicTunnel = interfaceManager.getInterfaceInfoFromOperationalDataStore(logicTunnelName);
    long groupId = ifLogicTunnel != null ? interfaceManager.getLogicalTunnelSelectGroupId(ifLogicTunnel.getInterfaceTag()) : INVALID_ID;
    BigInteger srcDpnId = logicInternalTunnel.getSourceDPN();
    List<Bucket> listBuckets = new ArrayList<>();
    List<InterfaceChildEntry> interfaceChildEntries = parentEntry.getInterfaceChildEntry();
    if (interfaceChildEntries == null || interfaceChildEntries.isEmpty()) {
        LOG.debug("MULTIPLE_VxLAN_TUNNELS: empty child list in group {}", parentEntry.getParentInterface());
        return;
    }
    for (InterfaceChildEntry interfaceChildEntry : interfaceChildEntries) {
        String curChildName = interfaceChildEntry.getChildInterface();
        org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface childIface = ItmUtils.getInterface(curChildName, interfaceManager);
        IfTunnel ifTunnel = childIface != null ? childIface.getAugmentation(IfTunnel.class) : null;
        if (ifTunnel == null || !ifTunnel.getTunnelInterfaceType().isAssignableFrom(TunnelTypeVxlan.class)) {
            LOG.debug("MULTIPLE_VxLAN_TUNNELS: not tunnel interface {} found in group {}", curChildName, logicTunnelName);
            continue;
        }
        ParentRefs parentRefs = childIface.getAugmentation(ParentRefs.class);
        if (parentRefs == null) {
            LOG.debug("MULTIPLE_VxLAN_TUNNELS: parent refs not specified for interface {} in group {}", curChildName, logicTunnelName);
            continue;
        }
        InterfaceInfo ifInfo = interfaceManager.getInterfaceInfoFromOperationalDataStore(curChildName);
        if (ifInfo == null) {
            LOG.debug("MULTIPLE_VxLAN_TUNNELS: interface state not found for {} in groupId {}", curChildName, groupId);
            continue;
        }
        int bucketId = interfaceChildEntries.indexOf(interfaceChildEntry);
        LOG.debug("MULTIPLE_VxLAN_TUNNELS: updateTunnelAggregationGroup - add bucketId {} to groupId {}", bucketId, groupId);
        listBuckets.add(createBucket(curChildName, ifTunnel, bucketId, ifInfo.getPortNo()));
    }
    if (!listBuckets.isEmpty()) {
        Group group = MDSALUtil.buildGroup(groupId, logicTunnelName, GroupTypes.GroupSelect, MDSALUtil.buildBucketLists(listBuckets));
        mdsalManager.syncInstallGroup(srcDpnId, group);
    }
}
Also used : TunnelTypeLogicalGroup(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeLogicalGroup) Group(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group) ArrayList(java.util.ArrayList) IfTunnel(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnel) InternalTunnel(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnel.list.InternalTunnel) ParentRefs(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs) Bucket(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket) InterfaceChildEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406._interface.child.info._interface.parent.entry.InterfaceChildEntry) BigInteger(java.math.BigInteger) InterfaceInfo(org.opendaylight.genius.interfacemanager.globals.InterfaceInfo)

Example 17 with Bucket

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

the class MDSALUtil method buildBuckets.

protected static Buckets buildBuckets(List<BucketInfo> listBucketInfo) {
    long index = 0;
    if (listBucketInfo != null) {
        BucketsBuilder bucketsBuilder = new BucketsBuilder();
        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();
    }
    return EMPTY_BUCKETS;
}
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) BucketId(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.BucketId)

Example 18 with Bucket

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

the class MDSALManager method deleteBucket.

public void deleteBucket(BigInteger dpId, long groupId, long bucketId, WriteTransaction tx) {
    Node nodeDpn = buildDpnNode(dpId);
    if (groupExists(nodeDpn, groupId)) {
        InstanceIdentifier<Bucket> bucketInstanceId = buildBucketInstanceIdentifier(groupId, bucketId, nodeDpn);
        tx.delete(LogicalDatastoreType.CONFIGURATION, bucketInstanceId);
    } else {
        LOG.debug("Group {} does not exist for dpn {}", groupId, dpId);
    }
}
Also used : Bucket(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)

Example 19 with Bucket

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

the class MultipartReplyGroupDescDeserializer method deserialize.

@Override
public MultipartReplyBody deserialize(ByteBuf message) {
    final MultipartReplyGroupDescBuilder builder = new MultipartReplyGroupDescBuilder();
    final List<GroupDescStats> items = new ArrayList<>();
    while (message.readableBytes() > 0) {
        final int itemLength = message.readUnsignedShort();
        final GroupDescStatsBuilder itemBuilder = new GroupDescStatsBuilder().setGroupType(GroupTypes.forValue(message.readUnsignedByte()));
        message.skipBytes(PADDING_IN_GROUP_DESC_HEADER);
        itemBuilder.setGroupId(new GroupId(message.readUnsignedInt()));
        itemBuilder.setKey(new GroupDescStatsKey(itemBuilder.getGroupId()));
        final List<Bucket> subItems = new ArrayList<>();
        int actualLength = GROUP_DESC_HEADER_LENGTH;
        long bucketKey = 0;
        while (actualLength < itemLength) {
            final int bucketsLength = message.readUnsignedShort();
            final BucketBuilder bucketBuilder = new BucketBuilder().setBucketId(new BucketId(bucketKey)).setKey(new BucketKey(new BucketId(bucketKey))).setWeight(message.readUnsignedShort()).setWatchPort(message.readUnsignedInt()).setWatchGroup(message.readUnsignedInt());
            message.skipBytes(PADDING_IN_BUCKETS_HEADER);
            final List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> actions = new ArrayList<>();
            final int startIndex = message.readerIndex();
            final int bucketLength = bucketsLength - BUCKETS_HEADER_LENGTH;
            int offset = 0;
            while (message.readerIndex() - startIndex < bucketLength) {
                actions.add(new ActionBuilder().setKey(new ActionKey(offset)).setOrder(offset).setAction(ActionUtil.readAction(EncodeConstants.OF13_VERSION_ID, message, registry, ActionPath.GROUP_DESC_STATS_UPDATED_BUCKET_ACTION)).build());
                offset++;
            }
            bucketBuilder.setAction(actions);
            subItems.add(bucketBuilder.build());
            bucketKey++;
            actualLength += bucketsLength;
        }
        items.add(itemBuilder.setBuckets(new BucketsBuilder().setBucket(subItems).build()).build());
    }
    return builder.setGroupDescStats(items).build();
}
Also used : ActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder) GroupDescStatsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.desc.stats.reply.GroupDescStatsKey) GroupDescStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.desc.stats.reply.GroupDescStatsBuilder) BucketKey(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.BucketKey) ArrayList(java.util.ArrayList) BucketsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.BucketsBuilder) BucketId(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.BucketId) BucketBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.BucketBuilder) GroupDescStats(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.desc.stats.reply.GroupDescStats) ActionKey(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionKey) GroupId(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId) Bucket(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket) MultipartReplyGroupDescBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.multipart.reply.multipart.reply.body.MultipartReplyGroupDescBuilder)

Example 20 with Bucket

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

the class GroupDescStatsResponseConvertor method toSALBucketsDesc.

private org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.Buckets toSALBucketsDesc(List<BucketsList> bucketDescStats, short version) {
    final ActionResponseConvertorData data = new ActionResponseConvertorData(version);
    data.setActionPath(ActionPath.GROUP_DESC_STATS_UPDATED_BUCKET_ACTION);
    org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.BucketsBuilder salBucketsDesc = new org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.BucketsBuilder();
    List<Bucket> allBuckets = new ArrayList<>();
    int bucketKey = 0;
    for (BucketsList bucketDetails : bucketDescStats) {
        BucketBuilder bucketDesc = new BucketBuilder();
        final Optional<List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action>> convertedSalActions = getConvertorExecutor().convert(bucketDetails.getAction(), data);
        if (convertedSalActions.isPresent()) {
            List<Action> actions = new ArrayList<>();
            int actionKey = 0;
            for (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action : convertedSalActions.get()) {
                ActionBuilder wrappedAction = new ActionBuilder();
                wrappedAction.setAction(action);
                wrappedAction.setKey(new ActionKey(actionKey));
                wrappedAction.setOrder(actionKey);
                actions.add(wrappedAction.build());
                actionKey++;
            }
            bucketDesc.setAction(actions);
        } else {
            bucketDesc.setAction(Collections.emptyList());
        }
        bucketDesc.setWeight(bucketDetails.getWeight());
        bucketDesc.setWatchPort(bucketDetails.getWatchPort().getValue());
        bucketDesc.setWatchGroup(bucketDetails.getWatchGroup());
        BucketId bucketId = new BucketId((long) bucketKey);
        bucketDesc.setBucketId(bucketId);
        bucketDesc.setKey(new BucketKey(bucketId));
        bucketKey++;
        allBuckets.add(bucketDesc.build());
    }
    salBucketsDesc.setBucket(allBuckets);
    return salBucketsDesc.build();
}
Also used : Action(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action) ActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder) BucketKey(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.BucketKey) ArrayList(java.util.ArrayList) BucketId(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.BucketId) BucketBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.BucketBuilder) ArrayList(java.util.ArrayList) BucketsList(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.grouping.BucketsList) List(java.util.List) ActionKey(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionKey) Bucket(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket) ActionResponseConvertorData(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData) BucketsList(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.grouping.BucketsList)

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