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());
}
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));
}
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();
}
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;
}
Aggregations