use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.Buckets in project openflowplugin by opendaylight.
the class ReconcileUtilTest method createGroupWithPreconditions.
private Group createGroupWithPreconditions(final long groupIdValue, final long... requiredId) {
final List<Action> actionBag = new ArrayList<>();
for (long groupIdPrecondition : requiredId) {
final GroupAction groupAction = new GroupActionBuilder().setGroupId(groupIdPrecondition).build();
final GroupActionCase groupActionCase = new GroupActionCaseBuilder().setGroupAction(groupAction).build();
final Action action = new ActionBuilder().setAction(groupActionCase).build();
actionBag.add(action);
}
final Bucket bucket = new BucketBuilder().setAction(actionBag).build();
final Buckets buckets = new BucketsBuilder().setBucket(Collections.singletonList(bucket)).build();
return new GroupBuilder().setGroupId(new GroupId(groupIdValue)).setBuckets(buckets).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.Buckets in project openflowplugin by opendaylight.
the class DSInputFactory method createGroupWithPreconditions.
public static Group createGroupWithPreconditions(final long groupIdValue, final long... requiredId) {
final List<Action> actionBag = new ArrayList<>();
for (long groupIdPrecondition : requiredId) {
final GroupAction groupAction = new GroupActionBuilder().setGroupId(groupIdPrecondition).build();
final GroupActionCase groupActionCase = new GroupActionCaseBuilder().setGroupAction(groupAction).build();
final Action action = new ActionBuilder().setAction(groupActionCase).build();
actionBag.add(action);
}
final Bucket bucket = new BucketBuilder().setAction(actionBag).build();
final Buckets buckets = new BucketsBuilder().setBucket(Collections.singletonList(bucket)).build();
return new GroupBuilder().setGroupId(new GroupId(groupIdValue)).setBuckets(buckets).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.Buckets in project openflowplugin by opendaylight.
the class GroupMessageDeserializerTest method deserialize.
@Test
public void deserialize() throws Exception {
// Group header
buffer.writeByte(TYPE);
buffer.writeShort(EncodeConstants.EMPTY_LENGTH);
buffer.writeInt(XID);
buffer.writeShort(COMMAND.getIntValue());
buffer.writeByte(GROUP_TYPE.getIntValue());
buffer.writeZero(PADDING);
buffer.writeInt(GROUP_ID);
// Buckets header
int index = buffer.writerIndex();
buffer.writeShort(EncodeConstants.EMPTY_LENGTH);
buffer.writeShort(WEIGHT);
buffer.writeInt(WATCH_PORT);
buffer.writeInt(WATCH_GROUP);
buffer.writeZero(PADDING_IN_BUCKETS_HEADER);
// POP PBB action
buffer.writeShort(ActionConstants.POP_PBB_CODE);
buffer.writeShort(ActionConstants.GENERAL_ACTION_LENGTH);
buffer.writeZero(ActionConstants.PADDING_IN_ACTION_HEADER);
// Count total length of buckets
buffer.setShort(index, buffer.writerIndex() - index);
// Deserialize and check everything
final GroupMessage message = (GroupMessage) getFactory().deserialize(buffer, EncodeConstants.OF13_VERSION_ID);
assertEquals(XID, message.getXid().intValue());
assertEquals(COMMAND.getIntValue(), message.getCommand().getIntValue());
assertEquals(GROUP_TYPE.getIntValue(), message.getGroupType().getIntValue());
assertEquals(1, message.getBuckets().getBucket().size());
final Bucket bucket = message.getBuckets().getBucket().get(0);
assertEquals(WEIGHT, bucket.getWeight().shortValue());
assertEquals(WATCH_PORT, bucket.getWatchPort().intValue());
assertEquals(WATCH_GROUP, bucket.getWatchGroup().intValue());
assertEquals(1, bucket.getAction().size());
assertEquals(PopPbbActionCase.class, bucket.getAction().get(0).getAction().getImplementedInterface());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.Buckets 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.group.types.rev131018.group.Buckets 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