Search in sources :

Example 1 with BucketBuilder

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

the class Activator method createBuckets.

private static BucketsBuilder createBuckets() {
    List<Action> actionList = new ArrayList<>();
    actionList.add(new ActionBuilder().setOrder(0).setAction(new PopVlanActionCaseBuilder().setPopVlanAction(new PopVlanActionBuilder().build()).build()).build());
    BucketBuilder bucketBuilder = new BucketBuilder();
    bucketBuilder.setBucketId(new BucketId(12L));
    bucketBuilder.setAction(actionList);
    List<Bucket> bucketList = new ArrayList<>();
    bucketList.add(bucketBuilder.build());
    actionList = new ArrayList<>();
    SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
    setFieldCaseBuilder.setSetField(new SetFieldBuilder().setLayer3Match(new Ipv4MatchBuilder().setIpv4Source(new Ipv4Prefix("10.0.1.0/32")).build()).build());
    actionList.add(new ActionBuilder().setAction(setFieldCaseBuilder.build()).setOrder(0).build());
    setFieldCaseBuilder = new SetFieldCaseBuilder();
    setFieldCaseBuilder.setSetField(new SetFieldBuilder().setLayer3Match(new Ipv4MatchBuilder().setIpv4Destination(new Ipv4Prefix("10.0.10.0/32")).build()).build());
    actionList.add(new ActionBuilder().setAction(setFieldCaseBuilder.build()).setOrder(0).build());
    bucketBuilder = new BucketBuilder();
    bucketBuilder.setBucketId(new BucketId(13L));
    bucketBuilder.setAction(actionList);
    bucketList.add(bucketBuilder.build());
    BucketsBuilder bucketsBuilder = new BucketsBuilder();
    bucketsBuilder.setBucket(bucketList);
    return bucketsBuilder;
}
Also used : Ipv4MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder) Action(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action) SetFieldCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetFieldCaseBuilder) PopVlanActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.vlan.action._case.PopVlanActionBuilder) GroupActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupActionBuilder) PopVlanActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.vlan.action._case.PopVlanActionBuilder) ActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder) 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) SetFieldBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.field._case.SetFieldBuilder) 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) PopVlanActionCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopVlanActionCaseBuilder) Ipv4Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix)

Example 2 with BucketBuilder

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

the class GroupConvertorTest method testGroupModConvertorBucketwithNOWieghtValuesForGroupTypeFastFailure.

/**
 * test of {@link GroupConvertor#convert(Group, VersionDatapathIdConvertorData)} }.
 */
@Test
public void testGroupModConvertorBucketwithNOWieghtValuesForGroupTypeFastFailure() {
    int actionOrder = 0;
    final AddGroupInputBuilder addGroupBuilder = new AddGroupInputBuilder();
    addGroupBuilder.setGroupId(new GroupId(10L));
    addGroupBuilder.setGroupType(GroupTypes.GroupFf);
    final List<Bucket> bucketList = new ArrayList<>();
    final List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> actionsList = new ArrayList<>();
    final List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> actionsList1 = new ArrayList<>();
    // Action1: 005
    actionsList.add(assembleActionBuilder("005", actionOrder++).build());
    // Action2: 006
    actionsList.add(assembleActionBuilder("006", actionOrder++).build());
    // .. and mr.Bond is not coming today
    final BucketsBuilder bucketsB = new BucketsBuilder();
    final BucketBuilder bucketB = new BucketBuilder();
    bucketB.setAction(actionsList);
    final Bucket bucket = bucketB.build();
    // List of bucket
    bucketList.add(bucket);
    final BucketBuilder bucketB1 = new BucketBuilder();
    // Action1
    actionsList1.add(assembleCopyTtlInBuilder(actionOrder++).build());
    // Action2:
    actionsList1.add(assembleSetMplsTtlActionBuilder(actionOrder++).build());
    bucketB1.setAction(actionsList1);
    // second bucket
    final Bucket bucket1 = bucketB1.build();
    bucketList.add(bucket1);
    // List of bucket added to the Buckets
    bucketsB.setBucket(bucketList);
    final Buckets buckets = bucketsB.build();
    addGroupBuilder.setBuckets(buckets);
    VersionDatapathIdConvertorData data = new VersionDatapathIdConvertorData((short) 0X4);
    data.setDatapathId(BigInteger.valueOf(1));
    final GroupModInputBuilder outAddGroupInput = convert(addGroupBuilder.build(), data);
    assertEquals(GroupModCommand.OFPGCADD, outAddGroupInput.getCommand());
    assertEquals(GroupType.OFPGTFF, outAddGroupInput.getType());
    assertEquals(10L, outAddGroupInput.getGroupId().getValue().longValue());
    final List<Action> outActionList = outAddGroupInput.getBucketsList().get(0).getAction();
    for (int outItem = 0; outItem < outActionList.size(); outItem++) {
        final Action action = outActionList.get(outItem);
        if (action.getActionChoice() instanceof GroupActionCase) {
            assertEquals((Long) 5L, ((GroupActionCase) action.getActionChoice()).getGroupAction().getGroupId());
        }
    }
    final List<Action> outActionList1 = outAddGroupInput.getBucketsList().get(1).getAction();
    for (int outItem = 0; outItem < outActionList1.size(); outItem++) {
        final Action action = outActionList1.get(outItem);
        if (action.getActionChoice() instanceof GroupActionCase) {
            assertEquals((Long) 6L, ((GroupActionCase) action.getActionChoice()).getGroupAction().getGroupId());
        }
    }
}
Also used : Action(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action) GroupAction(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupAction) SetMplsTtlAction(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.mpls.ttl.action._case.SetMplsTtlAction) VersionDatapathIdConvertorData(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData) ArrayList(java.util.ArrayList) BucketsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.BucketsBuilder) Buckets(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.Buckets) AddGroupInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInputBuilder) GroupId(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId) 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) GroupModInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GroupModInputBuilder) GroupActionCase(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCase) Test(org.junit.Test)

Example 3 with BucketBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.BucketBuilder 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 4 with BucketBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.BucketBuilder 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)

Example 5 with BucketBuilder

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

the class OpenflowPluginBulkGroupTransactionProvider method createTestGroup.

private GroupBuilder createTestGroup(String actionType, String groupType, String groupmod, String strId) {
    // Sample data , committing to DataStore
    GroupBuilder group = new GroupBuilder();
    BucketBuilder bucket = new BucketBuilder();
    bucket.setBucketId(new BucketId((long) 12));
    bucket.setKey(new BucketKey(new BucketId((long) 12)));
    if (groupType == null) {
        groupType = "g1";
    }
    if (actionType == null) {
        actionType = "a1";
    }
    switch(groupType) {
        case "g1":
            group.setGroupType(GroupTypes.GroupSelect);
            break;
        case "g2":
            group.setGroupType(GroupTypes.GroupAll);
            break;
        case "g3":
            group.setGroupType(GroupTypes.GroupIndirect);
            break;
        case "g4":
            group.setGroupType(GroupTypes.GroupFf);
            break;
        default:
            break;
    }
    switch(actionType) {
        case "a1":
            bucket.setAction(createPopVlanAction());
            break;
        case "a2":
            bucket.setAction(createPushVlanAction());
            break;
        case "a3":
            bucket.setAction(createPushMplsAction());
            break;
        case "a4":
            bucket.setAction(createPopMplsAction());
            break;
        case "a5":
            bucket.setAction(createPopPbbAction());
            break;
        case "a6":
        case "a7":
            bucket.setAction(createPushPbbAction());
            break;
        case "a8":
            bucket.setAction(createCopyTtlInAction());
            break;
        case "a9":
            bucket.setAction(createCopyTtlOutAction());
            break;
        case "a10":
            bucket.setAction(createDecMplsTtlAction());
            break;
        case "a14":
            bucket.setAction(createGroupAction());
            break;
        case "a29":
            bucket.setAction(createNonAppyPushVlanAction());
            break;
        default:
            break;
    }
    if ("add".equals(groupmod)) {
        bucket.setWatchGroup((long) 14);
        bucket.setWatchPort((long) 1234);
        bucket.setWeight(50);
    } else {
        bucket.setWatchGroup((long) 13);
        bucket.setWatchPort((long) 134);
        bucket.setWeight(30);
    }
    long id = Long.parseLong(strId);
    GroupKey key = new GroupKey(new GroupId(id));
    group.setKey(key);
    // group.setInstall(false);
    group.setGroupId(new GroupId(id));
    group.setGroupName(originalGroupName);
    group.setBarrier(false);
    BucketsBuilder value = new BucketsBuilder();
    List<Bucket> value1 = new ArrayList<>();
    value1.add(bucket.build());
    value.setBucket(value1);
    group.setBuckets(value.build());
    return group;
}
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) GroupBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupBuilder) BucketKey(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.BucketKey) GroupKey(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupKey) 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) GroupId(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId)

Aggregations

ArrayList (java.util.ArrayList)15 Bucket (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket)15 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 GroupId (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId)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 GroupActionCase (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCase)5 GroupAction (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupAction)5 GroupActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupActionBuilder)5 Buckets (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.Buckets)5 Test (org.junit.Test)4 VersionDatapathIdConvertorData (org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)4 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action)4 AddGroupInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInputBuilder)4 BucketKey (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.BucketKey)4 GroupBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupBuilder)4 GroupModInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GroupModInputBuilder)4 GroupActionCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCaseBuilder)3 OutputActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputActionBuilder)3