use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.BucketsBuilder in project openflowplugin by opendaylight.
the class Activator method createBuckets.
private static BucketsBuilder createBuckets() {
List<Action> actionList = new ArrayList<>();
actionList.add(new ActionBuilder().setOrder(0).setAction(new PopVlanActionCaseBuilder().setPopVlanAction(new PopVlanActionBuilder().build()).build()).build());
BucketBuilder bucketBuilder = new BucketBuilder();
bucketBuilder.setBucketId(new BucketId(12L));
bucketBuilder.setAction(actionList);
List<Bucket> bucketList = new ArrayList<>();
bucketList.add(bucketBuilder.build());
actionList = new ArrayList<>();
SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
setFieldCaseBuilder.setSetField(new SetFieldBuilder().setLayer3Match(new Ipv4MatchBuilder().setIpv4Source(new Ipv4Prefix("10.0.1.0/32")).build()).build());
actionList.add(new ActionBuilder().setAction(setFieldCaseBuilder.build()).setOrder(0).build());
setFieldCaseBuilder = new SetFieldCaseBuilder();
setFieldCaseBuilder.setSetField(new SetFieldBuilder().setLayer3Match(new Ipv4MatchBuilder().setIpv4Destination(new Ipv4Prefix("10.0.10.0/32")).build()).build());
actionList.add(new ActionBuilder().setAction(setFieldCaseBuilder.build()).setOrder(0).build());
bucketBuilder = new BucketBuilder();
bucketBuilder.setBucketId(new BucketId(13L));
bucketBuilder.setAction(actionList);
bucketList.add(bucketBuilder.build());
BucketsBuilder bucketsBuilder = new BucketsBuilder();
bucketsBuilder.setBucket(bucketList);
return bucketsBuilder;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.BucketsBuilder in project openflowplugin by opendaylight.
the class GroupConvertorTest method testGroupModConvertorBucketwithNOWieghtValuesForGroupTypeFastFailure.
/**
* test of {@link GroupConvertor#convert(Group, VersionDatapathIdConvertorData)} }.
*/
@Test
public void testGroupModConvertorBucketwithNOWieghtValuesForGroupTypeFastFailure() {
int actionOrder = 0;
final AddGroupInputBuilder addGroupBuilder = new AddGroupInputBuilder();
addGroupBuilder.setGroupId(new GroupId(10L));
addGroupBuilder.setGroupType(GroupTypes.GroupFf);
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: 005
actionsList.add(assembleActionBuilder("005", actionOrder++).build());
// Action2: 006
actionsList.add(assembleActionBuilder("006", actionOrder++).build());
// .. and mr.Bond is not coming today
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(actionsList1);
// 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.OFPGTFF, 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.BucketsBuilder in project openflowplugin by opendaylight.
the class MultipartReplyGroupDescDeserializer method deserialize.
@Override
public MultipartReplyBody deserialize(ByteBuf message) {
final MultipartReplyGroupDescBuilder builder = new MultipartReplyGroupDescBuilder();
final List<GroupDescStats> items = new ArrayList<>();
while (message.readableBytes() > 0) {
final int itemLength = message.readUnsignedShort();
final GroupDescStatsBuilder itemBuilder = new GroupDescStatsBuilder().setGroupType(GroupTypes.forValue(message.readUnsignedByte()));
message.skipBytes(PADDING_IN_GROUP_DESC_HEADER);
itemBuilder.setGroupId(new GroupId(message.readUnsignedInt()));
itemBuilder.setKey(new GroupDescStatsKey(itemBuilder.getGroupId()));
final List<Bucket> subItems = new ArrayList<>();
int actualLength = GROUP_DESC_HEADER_LENGTH;
long bucketKey = 0;
while (actualLength < itemLength) {
final int bucketsLength = message.readUnsignedShort();
final BucketBuilder bucketBuilder = new BucketBuilder().setBucketId(new BucketId(bucketKey)).setKey(new BucketKey(new BucketId(bucketKey))).setWeight(message.readUnsignedShort()).setWatchPort(message.readUnsignedInt()).setWatchGroup(message.readUnsignedInt());
message.skipBytes(PADDING_IN_BUCKETS_HEADER);
final List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> actions = new ArrayList<>();
final int startIndex = message.readerIndex();
final int bucketLength = bucketsLength - BUCKETS_HEADER_LENGTH;
int offset = 0;
while (message.readerIndex() - startIndex < bucketLength) {
actions.add(new ActionBuilder().setKey(new ActionKey(offset)).setOrder(offset).setAction(ActionUtil.readAction(EncodeConstants.OF13_VERSION_ID, message, registry, ActionPath.GROUP_DESC_STATS_UPDATED_BUCKET_ACTION)).build());
offset++;
}
bucketBuilder.setAction(actions);
subItems.add(bucketBuilder.build());
bucketKey++;
actualLength += bucketsLength;
}
items.add(itemBuilder.setBuckets(new BucketsBuilder().setBucket(subItems).build()).build());
}
return builder.setGroupDescStats(items).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.BucketsBuilder in project openflowplugin by opendaylight.
the class OpenflowPluginBulkGroupTransactionProvider method createTestGroup.
private GroupBuilder createTestGroup(String actionType, String groupType, String groupmod, String strId) {
// Sample data , committing to DataStore
GroupBuilder group = new GroupBuilder();
BucketBuilder bucket = new BucketBuilder();
bucket.setBucketId(new BucketId((long) 12));
bucket.setKey(new BucketKey(new BucketId((long) 12)));
if (groupType == null) {
groupType = "g1";
}
if (actionType == null) {
actionType = "a1";
}
switch(groupType) {
case "g1":
group.setGroupType(GroupTypes.GroupSelect);
break;
case "g2":
group.setGroupType(GroupTypes.GroupAll);
break;
case "g3":
group.setGroupType(GroupTypes.GroupIndirect);
break;
case "g4":
group.setGroupType(GroupTypes.GroupFf);
break;
default:
break;
}
switch(actionType) {
case "a1":
bucket.setAction(createPopVlanAction());
break;
case "a2":
bucket.setAction(createPushVlanAction());
break;
case "a3":
bucket.setAction(createPushMplsAction());
break;
case "a4":
bucket.setAction(createPopMplsAction());
break;
case "a5":
bucket.setAction(createPopPbbAction());
break;
case "a6":
case "a7":
bucket.setAction(createPushPbbAction());
break;
case "a8":
bucket.setAction(createCopyTtlInAction());
break;
case "a9":
bucket.setAction(createCopyTtlOutAction());
break;
case "a10":
bucket.setAction(createDecMplsTtlAction());
break;
case "a14":
bucket.setAction(createGroupAction());
break;
case "a29":
bucket.setAction(createNonAppyPushVlanAction());
break;
default:
break;
}
if ("add".equals(groupmod)) {
bucket.setWatchGroup((long) 14);
bucket.setWatchPort((long) 1234);
bucket.setWeight(50);
} else {
bucket.setWatchGroup((long) 13);
bucket.setWatchPort((long) 134);
bucket.setWeight(30);
}
long id = Long.parseLong(strId);
GroupKey key = new GroupKey(new GroupId(id));
group.setKey(key);
// group.setInstall(false);
group.setGroupId(new GroupId(id));
group.setGroupName(originalGroupName);
group.setBarrier(false);
BucketsBuilder value = new BucketsBuilder();
List<Bucket> value1 = new ArrayList<>();
value1.add(bucket.build());
value.setBucket(value1);
group.setBuckets(value.build());
return group;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.BucketsBuilder in project openflowplugin by opendaylight.
the class OpenflowpluginGroupTestCommandProvider method createTestGroup.
private GroupBuilder createTestGroup(String actionType, String groupType, String groupMod) {
// Sample data , committing to DataStore
GroupBuilder group = new GroupBuilder();
BucketBuilder bucket = new BucketBuilder();
bucket.setBucketId(new BucketId((long) 12));
bucket.setKey(new BucketKey(new BucketId((long) 12)));
if (groupType == null) {
groupType = "g1";
}
if (actionType == null) {
actionType = "a1";
}
switch(groupType) {
case "g1":
group.setGroupType(GroupTypes.GroupSelect);
break;
case "g2":
group.setGroupType(GroupTypes.GroupAll);
break;
case "g3":
group.setGroupType(GroupTypes.GroupIndirect);
break;
case "g4":
group.setGroupType(GroupTypes.GroupFf);
break;
default:
break;
}
switch(actionType) {
case "a1":
bucket.setAction(createPopVlanAction());
break;
case "a2":
bucket.setAction(createPushVlanAction());
break;
case "a3":
bucket.setAction(createPushMplsAction());
break;
case "a4":
bucket.setAction(createPopMplsAction());
break;
case "a5":
bucket.setAction(createPopPbbAction());
break;
case "a6":
case "a7":
bucket.setAction(createPushPbbAction());
break;
case "a8":
bucket.setAction(createCopyTtlInAction());
break;
case "a9":
bucket.setAction(createCopyTtlOutAction());
break;
case "a10":
bucket.setAction(createDecMplsTtlAction());
break;
case "a11":
bucket.setAction(createDecNwTtlAction());
break;
case "a12":
bucket.setAction(createSetQueueAction());
break;
case "a13":
bucket.setAction(createSetNwTtlAction());
break;
case "a14":
bucket.setAction(createGroupAction());
break;
case "a15":
bucket.setAction(createSetMplsTtlAction());
break;
case "a16":
bucket.setAction(createFloodOutputAction());
break;
case "a17":
bucket.setAction(createAllOutputAction());
break;
case "a18":
bucket.setAction(createNormalOutputAction());
break;
case "a19":
bucket.setAction(creatTableOutputAction());
break;
case "a20":
bucket.setAction(createControllerAction());
break;
case "a21":
bucket.setAction(createLocalOutputAction());
break;
case "a22":
bucket.setAction(createAnyOutputAction());
break;
case "a23":
bucket.setAction(createInportOutputAction());
break;
case "a24":
bucket.setAction(null);
break;
case "a25":
bucket.setAction(createNonAppyOutputAction());
break;
case "a26":
bucket.setAction(createNonAppyPushMplsAction());
break;
case "a27":
bucket.setAction(createNonAppyPushPbbAction());
break;
case "a28":
bucket.setAction(createNonAppyPushVlanAction());
break;
default:
break;
}
if ("add".equals(groupMod)) {
bucket.setWatchGroup((long) 14);
bucket.setWatchPort((long) 1234);
bucket.setWeight(50);
} else {
bucket.setWatchGroup((long) 13);
bucket.setWatchPort((long) 134);
bucket.setWeight(30);
}
long id = 1;
GroupKey key = new GroupKey(new GroupId(id));
group.setKey(key);
// group.setInstall(false);
group.setGroupId(new GroupId(id));
group.setGroupName(ORIGINAL_GROUP_NAME);
group.setBarrier(false);
BucketsBuilder value = new BucketsBuilder();
List<Bucket> value1 = new ArrayList<>();
value1.add(bucket.build());
value.setBucket(value1);
group.setBuckets(value.build());
testGroup = group.build();
return group;
}
Aggregations