use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.BucketBuilder in project openflowplugin by opendaylight.
the class GroupConvertorTest method testGroupModConvertorBucketwithNOWieghtValuesForGroupTypeAll.
/**
* test of {@link GroupConvertor#convert(Group, VersionDatapathIdConvertorData)} }.
*/
@Test
public void testGroupModConvertorBucketwithNOWieghtValuesForGroupTypeAll() {
int actionOrder = 0;
final AddGroupInputBuilder addGroupBuilder = new AddGroupInputBuilder();
addGroupBuilder.setGroupId(new GroupId(10L));
addGroupBuilder.setGroupType(GroupTypes.GroupAll);
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
actionsList.add(assembleActionBuilder("005", actionOrder++).build());
// Action2:
actionsList.add(assembleActionBuilder("006", actionOrder++).build());
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(actionsList);
// 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.OFPGTALL, 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());
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.BucketBuilder in project openflowplugin by opendaylight.
the class GroupConvertorTest method testGroupModConvertSortedBuckets.
/**
* test of {@link GroupConvertor#convert(Group, VersionDatapathIdConvertorData)} }.
*/
@Test
public void testGroupModConvertSortedBuckets() {
final int actionOrder = 0;
final ArrayList<Bucket> bucket = new ArrayList<>();
bucket.add(new BucketBuilder().setBucketId(new BucketId((long) 4)).setWatchPort((long) 2).setWatchGroup((long) 1).setAction(ImmutableList.of(new ActionBuilder().setOrder(0).setAction(new OutputActionCaseBuilder().setOutputAction(new OutputActionBuilder().setOutputNodeConnector(new Uri("openflow:1:2")).build()).build()).build())).build());
bucket.add(new BucketBuilder().setBucketId(new BucketId((long) 3)).setWatchPort((long) 6).setWatchGroup((long) 1).setAction(ImmutableList.of(new ActionBuilder().setOrder(0).setAction(new OutputActionCaseBuilder().setOutputAction(new OutputActionBuilder().setOutputNodeConnector(new Uri("openflow:1:6")).build()).build()).build())).build());
bucket.add(new BucketBuilder().setBucketId(new BucketId((long) 2)).setWatchPort((long) 5).setWatchGroup((long) 1).setAction(ImmutableList.of(new ActionBuilder().setOrder(0).setAction(new OutputActionCaseBuilder().setOutputAction(new OutputActionBuilder().setOutputNodeConnector(new Uri("openflow:1:5")).build()).build()).build())).build());
bucket.add(new BucketBuilder().setBucketId(new BucketId((long) 1)).setWatchPort((long) 4).setWatchGroup((long) 1).setAction(ImmutableList.of(new ActionBuilder().setOrder(0).setAction(new OutputActionCaseBuilder().setOutputAction(new OutputActionBuilder().setOutputNodeConnector(new Uri("openflow:1:4")).build()).build()).build())).build());
bucket.add(new BucketBuilder().setBucketId(new BucketId((long) 0)).setWatchPort((long) 3).setWatchGroup((long) 1).setAction(ImmutableList.of(new ActionBuilder().setOrder(0).setAction(new OutputActionCaseBuilder().setOutputAction(new OutputActionBuilder().setOutputNodeConnector(new Uri("openflow:1:3")).build()).build()).build())).build());
final AddGroupInput input = new AddGroupInputBuilder().setGroupId(new GroupId((long) 1)).setGroupName("Foo").setGroupType(GroupTypes.GroupFf).setBuckets(new BucketsBuilder().setBucket(bucket).build()).build();
VersionDatapathIdConvertorData data = new VersionDatapathIdConvertorData((short) 0X4);
data.setDatapathId(BigInteger.valueOf(1));
final GroupModInputBuilder outAddGroupInput = convert(input, data);
final List<BucketsList> bucketList = outAddGroupInput.getBucketsList();
assertEquals(Long.valueOf(1), bucketList.get(0).getWatchGroup());
assertEquals(Long.valueOf(3), bucketList.get(0).getWatchPort().getValue());
assertEquals(Long.valueOf(1), bucketList.get(1).getWatchGroup());
assertEquals(Long.valueOf(4), bucketList.get(1).getWatchPort().getValue());
assertEquals(Long.valueOf(1), bucketList.get(2).getWatchGroup());
assertEquals(Long.valueOf(5), bucketList.get(2).getWatchPort().getValue());
assertEquals(Long.valueOf(1), bucketList.get(3).getWatchGroup());
assertEquals(Long.valueOf(6), bucketList.get(3).getWatchPort().getValue());
assertEquals(Long.valueOf(1), bucketList.get(4).getWatchGroup());
assertEquals(Long.valueOf(2), bucketList.get(4).getWatchPort().getValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.BucketBuilder 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.BucketBuilder 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.BucketBuilder 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