Search in sources :

Example 61 with DefaultGroupDescription

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

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

Example 63 with DefaultGroupDescription

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

the class Utils method buildSelectGroup.

public static GroupDescription buildSelectGroup(DeviceId deviceId, String tableId, String actionProfileId, int groupId, Collection<PiAction> actions, ApplicationId appId) {
    final GroupKey groupKey = new PiGroupKey(PiTableId.of(tableId), PiActionProfileId.of(actionProfileId), groupId);
    final List<GroupBucket> buckets = actions.stream().map(action -> DefaultTrafficTreatment.builder().piTableAction(action).build()).map(DefaultGroupBucket::createSelectGroupBucket).collect(Collectors.toList());
    return new DefaultGroupDescription(deviceId, GroupDescription.Type.SELECT, new GroupBuckets(buckets), groupKey, groupId, appId);
}
Also used : PiGroupKey(org.onosproject.net.pi.runtime.PiGroupKey) GroupKey(org.onosproject.net.group.GroupKey) DefaultGroupKey(org.onosproject.net.group.DefaultGroupKey) PiGroupKey(org.onosproject.net.pi.runtime.PiGroupKey) 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)

Example 64 with DefaultGroupDescription

use of org.onosproject.net.group.DefaultGroupDescription in project fabric-tna by stratum.

the class NextObjectiveTranslatorTest method testHashedOutput.

/**
 * Test program ecmp output group for Hashed table.
 */
@Test
public void testHashedOutput() throws Exception {
    PiAction piAction1 = PiAction.builder().withId(P4InfoConstants.FABRIC_INGRESS_NEXT_ROUTING_HASHED).withParameter(new PiActionParam(P4InfoConstants.SMAC, ROUTER_MAC.toBytes())).withParameter(new PiActionParam(P4InfoConstants.DMAC, HOST_MAC.toBytes())).withParameter(new PiActionParam(P4InfoConstants.PORT_NUM, PORT_1.toLong())).build();
    PiAction piAction2 = PiAction.builder().withId(P4InfoConstants.FABRIC_INGRESS_NEXT_ROUTING_HASHED).withParameter(new PiActionParam(P4InfoConstants.SMAC, ROUTER_MAC.toBytes())).withParameter(new PiActionParam(P4InfoConstants.DMAC, HOST_MAC.toBytes())).withParameter(new PiActionParam(P4InfoConstants.PORT_NUM, PORT_1.toLong())).build();
    TrafficTreatment treatment1 = DefaultTrafficTreatment.builder().piTableAction(piAction1).build();
    TrafficTreatment treatment2 = DefaultTrafficTreatment.builder().piTableAction(piAction2).build();
    NextObjective nextObjective = DefaultNextObjective.builder().withId(NEXT_ID_1).withPriority(PRIORITY).withMeta(VLAN_META).addTreatment(treatment1).addTreatment(treatment2).withType(NextObjective.Type.HASHED).makePermanent().fromApp(APP_ID).add();
    ObjectiveTranslation actualTranslation = translatorHashed.doTranslate(nextObjective);
    // Expected hashed table flow rule.
    PiCriterion nextIdCriterion = PiCriterion.builder().matchExact(P4InfoConstants.HDR_NEXT_ID, NEXT_ID_1).build();
    TrafficSelector nextIdSelector = DefaultTrafficSelector.builder().matchPi(nextIdCriterion).build();
    PiActionProfileGroupId actionGroupId = PiActionProfileGroupId.of(NEXT_ID_1);
    TrafficTreatment treatment = DefaultTrafficTreatment.builder().piTableAction(actionGroupId).build();
    FlowRule expectedFlowRule = DefaultFlowRule.builder().forDevice(DEVICE_ID).fromApp(APP_ID).makePermanent().withPriority(0).forTable(P4InfoConstants.FABRIC_INGRESS_NEXT_HASHED).withSelector(nextIdSelector).withTreatment(treatment).build();
    // Expected group
    List<TrafficTreatment> treatments = ImmutableList.of(treatment1, treatment2);
    List<GroupBucket> buckets = treatments.stream().map(DefaultGroupBucket::createSelectGroupBucket).collect(Collectors.toList());
    GroupBuckets groupBuckets = new GroupBuckets(buckets);
    PiGroupKey groupKey = new PiGroupKey(P4InfoConstants.FABRIC_INGRESS_NEXT_HASHED, P4InfoConstants.FABRIC_INGRESS_NEXT_HASHED_PROFILE, NEXT_ID_1);
    GroupDescription expectedGroup = new DefaultGroupDescription(DEVICE_ID, GroupDescription.Type.SELECT, groupBuckets, groupKey, NEXT_ID_1, APP_ID);
    ObjectiveTranslation expectedTranslation = ObjectiveTranslation.builder().addFlowRule(expectedFlowRule).addFlowRule(vlanMetaFlowRule).addGroup(expectedGroup).build();
    assertEquals(expectedTranslation, actualTranslation);
}
Also used : DefaultNextObjective(org.onosproject.net.flowobjective.DefaultNextObjective) NextObjective(org.onosproject.net.flowobjective.NextObjective) PiCriterion(org.onosproject.net.flow.criteria.PiCriterion) PiActionProfileGroupId(org.onosproject.net.pi.runtime.PiActionProfileGroupId) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) GroupBuckets(org.onosproject.net.group.GroupBuckets) PiAction(org.onosproject.net.pi.runtime.PiAction) DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription) GroupDescription(org.onosproject.net.group.GroupDescription) PiGroupKey(org.onosproject.net.pi.runtime.PiGroupKey) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) GroupBucket(org.onosproject.net.group.GroupBucket) DefaultGroupBucket(org.onosproject.net.group.DefaultGroupBucket) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) FlowRule(org.onosproject.net.flow.FlowRule) PiActionParam(org.onosproject.net.pi.runtime.PiActionParam) DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription) Test(org.junit.Test)

Example 65 with DefaultGroupDescription

use of org.onosproject.net.group.DefaultGroupDescription in project fabric-tna by stratum.

the class FabricIntProgrammableTest method testInit.

private void testInit() {
    final List<GroupDescription> expectedGroups = Lists.newArrayList();
    final Capture<GroupDescription> capturedGroup = newCapture(CaptureType.ALL);
    final Map<Integer, Long> recircPorts = intProgrammable.capabilities.isArchV1model() ? V1MODEL_MIRROR_SESS_TO_RECIRC_PORTS : QUAD_PIPE_MIRROR_SESS_TO_RECIRC_PORTS;
    recircPorts.forEach((sessionId, port) -> {
        // Set up mirror sessions
        final List<GroupBucket> buckets = ImmutableList.of(getCloneBucket(port));
        expectedGroups.add(new DefaultGroupDescription(LEAF_DEVICE_ID, GroupDescription.Type.CLONE, new GroupBuckets(buckets), new DefaultGroupKey(KRYO.serialize(sessionId)), sessionId, APP_ID));
        groupService.addGroup(capture(capturedGroup));
    });
    replay(groupService, flowRuleService);
    assertTrue(intProgrammable.init());
    for (int i = 0; i < recircPorts.size(); i++) {
        GroupDescription expectGroup = expectedGroups.get(i);
        GroupDescription actualGroup = capturedGroup.getValues().get(i);
        assertEquals(expectGroup, actualGroup);
    }
    verify(groupService, flowRuleService);
    reset(groupService, flowRuleService);
}
Also used : DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription) GroupDescription(org.onosproject.net.group.GroupDescription) DefaultGroupKey(org.onosproject.net.group.DefaultGroupKey) GroupBucket(org.onosproject.net.group.GroupBucket) DefaultGroupBucket.createCloneGroupBucket(org.onosproject.net.group.DefaultGroupBucket.createCloneGroupBucket) GroupBuckets(org.onosproject.net.group.GroupBuckets) DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription)

Aggregations

DefaultGroupDescription (org.onosproject.net.group.DefaultGroupDescription)67 GroupBuckets (org.onosproject.net.group.GroupBuckets)61 GroupBucket (org.onosproject.net.group.GroupBucket)56 GroupDescription (org.onosproject.net.group.GroupDescription)54 DefaultGroupBucket (org.onosproject.net.group.DefaultGroupBucket)47 GroupKey (org.onosproject.net.group.GroupKey)45 DefaultGroupKey (org.onosproject.net.group.DefaultGroupKey)42 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)40 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)39 GroupId (org.onosproject.core.GroupId)21 Group (org.onosproject.net.group.Group)21 ArrayList (java.util.ArrayList)18 OfdpaGroupHandlerUtility.l2MulticastGroupKey (org.onosproject.driver.pipeline.ofdpa.OfdpaGroupHandlerUtility.l2MulticastGroupKey)15 PortNumber (org.onosproject.net.PortNumber)14 PiGroupKey (org.onosproject.net.pi.runtime.PiGroupKey)14 ArrayDeque (java.util.ArrayDeque)13 Deque (java.util.Deque)13 TrafficSelector (org.onosproject.net.flow.TrafficSelector)13 DefaultGroup (org.onosproject.net.group.DefaultGroup)13 VlanId (org.onlab.packet.VlanId)10