Search in sources :

Example 6 with BucketsListBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.grouping.BucketsListBuilder in project openflowplugin by opendaylight.

the class OpendaylightGroupStatisticsServiceImplTest method testGetGroupDescription.

@Test
public void testGetGroupDescription() throws Exception {
    GetGroupDescriptionInputBuilder input = new GetGroupDescriptionInputBuilder().setNode(createNodeRef("unitProt:123"));
    rpcResult = RpcResultBuilder.<Object>success(Collections.singletonList(new MultipartReplyMessageBuilder().setVersion(OFConstants.OFP_VERSION_1_3).setMultipartReplyBody(new MultipartReplyGroupDescCaseBuilder().setMultipartReplyGroupDesc(new MultipartReplyGroupDescBuilder().setGroupDesc(Collections.singletonList(new GroupDescBuilder().setGroupId(GROUP_ID).setBucketsList(Collections.singletonList(new BucketsListBuilder().setWatchGroup(51L).setWatchPort(new PortNumber(52L)).setWeight(53).build())).setType(GroupType.OFPGTALL).build())).build()).build()).build())).build();
    final Future<RpcResult<GetGroupDescriptionOutput>> resultFuture = groupStatisticsService.getGroupDescription(input.build());
    Assert.assertTrue(resultFuture.isDone());
    final RpcResult<GetGroupDescriptionOutput> rpcResult = resultFuture.get();
    Assert.assertTrue(rpcResult.isSuccessful());
    Assert.assertEquals(MultipartType.OFPMPGROUPDESC, requestInput.getValue().getType());
}
Also used : BucketsListBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.grouping.BucketsListBuilder) GetGroupDescriptionOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupDescriptionOutput) MultipartReplyMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder) GetGroupDescriptionInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupDescriptionInputBuilder) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) PortNumber(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber) MultipartReplyGroupDescBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.desc._case.MultipartReplyGroupDescBuilder) GroupDescBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.desc._case.multipart.reply.group.desc.GroupDescBuilder) MultipartReplyGroupDescCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupDescCaseBuilder) MultipartReplyGroupDescBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.desc._case.MultipartReplyGroupDescBuilder) Test(org.junit.Test)

Example 7 with BucketsListBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.grouping.BucketsListBuilder in project openflowplugin by opendaylight.

the class StatisticsGatheringUtilsTest method testGatherStatistics_groupDesc.

@Test
public void testGatherStatistics_groupDesc() throws Exception {
    final MultipartType type = MultipartType.OFPMPGROUPDESC;
    final long groupIdValue = 27L;
    final BucketsListBuilder bucketsListBld = new BucketsListBuilder().setWatchPort(new PortNumber(5L));
    final GroupDescBuilder groupStatsBld = new GroupDescBuilder().setBucketsList(Lists.newArrayList(bucketsListBld.build())).setGroupId(new GroupId(groupIdValue)).setType(GroupType.OFPGTALL);
    final MultipartReplyGroupDescBuilder mpReplyGroupBld = new MultipartReplyGroupDescBuilder();
    mpReplyGroupBld.setGroupDesc(Lists.newArrayList(groupStatsBld.build()));
    final MultipartReplyGroupDescCaseBuilder mpReplyGroupCaseBld = new MultipartReplyGroupDescCaseBuilder();
    mpReplyGroupCaseBld.setMultipartReplyGroupDesc(mpReplyGroupBld.build());
    final MultipartReply groupStatsUpdated = assembleMPReplyMessage(type, mpReplyGroupCaseBld.build());
    final List<MultipartReply> statsData = Collections.singletonList(groupStatsUpdated);
    fireAndCheck(type, statsData);
    final org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId storedGroupId = new org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId(groupIdValue);
    final KeyedInstanceIdentifier<Group, GroupKey> groupPath = dummyNodePath.augmentation(FlowCapableNode.class).child(Group.class, new GroupKey(storedGroupId));
    verify(deviceContext, Mockito.never()).addDeleteToTxChain(Matchers.eq(LogicalDatastoreType.OPERATIONAL), Matchers.<InstanceIdentifier<?>>any());
    verify(deviceGroupRegistry).store(storedGroupId);
    verify(deviceContext).writeToTransaction(Matchers.eq(LogicalDatastoreType.OPERATIONAL), Matchers.eq(groupPath), Matchers.any(Group.class));
}
Also used : Group(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group) BucketsListBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.grouping.BucketsListBuilder) MultipartType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType) MultipartReply(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) GroupKey(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupKey) MultipartReplyGroupDescCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupDescCaseBuilder) GroupId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId) PortNumber(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber) MultipartReplyGroupDescBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.desc._case.MultipartReplyGroupDescBuilder) GroupDescBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.desc._case.multipart.reply.group.desc.GroupDescBuilder) MultipartReplyGroupDescBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.desc._case.MultipartReplyGroupDescBuilder) Test(org.junit.Test)

Example 8 with BucketsListBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.grouping.BucketsListBuilder in project openflowplugin by opendaylight.

the class GroupModInputMessageFactory method deserialize.

@Override
public GroupModInput deserialize(ByteBuf rawMessage) {
    GroupModInputBuilder builder = new GroupModInputBuilder();
    builder.setVersion((short) EncodeConstants.OF13_VERSION_ID);
    builder.setXid(rawMessage.readUnsignedInt());
    builder.setCommand(GroupModCommand.forValue(rawMessage.readUnsignedShort()));
    builder.setType(GroupType.forValue(rawMessage.readUnsignedByte()));
    rawMessage.skipBytes(PADDING);
    builder.setGroupId(new GroupId(rawMessage.readUnsignedInt()));
    List<BucketsList> bucketsList = new ArrayList<>();
    while (rawMessage.readableBytes() > 0) {
        BucketsListBuilder bucketsBuilder = new BucketsListBuilder();
        final int bucketsLength = rawMessage.readUnsignedShort();
        bucketsBuilder.setWeight(rawMessage.readUnsignedShort());
        bucketsBuilder.setWatchPort(new PortNumber(rawMessage.readUnsignedInt()));
        bucketsBuilder.setWatchGroup(rawMessage.readUnsignedInt());
        rawMessage.skipBytes(PADDING_IN_BUCKETS_HEADER);
        CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF13_VERSION_ID);
        List<Action> actions = ListDeserializer.deserializeList(EncodeConstants.OF13_VERSION_ID, bucketsLength - BUCKETS_HEADER_LENGTH, rawMessage, keyMaker, registry);
        bucketsBuilder.setAction(actions);
        bucketsList.add(bucketsBuilder.build());
    }
    builder.setBucketsList(bucketsList);
    return builder.build();
}
Also used : Action(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action) BucketsListBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.grouping.BucketsListBuilder) ArrayList(java.util.ArrayList) CodeKeyMaker(org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMaker) GroupModInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GroupModInputBuilder) BucketsList(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.grouping.BucketsList) PortNumber(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber) GroupId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId)

Example 9 with BucketsListBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.grouping.BucketsListBuilder in project openflowplugin by opendaylight.

the class GroupConvertor method salToOFBucketList.

private List<BucketsList> salToOFBucketList(Buckets buckets, short version, int groupType, BigInteger datapathid) {
    final List<BucketsList> bucketLists = new ArrayList<>();
    final ActionConvertorData data = new ActionConvertorData(version);
    data.setDatapathId(datapathid);
    for (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket groupBucket : buckets.getBucket()) {
        BucketsListBuilder bucketBuilder = new BucketsListBuilder();
        salToOFBucketListWeight(groupBucket, bucketBuilder, groupType);
        salToOFBucketListWatchGroup(groupBucket, bucketBuilder, groupType);
        salToOFBucketListWatchPort(groupBucket, bucketBuilder, groupType);
        Optional<List<Action>> bucketActionList = getConvertorExecutor().convert(groupBucket.getAction(), data);
        bucketBuilder.setAction(bucketActionList.orElse(Collections.emptyList()));
        BucketsList bucket = bucketBuilder.build();
        bucketLists.add(bucket);
    }
    return bucketLists;
}
Also used : BucketsListBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.grouping.BucketsListBuilder) ArrayList(java.util.ArrayList) ActionConvertorData(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData) ArrayList(java.util.ArrayList) BucketsList(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.grouping.BucketsList) List(java.util.List) Bucket(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket) BucketsList(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.grouping.BucketsList)

Aggregations

BucketsListBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.grouping.BucketsListBuilder)9 PortNumber (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber)8 ArrayList (java.util.ArrayList)7 BucketsList (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.grouping.BucketsList)7 GroupId (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId)4 GroupDescBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.desc._case.multipart.reply.group.desc.GroupDescBuilder)4 Test (org.junit.Test)3 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action)3 MultipartReplyGroupDescCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupDescCaseBuilder)3 MultipartReplyGroupDescBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.desc._case.MultipartReplyGroupDescBuilder)3 CodeKeyMaker (org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMaker)2 Bucket (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket)2 GroupDesc (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.desc._case.multipart.reply.group.desc.GroupDesc)2 List (java.util.List)1 ActionConvertorData (org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData)1 VersionConvertorData (org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData)1 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)1 GetGroupDescriptionInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupDescriptionInputBuilder)1 GetGroupDescriptionOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupDescriptionOutput)1 GroupDescStats (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.desc.stats.reply.GroupDescStats)1