Search in sources :

Example 71 with GroupDescription

use of org.onosproject.net.group.GroupDescription 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 72 with GroupDescription

use of org.onosproject.net.group.GroupDescription 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 73 with GroupDescription

use of org.onosproject.net.group.GroupDescription 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 74 with GroupDescription

use of org.onosproject.net.group.GroupDescription in project TFG by mattinelorza.

the class Ipv6SimpleRoutingComponent method cloneToCollector.

private void cloneToCollector(DeviceId deviceId) {
    final long COLLECTOR_PORT_ID = 4;
    PortNumber collectorPort = PortNumber.portNumber(COLLECTOR_PORT_ID);
    final int COLLECTOR_CLONE_SESSION_ID = 90;
    final GroupDescription cloneGroupCollector = Utils.buildCloneGroup(appId, deviceId, COLLECTOR_CLONE_SESSION_ID, // Just controller in this case.
    Collections.singleton(collectorPort));
    groupService.addGroup(cloneGroupCollector);
}
Also used : GroupDescription(org.onosproject.net.group.GroupDescription) PortNumber(org.onosproject.net.PortNumber)

Example 75 with GroupDescription

use of org.onosproject.net.group.GroupDescription 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

GroupDescription (org.onosproject.net.group.GroupDescription)82 DefaultGroupDescription (org.onosproject.net.group.DefaultGroupDescription)66 GroupBuckets (org.onosproject.net.group.GroupBuckets)51 GroupBucket (org.onosproject.net.group.GroupBucket)48 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)46 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)44 GroupKey (org.onosproject.net.group.GroupKey)44 DefaultGroupBucket (org.onosproject.net.group.DefaultGroupBucket)39 DefaultGroupKey (org.onosproject.net.group.DefaultGroupKey)39 FlowRule (org.onosproject.net.flow.FlowRule)28 List (java.util.List)26 TrafficSelector (org.onosproject.net.flow.TrafficSelector)26 PiAction (org.onosproject.net.pi.runtime.PiAction)26 DefaultFlowRule (org.onosproject.net.flow.DefaultFlowRule)25 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)23 Group (org.onosproject.net.group.Group)23 Test (org.junit.Test)22 ArrayList (java.util.ArrayList)20 GroupId (org.onosproject.core.GroupId)20 PortNumber (org.onosproject.net.PortNumber)19