use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.BucketKey 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.buckets.BucketKey in project openflowplugin by opendaylight.
the class GroupDescStatsResponseConvertor method toSALBucketsDesc.
private org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.Buckets toSALBucketsDesc(List<BucketsList> bucketDescStats, short version) {
final ActionResponseConvertorData data = new ActionResponseConvertorData(version);
data.setActionPath(ActionPath.GROUP_DESC_STATS_UPDATED_BUCKET_ACTION);
org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.BucketsBuilder salBucketsDesc = new org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.BucketsBuilder();
List<Bucket> allBuckets = new ArrayList<>();
int bucketKey = 0;
for (BucketsList bucketDetails : bucketDescStats) {
BucketBuilder bucketDesc = new BucketBuilder();
final Optional<List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action>> convertedSalActions = getConvertorExecutor().convert(bucketDetails.getAction(), data);
if (convertedSalActions.isPresent()) {
List<Action> actions = new ArrayList<>();
int actionKey = 0;
for (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action : convertedSalActions.get()) {
ActionBuilder wrappedAction = new ActionBuilder();
wrappedAction.setAction(action);
wrappedAction.setKey(new ActionKey(actionKey));
wrappedAction.setOrder(actionKey);
actions.add(wrappedAction.build());
actionKey++;
}
bucketDesc.setAction(actions);
} else {
bucketDesc.setAction(Collections.emptyList());
}
bucketDesc.setWeight(bucketDetails.getWeight());
bucketDesc.setWatchPort(bucketDetails.getWatchPort().getValue());
bucketDesc.setWatchGroup(bucketDetails.getWatchGroup());
BucketId bucketId = new BucketId((long) bucketKey);
bucketDesc.setBucketId(bucketId);
bucketDesc.setKey(new BucketKey(bucketId));
bucketKey++;
allBuckets.add(bucketDesc.build());
}
salBucketsDesc.setBucket(allBuckets);
return salBucketsDesc.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.BucketKey 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.buckets.BucketKey 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;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.BucketKey in project openflowplugin by opendaylight.
the class GroupStatsResponseConvertor method toSALBuckets.
private Buckets toSALBuckets(List<BucketStats> bucketStats) {
BucketsBuilder salBuckets = new BucketsBuilder();
List<BucketCounter> allBucketStats = new ArrayList<>();
int bucketKey = 0;
for (BucketStats bucketStat : bucketStats) {
BucketCounterBuilder bucketCounter = new BucketCounterBuilder();
bucketCounter.setByteCount(new Counter64(bucketStat.getByteCount()));
bucketCounter.setPacketCount(new Counter64(bucketStat.getPacketCount()));
BucketId bucketId = new BucketId((long) bucketKey);
bucketCounter.setKey(new BucketCounterKey(bucketId));
bucketCounter.setBucketId(bucketId);
bucketKey++;
allBucketStats.add(bucketCounter.build());
}
salBuckets.setBucketCounter(allBucketStats);
return salBuckets.build();
}
Aggregations