use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.grouping.BucketsList in project openflowplugin by opendaylight.
the class MultipartReplyTranslatorTest method prepareMultipartReplyGroupDesc.
private MultipartReplyBody prepareMultipartReplyGroupDesc() {
GroupDescBuilder groupDescBuilder = new GroupDescBuilder();
groupDescBuilder.setGroupId(DUMMY_GROUP_ID);
groupDescBuilder.setBucketsList(Collections.<BucketsList>emptyList());
groupDescBuilder.setType(DUMMY_GROUP_TYPE);
MultipartReplyGroupDescBuilder multipartReplyGroupDescBuilder = new MultipartReplyGroupDescBuilder();
multipartReplyGroupDescBuilder.setGroupDesc(Lists.newArrayList(groupDescBuilder.build()));
MultipartReplyGroupDescCaseBuilder multipartReplyGroupDescCaseBuilder = new MultipartReplyGroupDescCaseBuilder();
multipartReplyGroupDescCaseBuilder.setMultipartReplyGroupDesc(multipartReplyGroupDescBuilder.build());
return multipartReplyGroupDescCaseBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.grouping.BucketsList 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.BucketsList in project openflowplugin by opendaylight.
the class GroupModInputMessageFactory method serializerBuckets.
private void serializerBuckets(List<BucketsList> buckets, ByteBuf outBuffer) {
if (buckets != null) {
for (BucketsList currentBucket : buckets) {
final int bucketLengthIndex = outBuffer.writerIndex();
outBuffer.writeShort(EncodeConstants.EMPTY_LENGTH);
outBuffer.writeShort(currentBucket.getWeight().shortValue());
outBuffer.writeInt(currentBucket.getWatchPort().getValue().intValue());
outBuffer.writeInt(currentBucket.getWatchGroup().intValue());
outBuffer.writeZero(PADDING_IN_BUCKET);
ListSerializer.serializeList(currentBucket.getAction(), TypeKeyMakerFactory.createActionKeyMaker(EncodeConstants.OF13_VERSION_ID), registry, outBuffer);
outBuffer.setShort(bucketLengthIndex, outBuffer.writerIndex() - bucketLengthIndex);
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.grouping.BucketsList in project openflowplugin by opendaylight.
the class MultipartReplyMessageFactory method serializeGroupDescBody.
private void serializeGroupDescBody(final MultipartReplyBody body, final ByteBuf outBuffer, final MultipartReplyMessage message) {
MultipartReplyGroupDescCase groupDescCase = (MultipartReplyGroupDescCase) body;
MultipartReplyGroupDesc group = groupDescCase.getMultipartReplyGroupDesc();
for (GroupDesc groupDesc : group.getGroupDesc()) {
ByteBuf groupDescBuff = UnpooledByteBufAllocator.DEFAULT.buffer();
groupDescBuff.writeShort(EncodeConstants.EMPTY_LENGTH);
groupDescBuff.writeByte(groupDesc.getType().getIntValue());
groupDescBuff.writeZero(GROUP_DESC_PADDING);
groupDescBuff.writeInt(groupDesc.getGroupId().getValue().intValue());
for (BucketsList bucket : groupDesc.getBucketsList()) {
ByteBuf bucketBuff = UnpooledByteBufAllocator.DEFAULT.buffer();
bucketBuff.writeShort(EncodeConstants.EMPTY_LENGTH);
bucketBuff.writeShort(bucket.getWeight());
bucketBuff.writeInt(bucket.getWatchPort().getValue().intValue());
bucketBuff.writeInt(bucket.getWatchGroup().intValue());
bucketBuff.writeZero(BUCKET_PADDING);
ListSerializer.serializeList(bucket.getAction(), TypeKeyMakerFactory.createActionKeyMaker(message.getVersion()), registry, bucketBuff);
bucketBuff.setShort(BUCKET_LENGTH_INDEX, bucketBuff.readableBytes());
groupDescBuff.writeBytes(bucketBuff);
}
groupDescBuff.setShort(GROUP_DESC_LENGTH_INDEX, groupDescBuff.readableBytes());
outBuffer.writeBytes(groupDescBuff);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.grouping.BucketsList 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