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