Search in sources :

Example 1 with GroupOperations

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

the class P4RuntimeGroupProgrammable method doPerformGroupOperation.

private void doPerformGroupOperation(DeviceId deviceId, GroupOperations groupOps) {
    // TODO: fix GroupProgrammable API, passing the device ID is ambiguous
    checkArgument(deviceId.equals(data().deviceId()), "passed deviceId must be the same assigned to this behavior");
    final List<GroupOperation> actionGroups = Lists.newArrayList();
    final List<GroupOperation> preGroups = Lists.newArrayList();
    groupOps.operations().forEach(op -> {
        switch(op.groupType()) {
            case INDIRECT:
            case SELECT:
                actionGroups.add(op);
                break;
            case ALL:
            case CLONE:
                preGroups.add(op);
                break;
            case FAILOVER:
            default:
                log.warn("{} group type not supported [{}]", op.groupType(), op);
        }
    });
    if (!actionGroups.isEmpty()) {
        actionProgrammable().performGroupOperation(deviceId, new GroupOperations(actionGroups));
    }
    if (!preGroups.isEmpty()) {
        replicationProgrammable().performGroupOperation(deviceId, new GroupOperations(preGroups));
    }
}
Also used : GroupOperations(org.onosproject.net.group.GroupOperations) GroupOperation(org.onosproject.net.group.GroupOperation)

Example 2 with GroupOperations

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

the class OpenFlowGroupProviderTest method addGroup.

@Test
public void addGroup() {
    GroupId groupId = new GroupId(1);
    List<GroupBucket> bucketList = Lists.newArrayList();
    TrafficTreatment.Builder builder = DefaultTrafficTreatment.builder();
    builder.setOutput(PortNumber.portNumber(1));
    GroupBucket bucket = DefaultGroupBucket.createSelectGroupBucket(builder.build());
    bucketList.add(bucket);
    GroupBuckets buckets = new GroupBuckets(bucketList);
    List<GroupOperation> operationList = Lists.newArrayList();
    GroupOperation operation = GroupOperation.createAddGroupOperation(groupId, GroupDescription.Type.SELECT, buckets);
    operationList.add(operation);
    GroupOperations operations = new GroupOperations(operationList);
    provider.performGroupOperation(deviceId, operations);
    final Dpid dpid = Dpid.dpid(deviceId.uri());
    TestOpenFlowSwitch sw = (TestOpenFlowSwitch) controller.getSwitch(dpid);
    assertNotNull("Switch should not be nul", sw);
    assertNotNull("OFGroupMsg should not be null", sw.msg);
}
Also used : GroupOperations(org.onosproject.net.group.GroupOperations) Dpid(org.onosproject.openflow.controller.Dpid) 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) GroupOperation(org.onosproject.net.group.GroupOperation) GroupId(org.onosproject.core.GroupId) Test(org.junit.Test)

Example 3 with GroupOperations

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

the class OpenFlowGroupProviderTest method groupModFailure.

@Test
public void groupModFailure() {
    TestOpenFlowGroupProviderService testProviderService = (TestOpenFlowGroupProviderService) providerService;
    GroupId groupId = new GroupId(1);
    List<GroupBucket> bucketList = Lists.newArrayList();
    TrafficTreatment.Builder builder = DefaultTrafficTreatment.builder();
    builder.setOutput(PortNumber.portNumber(1));
    GroupBucket bucket = DefaultGroupBucket.createSelectGroupBucket(builder.build());
    bucketList.add(bucket);
    GroupBuckets buckets = new GroupBuckets(bucketList);
    List<GroupOperation> operationList = Lists.newArrayList();
    GroupOperation operation = GroupOperation.createAddGroupOperation(groupId, GroupDescription.Type.SELECT, buckets);
    operationList.add(operation);
    GroupOperations operations = new GroupOperations(operationList);
    provider.performGroupOperation(deviceId, operations);
    OFGroupModFailedErrorMsg.Builder errorBuilder = OFFactories.getFactory(OFVersion.OF_13).errorMsgs().buildGroupModFailedErrorMsg();
    OFGroupMod.Builder groupBuilder = OFFactories.getFactory(OFVersion.OF_13).buildGroupModify();
    groupBuilder.setGroupType(OFGroupType.ALL);
    groupBuilder.setGroup(OFGroup.of(1));
    errorBuilder.setCode(OFGroupModFailedCode.GROUP_EXISTS);
    errorBuilder.setXid(provider.getXidAndAdd(0) - 1);
    controller.processPacket(dpid1, errorBuilder.build());
    assertNotNull("Operation failed should not be null", testProviderService.failedOperation);
}
Also used : OFGroupModFailedErrorMsg(org.projectfloodlight.openflow.protocol.errormsg.OFGroupModFailedErrorMsg) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) GroupBuckets(org.onosproject.net.group.GroupBuckets) GroupId(org.onosproject.core.GroupId) OFGroupMod(org.projectfloodlight.openflow.protocol.OFGroupMod) GroupOperations(org.onosproject.net.group.GroupOperations) GroupBucket(org.onosproject.net.group.GroupBucket) DefaultGroupBucket(org.onosproject.net.group.DefaultGroupBucket) GroupOperation(org.onosproject.net.group.GroupOperation) Test(org.junit.Test)

Aggregations

GroupOperation (org.onosproject.net.group.GroupOperation)3 GroupOperations (org.onosproject.net.group.GroupOperations)3 Test (org.junit.Test)2 GroupId (org.onosproject.core.GroupId)2 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)2 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)2 DefaultGroupBucket (org.onosproject.net.group.DefaultGroupBucket)2 GroupBucket (org.onosproject.net.group.GroupBucket)2 GroupBuckets (org.onosproject.net.group.GroupBuckets)2 Dpid (org.onosproject.openflow.controller.Dpid)1 OFGroupMod (org.projectfloodlight.openflow.protocol.OFGroupMod)1 OFGroupModFailedErrorMsg (org.projectfloodlight.openflow.protocol.errormsg.OFGroupModFailedErrorMsg)1