Search in sources :

Example 1 with GroupBuckets

use of org.onosproject.net.group.GroupBuckets in project onos by opennetworkinglab.

the class K8sGroupRuleManager method setRule.

@Override
public void setRule(ApplicationId appId, DeviceId deviceId, int groupId, Type type, List<GroupBucket> buckets, boolean install) {
    if (install) {
        GroupDescription groupDesc = new DefaultGroupDescription(deviceId, type, new GroupBuckets(buckets), getGroupKey(groupId), groupId, appId);
        groupService.addGroup(groupDesc);
    } else {
        groupService.removeGroup(deviceId, getGroupKey(groupId), appId);
    }
}
Also used : DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription) GroupDescription(org.onosproject.net.group.GroupDescription) GroupBuckets(org.onosproject.net.group.GroupBuckets) DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription)

Example 2 with GroupBuckets

use of org.onosproject.net.group.GroupBuckets in project onos by opennetworkinglab.

the class OFAgentVirtualGroupBucketEntryBuilder method build.

/**
 * Builds a GroupBuckets.
 *
 * @return GroupBuckets object, a list of GroupBuckets
 */
public GroupBuckets build() {
    List<GroupBucket> bucketList = Lists.newArrayList();
    for (OFBucket bucket : ofBuckets) {
        TrafficTreatment treatment = buildTreatment(bucket.getActions());
        // TODO: Use GroupBucketEntry
        GroupBucket groupBucket = null;
        switch(type) {
            case INDIRECT:
                groupBucket = DefaultGroupBucket.createIndirectGroupBucket(treatment);
                break;
            case SELECT:
                groupBucket = DefaultGroupBucket.createSelectGroupBucket(treatment, (short) bucket.getWeight());
                break;
            case FF:
                PortNumber port = PortNumber.portNumber(bucket.getWatchPort().getPortNumber());
                GroupId groupId = new GroupId(bucket.getWatchGroup().getGroupNumber());
                groupBucket = DefaultGroupBucket.createFailoverGroupBucket(treatment, port, groupId);
                break;
            case ALL:
                groupBucket = DefaultGroupBucket.createAllGroupBucket(treatment);
                break;
            default:
                log.error("Unsupported Group type : {}", type);
        }
        if (groupBucket != null) {
            bucketList.add(groupBucket);
        }
    }
    return new GroupBuckets(bucketList);
}
Also used : OFBucket(org.projectfloodlight.openflow.protocol.OFBucket) GroupBucket(org.onosproject.net.group.GroupBucket) DefaultGroupBucket(org.onosproject.net.group.DefaultGroupBucket) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) PortNumber(org.onosproject.net.PortNumber) GroupBuckets(org.onosproject.net.group.GroupBuckets) GroupId(org.onosproject.core.GroupId)

Example 3 with GroupBuckets

use of org.onosproject.net.group.GroupBuckets in project onos by opennetworkinglab.

the class SelectGroupHandler method updateGatewayGroupBuckets.

/**
 * Updates groupBuckets in select type group.
 *
 * @param deviceId target device id to update the group
 * @param nodeList updated gateway node list for bucket action
 * @param isInsert update type(add or remove)
 */
public void updateGatewayGroupBuckets(DeviceId deviceId, List<GatewayNode> nodeList, boolean isInsert) {
    List<GroupBucket> bucketList = generateBucketsForSelectGroup(deviceId, nodeList);
    GroupKey groupKey = getGroupKey(deviceId);
    if (isInsert) {
        groupService.addBucketsToGroup(deviceId, groupKey, new GroupBuckets(bucketList), groupKey, appId);
    } else {
        groupService.removeBucketsFromGroup(deviceId, groupKey, new GroupBuckets(bucketList), groupKey, appId);
    }
}
Also used : GroupKey(org.onosproject.net.group.GroupKey) DefaultGroupKey(org.onosproject.net.group.DefaultGroupKey) GroupBucket(org.onosproject.net.group.GroupBucket) DefaultGroupBucket.createSelectGroupBucket(org.onosproject.net.group.DefaultGroupBucket.createSelectGroupBucket) GroupBuckets(org.onosproject.net.group.GroupBuckets)

Example 4 with GroupBuckets

use of org.onosproject.net.group.GroupBuckets in project onos by opennetworkinglab.

the class OpenstackGroupRuleManager method setBuckets.

@Override
public void setBuckets(ApplicationId appId, DeviceId deviceId, int groupId, List<GroupBucket> buckets, boolean install) {
    if (!hasGroup(deviceId, groupId)) {
        return;
    }
    if (install) {
        // we add the buckets into the group, only if the buckets do not exist
        // in the given group
        Group group = groupService.getGroup(deviceId, getGroupKey(groupId));
        if (group.buckets() != null && !group.buckets().buckets().containsAll(buckets)) {
            groupService.addBucketsToGroup(deviceId, getGroupKey(groupId), new GroupBuckets(buckets), getGroupKey(groupId), appId);
            log.debug("Adding buckets for group rule {}", groupId);
        }
    } else {
        groupService.removeBucketsFromGroup(deviceId, getGroupKey(groupId), new GroupBuckets(buckets), getGroupKey(groupId), appId);
        log.debug("Removing buckets for group rule {}", groupId);
    }
}
Also used : Group(org.onosproject.net.group.Group) GroupBuckets(org.onosproject.net.group.GroupBuckets)

Example 5 with GroupBuckets

use of org.onosproject.net.group.GroupBuckets in project onos by opennetworkinglab.

the class OpenstackVtapManager method createGroupTable.

private void createGroupTable(DeviceId deviceId, int groupId, List<Integer> tableIds, List<PortNumber> ports) {
    List<GroupBucket> buckets = Lists.newArrayList();
    if (tableIds != null) {
        tableIds.forEach(tableId -> {
            TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder().extension(buildResubmitExtension(deviceId, tableId), deviceId);
            GroupBucket bucket = DefaultGroupBucket.createAllGroupBucket(treatment.build());
            buckets.add(bucket);
        });
    }
    if (ports != null) {
        ports.forEach(port -> {
            TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder().setOutput(port);
            GroupBucket bucket = DefaultGroupBucket.createAllGroupBucket(treatment.build());
            buckets.add(bucket);
        });
    }
    GroupDescription groupDescription = new DefaultGroupDescription(deviceId, GroupDescription.Type.ALL, new GroupBuckets(buckets), getGroupKey(groupId), groupId, appId);
    groupService.addGroup(groupDescription);
}
Also used : GroupDescription(org.onosproject.net.group.GroupDescription) DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription) GroupBucket(org.onosproject.net.group.GroupBucket) DefaultGroupBucket(org.onosproject.net.group.DefaultGroupBucket) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) GroupBuckets(org.onosproject.net.group.GroupBuckets) DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription)

Aggregations

GroupBuckets (org.onosproject.net.group.GroupBuckets)79 GroupBucket (org.onosproject.net.group.GroupBucket)71 DefaultGroupBucket (org.onosproject.net.group.DefaultGroupBucket)61 GroupKey (org.onosproject.net.group.GroupKey)53 DefaultGroupDescription (org.onosproject.net.group.DefaultGroupDescription)52 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)50 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)50 DefaultGroupKey (org.onosproject.net.group.DefaultGroupKey)49 GroupDescription (org.onosproject.net.group.GroupDescription)47 Group (org.onosproject.net.group.Group)34 ArrayList (java.util.ArrayList)31 GroupId (org.onosproject.core.GroupId)28 PortNumber (org.onosproject.net.PortNumber)23 DefaultGroup (org.onosproject.net.group.DefaultGroup)21 OfdpaGroupHandlerUtility.l2MulticastGroupKey (org.onosproject.driver.pipeline.ofdpa.OfdpaGroupHandlerUtility.l2MulticastGroupKey)17 ArrayDeque (java.util.ArrayDeque)15 Deque (java.util.Deque)15 NextGroup (org.onosproject.net.behaviour.NextGroup)12 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)11 VlanId (org.onlab.packet.VlanId)11