Search in sources :

Example 81 with GroupBuckets

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);
    }
}
Also used : Group(org.onosproject.net.group.Group) GroupBuckets(org.onosproject.net.group.GroupBuckets)

Example 82 with GroupBuckets

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);
    }
}
Also used : GroupDescription(org.onosproject.net.group.GroupDescription) DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription) OFGroupAdd(org.projectfloodlight.openflow.protocol.OFGroupAdd) OFGroupModify(org.projectfloodlight.openflow.protocol.OFGroupModify) GroupKey(org.onosproject.net.group.GroupKey) DefaultGroupKey(org.onosproject.net.group.DefaultGroupKey) DefaultGroupKey(org.onosproject.net.group.DefaultGroupKey) ApplicationId(org.onosproject.core.ApplicationId) GroupBuckets(org.onosproject.net.group.GroupBuckets) DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription) ConnectPoint(org.onosproject.net.ConnectPoint)

Example 83 with GroupBuckets

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);
        }
    }
}
Also used : DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription) GroupDescription(org.onosproject.net.group.GroupDescription) Group(org.onosproject.net.group.Group) GroupBuckets(org.onosproject.net.group.GroupBuckets) DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription)

Example 84 with GroupBuckets

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;
}
Also used : DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription) GroupDescription(org.onosproject.net.group.GroupDescription) GroupBucket(org.onosproject.net.group.GroupBucket) DefaultGroupBucket.createSelectGroupBucket(org.onosproject.net.group.DefaultGroupBucket.createSelectGroupBucket) GroupBuckets(org.onosproject.net.group.GroupBuckets) DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription) GroupId(org.onosproject.core.GroupId)

Example 85 with GroupBuckets

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);
}
Also used : PiTableId(org.onosproject.net.pi.model.PiTableId) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) PortNumber(org.onosproject.net.PortNumber) LoggerFactory(org.slf4j.LoggerFactory) GroupBucket(org.onosproject.net.group.GroupBucket) GroupKey(org.onosproject.net.group.GroupKey) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) ByteBuffer(java.nio.ByteBuffer) Preconditions.checkArgument(com.google.common.base.Preconditions.checkArgument) DefaultGroupBucket.createCloneGroupBucket(org.onosproject.net.group.DefaultGroupBucket.createCloneGroupBucket) DefaultGroupKey(org.onosproject.net.group.DefaultGroupKey) PiCriterion(org.onosproject.net.flow.criteria.PiCriterion) ApplicationId(org.onosproject.core.ApplicationId) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) PiActionProfileId(org.onosproject.net.pi.model.PiActionProfileId) PiTableAction(org.onosproject.net.pi.runtime.PiTableAction) Logger(org.slf4j.Logger) DefaultGroupBucket.createAllGroupBucket(org.onosproject.net.group.DefaultGroupBucket.createAllGroupBucket) Collection(java.util.Collection) Preconditions.checkNotNull(com.google.common.base.Preconditions.checkNotNull) PiGroupKey(org.onosproject.net.pi.runtime.PiGroupKey) Collectors(java.util.stream.Collectors) DefaultGroupBucket(org.onosproject.net.group.DefaultGroupBucket) PiAction(org.onosproject.net.pi.runtime.PiAction) DEFAULT_FLOW_RULE_PRIORITY(org.onosproject.ngsdn.tutorial.AppConstants.DEFAULT_FLOW_RULE_PRIORITY) List(java.util.List) FlowRule(org.onosproject.net.flow.FlowRule) GroupBuckets(org.onosproject.net.group.GroupBuckets) DeviceId(org.onosproject.net.DeviceId) DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription) GroupDescription(org.onosproject.net.group.GroupDescription) GroupKey(org.onosproject.net.group.GroupKey) DefaultGroupKey(org.onosproject.net.group.DefaultGroupKey) PiGroupKey(org.onosproject.net.pi.runtime.PiGroupKey) DefaultGroupKey(org.onosproject.net.group.DefaultGroupKey) GroupBucket(org.onosproject.net.group.GroupBucket) DefaultGroupBucket.createCloneGroupBucket(org.onosproject.net.group.DefaultGroupBucket.createCloneGroupBucket) DefaultGroupBucket.createAllGroupBucket(org.onosproject.net.group.DefaultGroupBucket.createAllGroupBucket) DefaultGroupBucket(org.onosproject.net.group.DefaultGroupBucket) GroupBuckets(org.onosproject.net.group.GroupBuckets) DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription)

Aggregations

GroupBuckets (org.onosproject.net.group.GroupBuckets)90 GroupBucket (org.onosproject.net.group.GroupBucket)82 DefaultGroupBucket (org.onosproject.net.group.DefaultGroupBucket)69 DefaultGroupDescription (org.onosproject.net.group.DefaultGroupDescription)63 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)58 GroupKey (org.onosproject.net.group.GroupKey)58 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)57 DefaultGroupKey (org.onosproject.net.group.DefaultGroupKey)56 GroupDescription (org.onosproject.net.group.GroupDescription)53 Group (org.onosproject.net.group.Group)35 ArrayList (java.util.ArrayList)31 GroupId (org.onosproject.core.GroupId)28 PortNumber (org.onosproject.net.PortNumber)27 DefaultGroup (org.onosproject.net.group.DefaultGroup)22 OfdpaGroupHandlerUtility.l2MulticastGroupKey (org.onosproject.driver.pipeline.ofdpa.OfdpaGroupHandlerUtility.l2MulticastGroupKey)17 ArrayDeque (java.util.ArrayDeque)15 Deque (java.util.Deque)15 TrafficSelector (org.onosproject.net.flow.TrafficSelector)15 PiGroupKey (org.onosproject.net.pi.runtime.PiGroupKey)14 NextObjective (org.onosproject.net.flowobjective.NextObjective)13