Search in sources :

Example 21 with Group

use of org.onosproject.net.group.Group 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 22 with Group

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

the class DistributedGroupStoreTest method testPushGroupMetrics.

/**
 * Tests pushing group metrics.
 */
@Test
public void testPushGroupMetrics() {
    groupStore.deviceInitialAuditCompleted(deviceId1, true);
    groupStore.deviceInitialAuditCompleted(deviceId2, true);
    GroupDescription groupDescription3 = new DefaultGroupDescription(deviceId1, ALL, allGroupBuckets, new DefaultGroupKey("aaa".getBytes()), null, APP_ID);
    groupStore.storeGroupDescription(groupDescription1);
    groupStore.storeGroupDescription(groupDescription2);
    groupStore.storeGroupDescription(groupDescription3);
    Group group1 = groupStore.getGroup(deviceId1, groupId1);
    assertThat(group1, instanceOf(DefaultGroup.class));
    DefaultGroup defaultGroup1 = (DefaultGroup) group1;
    defaultGroup1.setPackets(55L);
    defaultGroup1.setBytes(66L);
    groupStore.pushGroupMetrics(deviceId1, ImmutableList.of(group1));
    // Make sure the group was updated.
    Group requeryGroup1 = groupStore.getGroup(deviceId1, groupId1);
    assertThat(requeryGroup1.packets(), is(55L));
    assertThat(requeryGroup1.bytes(), is(66L));
}
Also used : DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription) GroupDescription(org.onosproject.net.group.GroupDescription) DefaultGroup(org.onosproject.net.group.DefaultGroup) Group(org.onosproject.net.group.Group) DefaultGroupKey(org.onosproject.net.group.DefaultGroupKey) DefaultGroup(org.onosproject.net.group.DefaultGroup) DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription) Test(org.junit.Test)

Example 23 with Group

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

the class DistributedGroupStoreTest method testAddRemoveGroup.

/**
 * Tests adding and removing a group.
 */
@Test
public void testAddRemoveGroup() throws Exception {
    groupStore.deviceInitialAuditCompleted(deviceId1, true);
    assertThat(groupStore.deviceInitialAuditStatus(deviceId1), is(true));
    // Make sure the pending list starts out empty
    assertThat(auditPendingReqQueue.size(), is(0));
    groupStore.storeGroupDescription(groupDescription1);
    assertThat(groupStore.getGroupCount(deviceId1), is(1));
    assertThat(groupStore.getGroup(deviceId1, groupId1), notNullValue());
    assertThat(groupStore.getGroup(deviceId1, groupKey1), notNullValue());
    // Make sure that nothing is pending
    assertThat(auditPendingReqQueue.size(), is(0));
    Group groupById = groupStore.getGroup(deviceId1, groupId1);
    Group groupByKey = groupStore.getGroup(deviceId1, groupKey1);
    assertThat(groupById, notNullValue());
    assertThat(groupByKey, notNullValue());
    assertThat(groupById, is(groupByKey));
    assertThat(groupById.deviceId(), is(did("dev1")));
    groupStore.removeGroupEntry(groupById);
    assertThat(groupStore.getGroupCount(deviceId1), is(0));
    assertThat(groupStore.getGroup(deviceId1, groupId1), nullValue());
    assertThat(groupStore.getGroup(deviceId1, groupKey1), nullValue());
    // Make sure that nothing is pending
    assertThat(auditPendingReqQueue.size(), is(0));
}
Also used : DefaultGroup(org.onosproject.net.group.DefaultGroup) Group(org.onosproject.net.group.Group) Test(org.junit.Test)

Example 24 with Group

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

the class DistributedGroupStoreTest method testExtraneousOperations.

/**
 * Tests extraneous group operations.
 */
@Test
public void testExtraneousOperations() {
    ArrayList<Group> extraneous;
    groupStore.deviceInitialAuditCompleted(deviceId1, true);
    groupStore.storeGroupDescription(groupDescription1);
    Group group1 = groupStore.getGroup(deviceId1, groupId1);
    extraneous = Lists.newArrayList(groupStore.getExtraneousGroups(deviceId1));
    assertThat(extraneous, hasSize(0));
    groupStore.addOrUpdateExtraneousGroupEntry(group1);
    extraneous = Lists.newArrayList(groupStore.getExtraneousGroups(deviceId1));
    assertThat(extraneous, hasSize(1));
    groupStore.removeExtraneousGroupEntry(group1);
    extraneous = Lists.newArrayList(groupStore.getExtraneousGroups(deviceId1));
    assertThat(extraneous, hasSize(0));
}
Also used : DefaultGroup(org.onosproject.net.group.DefaultGroup) Group(org.onosproject.net.group.Group) Test(org.junit.Test)

Example 25 with Group

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

the class HPPipelineV2 method tableIdForForwardingObjective.

@Override
protected int tableIdForForwardingObjective(TrafficSelector selector, TrafficTreatment treatment) {
    boolean hardwareProcess = true;
    log.debug("HP V2 Driver - Evaluating the ForwardingObjective for proper TableID");
    // Check criteria supported in hardware
    for (Criterion criterion : selector.criteria()) {
        if (!this.hardwareCriteria.contains(criterion.type())) {
            log.warn("HP V2 Driver - criterion {} only supported in SOFTWARE", criterion.type());
            hardwareProcess = false;
            break;
        }
        // V2 does not support hardware match on ETH_TYPE of value TYPE_VLAN (tested on HP3800 16.04)
        if (criterion.type() == Criterion.Type.ETH_TYPE) {
            if (((EthTypeCriterion) criterion).ethType().toShort() == Ethernet.TYPE_VLAN) {
                log.warn("HP V2 Driver - ETH_TYPE == VLAN (0x8100) is only supported in software");
                hardwareProcess = false;
                break;
            }
        }
        // HP2920 cannot match in hardware the ETH_DST in non-IP packets - TO BE REFINED AND TESTED
        if (deviceHwVersion.contains("2920")) {
            if (criterion.type() == Criterion.Type.ETH_DST) {
                log.warn("HP V2 Driver (specific for HP2920) " + "- criterion {} only supported in SOFTWARE", criterion.type());
                hardwareProcess = false;
                break;
            }
        }
    }
    // Check if a CLEAR action is included
    if (treatment.clearedDeferred()) {
        log.warn("HP V2 Driver - CLEAR action only supported in SOFTWARE");
        hardwareProcess = false;
    }
    // If criteria can be processed in hardware, then check treatment
    if (hardwareProcess) {
        for (Instruction instruction : treatment.allInstructions()) {
            // Check if the instruction type is contained in the hardware instruction
            if (!this.hardwareInstructions.contains(instruction.type())) {
                log.warn("HP V2 Driver - instruction {} only supported in SOFTWARE", instruction.type());
                hardwareProcess = false;
                break;
            }
            /* If output is CONTROLLER_PORT the flow entry could be installed in hardware
                 * but is anyway processed in software because OPENFLOW header has to be added
                 */
            if (instruction.type() == Instruction.Type.OUTPUT) {
                if (((Instructions.OutputInstruction) instruction).port() == PortNumber.CONTROLLER) {
                    log.warn("HP V2 Driver - Forwarding to CONTROLLER only supported in software");
                    hardwareProcess = false;
                    break;
                }
            }
            // Check if the specific L2MODIFICATION.subtype is supported in hardware
            if (instruction.type() == Instruction.Type.L2MODIFICATION) {
                if (!this.hardwareInstructionsL2mod.contains(((L2ModificationInstruction) instruction).subtype())) {
                    log.warn("HP V2 Driver - L2MODIFICATION.subtype {} only supported in SOFTWARE", ((L2ModificationInstruction) instruction).subtype());
                    hardwareProcess = false;
                    break;
                }
            }
            // TODO --- check if all the buckets contains one and only one output action
            if (instruction.type() == Instruction.Type.GROUP) {
                boolean groupInstalled = false;
                GroupId groupId = ((Instructions.GroupInstruction) instruction).groupId();
                Iterable<Group> groupsOnDevice = groupService.getGroups(deviceId);
                for (Group group : groupsOnDevice) {
                    if ((group.state() == Group.GroupState.ADDED) && (group.id().equals(groupId))) {
                        groupInstalled = true;
                        if (group.type() != Group.Type.ALL) {
                            log.warn("HP V2 Driver - group type {} only supported in SOFTWARE", group.type().toString());
                            hardwareProcess = false;
                        }
                        break;
                    }
                }
                if (!groupInstalled) {
                    log.warn("HP V2 Driver - referenced group is not installed on the device.");
                    hardwareProcess = false;
                }
            }
        }
    }
    if (hardwareProcess) {
        log.warn("HP V2 Driver - This flow rule is supported in HARDWARE");
        return HP_HARDWARE_TABLE;
    } else {
        // TODO: create a specific flow in table 100 to redirect selected traffic on table 200
        log.warn("HP V2 Driver - This flow rule is only supported in SOFTWARE");
        return HP_SOFTWARE_TABLE;
    }
}
Also used : Group(org.onosproject.net.group.Group) EthTypeCriterion(org.onosproject.net.flow.criteria.EthTypeCriterion) PortCriterion(org.onosproject.net.flow.criteria.PortCriterion) EthCriterion(org.onosproject.net.flow.criteria.EthCriterion) VlanIdCriterion(org.onosproject.net.flow.criteria.VlanIdCriterion) IPCriterion(org.onosproject.net.flow.criteria.IPCriterion) Criterion(org.onosproject.net.flow.criteria.Criterion) EthTypeCriterion(org.onosproject.net.flow.criteria.EthTypeCriterion) Instructions(org.onosproject.net.flow.instructions.Instructions) L2ModificationInstruction(org.onosproject.net.flow.instructions.L2ModificationInstruction) L3ModificationInstruction(org.onosproject.net.flow.instructions.L3ModificationInstruction) Instruction(org.onosproject.net.flow.instructions.Instruction) L2ModificationInstruction(org.onosproject.net.flow.instructions.L2ModificationInstruction) GroupId(org.onosproject.core.GroupId)

Aggregations

Group (org.onosproject.net.group.Group)120 DefaultGroup (org.onosproject.net.group.DefaultGroup)57 GroupKey (org.onosproject.net.group.GroupKey)56 DefaultGroupKey (org.onosproject.net.group.DefaultGroupKey)45 GroupBucket (org.onosproject.net.group.GroupBucket)44 GroupBuckets (org.onosproject.net.group.GroupBuckets)42 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)38 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)38 NextGroup (org.onosproject.net.behaviour.NextGroup)37 ArrayList (java.util.ArrayList)36 GroupDescription (org.onosproject.net.group.GroupDescription)36 DefaultGroupDescription (org.onosproject.net.group.DefaultGroupDescription)30 PortNumber (org.onosproject.net.PortNumber)27 DefaultGroupBucket (org.onosproject.net.group.DefaultGroupBucket)26 DeviceId (org.onosproject.net.DeviceId)24 TrafficSelector (org.onosproject.net.flow.TrafficSelector)24 GroupId (org.onosproject.core.GroupId)23 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)21 FlowRule (org.onosproject.net.flow.FlowRule)20 Instruction (org.onosproject.net.flow.instructions.Instruction)20