Search in sources :

Example 16 with BucketsList

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.grouping.BucketsList in project openflowplugin by opendaylight.

the class GroupConvertor method convert.

@Override
public GroupModInputBuilder convert(Group source, VersionDatapathIdConvertorData data) {
    GroupModInputBuilder groupModInputBuilder = new GroupModInputBuilder();
    if (source instanceof AddGroupInput) {
        groupModInputBuilder.setCommand(GroupModCommand.OFPGCADD);
    } else if (source instanceof RemoveGroupInput) {
        groupModInputBuilder.setCommand(GroupModCommand.OFPGCDELETE);
    } else if (source instanceof UpdatedGroup) {
        groupModInputBuilder.setCommand(GroupModCommand.OFPGCMODIFY);
    }
    if (GroupTypes.GroupAll.equals(source.getGroupType())) {
        groupModInputBuilder.setType(GroupType.OFPGTALL);
    }
    if (GroupTypes.GroupSelect.equals(source.getGroupType())) {
        groupModInputBuilder.setType(GroupType.OFPGTSELECT);
    }
    if (GroupTypes.GroupIndirect.equals(source.getGroupType())) {
        groupModInputBuilder.setType(GroupType.OFPGTINDIRECT);
    }
    if (GroupTypes.GroupFf.equals(source.getGroupType())) {
        groupModInputBuilder.setType(GroupType.OFPGTFF);
    }
    groupModInputBuilder.setGroupId(new GroupId(source.getGroupId().getValue()));
    // During group deletion do not push the buckets
    if (groupModInputBuilder.getCommand() != GroupModCommand.OFPGCDELETE) {
        if (source.getBuckets() != null && source.getBuckets().getBucket().size() != 0) {
            Collections.sort(source.getBuckets().getBucket(), COMPARATOR);
            List<BucketsList> bucketLists = salToOFBucketList(source.getBuckets(), data.getVersion(), source.getGroupType().getIntValue(), data.getDatapathId());
            groupModInputBuilder.setBucketsList(bucketLists);
        }
    }
    groupModInputBuilder.setVersion(data.getVersion());
    return groupModInputBuilder;
}
Also used : RemoveGroupInput(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupInput) AddGroupInput(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInput) GroupModInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GroupModInputBuilder) UpdatedGroup(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.group.update.UpdatedGroup) BucketsList(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.grouping.BucketsList) GroupId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId)

Aggregations

BucketsList (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.grouping.BucketsList)15 ArrayList (java.util.ArrayList)9 PortNumber (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber)7 BucketsListBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.grouping.BucketsListBuilder)7 GroupId (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId)6 Test (org.junit.Test)5 ByteBuf (io.netty.buffer.ByteBuf)4 Bucket (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket)4 GroupModInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GroupModInputBuilder)4 GroupDesc (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.desc._case.multipart.reply.group.desc.GroupDesc)4 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action)3 MultipartReplyGroupDescCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupDescCaseBuilder)3 MultipartReplyGroupDescBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.desc._case.MultipartReplyGroupDescBuilder)3 GroupDescBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.desc._case.multipart.reply.group.desc.GroupDescBuilder)3 List (java.util.List)2 CodeKeyMaker (org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMaker)2 ActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder)2 AddGroupInput (org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInput)2 BucketId (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.BucketId)2 BucketBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.BucketBuilder)2