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));
}
}
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);
}
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);
}
Aggregations