Search in sources :

Example 16 with GroupBuckets

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

the class PointToPointIntentCompiler method updateFailoverGroup.

// Removes buckets whose treatments rely on disabled ports from the
// failover group.
private void updateFailoverGroup(PointToPointIntent pointIntent) {
    DeviceId deviceId = pointIntent.filteredIngressPoint().connectPoint().deviceId();
    GroupKey groupKey = makeGroupKey(pointIntent.id());
    Group group = waitForGroup(deviceId, groupKey);
    Iterator<GroupBucket> groupIterator = group.buckets().buckets().iterator();
    while (groupIterator.hasNext()) {
        GroupBucket bucket = groupIterator.next();
        Instruction individualInstruction = bucket.treatment().allInstructions().get(0);
        if (individualInstruction instanceof Instructions.OutputInstruction) {
            Instructions.OutputInstruction outInstruction = (Instructions.OutputInstruction) individualInstruction;
            Port port = deviceService.getPort(deviceId, outInstruction.port());
            if (port == null || !port.isEnabled()) {
                GroupBuckets removeBuckets = new GroupBuckets(Collections.singletonList(bucket));
                groupService.removeBucketsFromGroup(deviceId, groupKey, removeBuckets, groupKey, pointIntent.appId());
            }
        }
    }
}
Also used : Group(org.onosproject.net.group.Group) DeviceId(org.onosproject.net.DeviceId) Port(org.onosproject.net.Port) GroupKey(org.onosproject.net.group.GroupKey) DefaultGroupKey(org.onosproject.net.group.DefaultGroupKey) GroupBucket(org.onosproject.net.group.GroupBucket) DefaultGroupBucket(org.onosproject.net.group.DefaultGroupBucket) Instructions(org.onosproject.net.flow.instructions.Instructions) Instruction(org.onosproject.net.flow.instructions.Instruction) GroupBuckets(org.onosproject.net.group.GroupBuckets)

Example 17 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 18 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 19 with GroupBuckets

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

the class DistributedGroupStoreTest method testUpdateGroupDescription.

/**
 * Tests updating of group descriptions.
 */
@Test
public void testUpdateGroupDescription() {
    GroupBuckets buckets = new GroupBuckets(ImmutableList.of(allGroupBucket2));
    groupStore.deviceInitialAuditCompleted(deviceId1, true);
    groupStore.storeGroupDescription(groupDescription1);
    GroupKey newKey = new DefaultGroupKey("123".getBytes());
    groupStore.updateGroupDescription(deviceId1, groupKey1, ADD, buckets, newKey);
    Group group1 = groupStore.getGroup(deviceId1, groupId1);
    assertThat(group1.appCookie(), is(newKey));
    assertThat(group1.buckets().buckets(), hasSize(2));
    buckets = new GroupBuckets(ImmutableList.of(allGroupBucket, allGroupBucket2));
    groupStore.updateGroupDescription(deviceId1, newKey, ADD, buckets, newKey);
    group1 = groupStore.getGroup(deviceId1, groupId1);
    assertThat(group1.appCookie(), is(newKey));
    assertThat(group1.buckets().buckets(), hasSize(2));
    for (GroupBucket bucket : group1.buckets().buckets()) {
        assertTrue(bucket.treatment().equals(treatment) || bucket.treatment().equals(treatment2));
    }
    buckets = new GroupBuckets(ImmutableList.of(allGroupBucket2));
    groupStore.updateGroupDescription(deviceId1, newKey, SET, buckets, newKey);
    group1 = groupStore.getGroup(deviceId1, groupId1);
    assertThat(group1.appCookie(), is(newKey));
    assertThat(group1.buckets().buckets(), hasSize(1));
    GroupBucket onlyBucket = group1.buckets().buckets().iterator().next();
    assertEquals(treatment2, onlyBucket.treatment());
}
Also used : DefaultGroup(org.onosproject.net.group.DefaultGroup) Group(org.onosproject.net.group.Group) GroupKey(org.onosproject.net.group.GroupKey) DefaultGroupKey(org.onosproject.net.group.DefaultGroupKey) DefaultGroupKey(org.onosproject.net.group.DefaultGroupKey) GroupBucket(org.onosproject.net.group.GroupBucket) DefaultGroupBucket(org.onosproject.net.group.DefaultGroupBucket) GroupBuckets(org.onosproject.net.group.GroupBuckets) Test(org.junit.Test)

Example 20 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)90 GroupBucket (org.onosproject.net.group.GroupBucket)82 DefaultGroupBucket (org.onosproject.net.group.DefaultGroupBucket)69 DefaultGroupDescription (org.onosproject.net.group.DefaultGroupDescription)63 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)58 GroupKey (org.onosproject.net.group.GroupKey)58 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)57 DefaultGroupKey (org.onosproject.net.group.DefaultGroupKey)56 GroupDescription (org.onosproject.net.group.GroupDescription)53 Group (org.onosproject.net.group.Group)35 ArrayList (java.util.ArrayList)31 GroupId (org.onosproject.core.GroupId)28 PortNumber (org.onosproject.net.PortNumber)27 DefaultGroup (org.onosproject.net.group.DefaultGroup)22 OfdpaGroupHandlerUtility.l2MulticastGroupKey (org.onosproject.driver.pipeline.ofdpa.OfdpaGroupHandlerUtility.l2MulticastGroupKey)17 ArrayDeque (java.util.ArrayDeque)15 Deque (java.util.Deque)15 TrafficSelector (org.onosproject.net.flow.TrafficSelector)15 PiGroupKey (org.onosproject.net.pi.runtime.PiGroupKey)14 NextObjective (org.onosproject.net.flowobjective.NextObjective)13