use of org.onosproject.net.group.GroupBuckets in project onos by opennetworkinglab.
the class KubevirtGroupRuleManager method setBuckets.
@Override
public void setBuckets(ApplicationId appId, DeviceId deviceId, int groupId, List<GroupBucket> buckets, boolean install) {
if (!hasGroup(deviceId, groupId)) {
return;
}
if (install) {
// we add the buckets into the group, only if the buckets do not exist
// in the given group
Group group = groupService.getGroup(deviceId, getGroupKey(groupId));
if (group.buckets() != null && !group.buckets().buckets().containsAll(buckets)) {
groupService.addBucketsToGroup(deviceId, getGroupKey(groupId), new GroupBuckets(buckets), getGroupKey(groupId), appId);
log.debug("Adding buckets for group rule {}", groupId);
}
} else {
groupService.removeBucketsFromGroup(deviceId, getGroupKey(groupId), new GroupBuckets(buckets), getGroupKey(groupId), appId);
log.debug("Removing buckets for group rule {}", groupId);
}
}
use of org.onosproject.net.group.GroupBuckets in project onos by opennetworkinglab.
the class DefaultOFSwitch method processGroupMod.
private void processGroupMod(OFGroupMod groupMod) {
log.debug("processing GROUP_MOD {} message", groupMod.getCommand());
ApplicationId appId = ofSwitchService.appId();
GroupKey appCookie = new DefaultGroupKey(networkId.toString().getBytes());
switch(groupMod.getCommand()) {
case ADD:
// TODO return OFGroupModFailedCode.GROUP_EXISTS if group already exists
int groupId = groupMod.getGroup().getGroupNumber();
OFGroupAdd groupAdd = (OFGroupAdd) groupMod;
GroupBuckets groupAddBuckets = new OFAgentVirtualGroupBucketEntryBuilder(Dpid.dpid(Dpid.uri(dpid().getLong())), groupAdd.getBuckets(), groupAdd.getGroupType(), driverService).build();
GroupDescription groupDescription = new DefaultGroupDescription(deviceId, getGroupType(groupAdd.getGroupType()), groupAddBuckets, appCookie, groupId, appId);
groupService.addGroup(groupDescription);
break;
case MODIFY:
// TODO return OFGroupModFailedCode.INVALID_GROUP if group does not exist
OFGroupModify groupModify = (OFGroupModify) groupMod;
GroupBuckets groupModifyBuckets = new OFAgentVirtualGroupBucketEntryBuilder(Dpid.dpid(Dpid.uri(dpid().getLong())), groupModify.getBuckets(), groupModify.getGroupType(), driverService).build();
groupService.setBucketsForGroup(deviceId, appCookie, groupModifyBuckets, appCookie, appId);
break;
case DELETE:
groupService.removeGroup(deviceId, appCookie, appId);
break;
default:
// INSERT_BUCKET, REMOVE_BUCKET are effective OF 1.5. OFAgent supports 1.3.
log.warn("Unsupported GROUP_MOD {} message received for switch {}", groupMod.getCommand(), this);
}
}
use of org.onosproject.net.group.GroupBuckets in project onos by opennetworkinglab.
the class OpenstackGroupRuleManager method setRule.
@Override
public void setRule(ApplicationId appId, DeviceId deviceId, int groupId, GroupDescription.Type type, List<GroupBucket> buckets, boolean install) {
Group group = groupService.getGroup(deviceId, getGroupKey(groupId));
if (install) {
if (group == null) {
GroupDescription groupDesc = new DefaultGroupDescription(deviceId, type, new GroupBuckets(buckets), getGroupKey(groupId), groupId, appId);
groupService.addGroup(groupDesc);
log.debug("Adding group table rule {}", groupId);
}
} else {
if (group != null) {
groupService.removeGroup(deviceId, getGroupKey(groupId), appId);
log.debug("Removing group table rule {}", groupId);
}
}
}
use of org.onosproject.net.group.GroupBuckets in project onos by opennetworkinglab.
the class SelectGroupHandler method createGatewayGroup.
/**
* Creates select type group description according to given deviceId.
*
* @param srcDeviceId target device id for group description
* @param nodeList gateway node list for bucket action
* @return created select type group description
*/
public GroupId createGatewayGroup(DeviceId srcDeviceId, List<GatewayNode> nodeList) {
List<GroupBucket> bucketList = generateBucketsForSelectGroup(srcDeviceId, nodeList);
GroupId groupId = getGroupId(srcDeviceId);
GroupDescription groupDescription = new DefaultGroupDescription(srcDeviceId, GroupDescription.Type.SELECT, new GroupBuckets(bucketList), getGroupKey(srcDeviceId), groupId.id(), appId);
groupService.addGroup(groupDescription);
return groupId;
}
use of org.onosproject.net.group.GroupBuckets in project TFG by mattinelorza.
the class Utils method buildReplicationGroup.
private static GroupDescription buildReplicationGroup(ApplicationId appId, DeviceId deviceId, int groupId, Collection<PortNumber> ports, boolean isClone) {
checkNotNull(deviceId);
checkNotNull(appId);
checkArgument(!ports.isEmpty());
final GroupKey groupKey = new DefaultGroupKey(ByteBuffer.allocate(4).putInt(groupId).array());
final List<GroupBucket> bucketList = ports.stream().map(p -> DefaultTrafficTreatment.builder().setOutput(p).build()).map(t -> isClone ? createCloneGroupBucket(t) : createAllGroupBucket(t)).collect(Collectors.toList());
return new DefaultGroupDescription(deviceId, isClone ? GroupDescription.Type.CLONE : GroupDescription.Type.ALL, new GroupBuckets(bucketList), groupKey, groupId, appId);
}
Aggregations