Search in sources :

Example 91 with PortOutAction

use of org.openkilda.rulemanager.action.PortOutAction in project open-kilda by telstra.

the class OfGroupConverterTest method testConvertToGroupSpeakerData.

@Test
public void testConvertToGroupSpeakerData() {
    OFFactoryVer13 factory = new OFFactoryVer13();
    Builder builder = factory.buildGroupDescStatsReply();
    List<OFGroupDescStatsEntry> entries = new ArrayList<>();
    entries.add(getOfGroupEntry(factory));
    builder.setEntries(entries);
    List<GroupSpeakerData> groupSpeakerDataList = OfGroupConverter.INSTANCE.convertToGroupSpeakerData(builder.build());
    assertEquals(1, groupSpeakerDataList.size());
    GroupSpeakerData groupSpeakerData = groupSpeakerDataList.get(0);
    assertEquals(new GroupId(GROUP_ID), groupSpeakerData.getGroupId());
    assertEquals(GroupType.ALL, groupSpeakerData.getType());
    List<Bucket> buckets = groupSpeakerData.getBuckets();
    Set<Bucket> expectedBuckets = new HashSet<>();
    expectedBuckets.add(Bucket.builder().watchPort(WatchPort.ANY).watchGroup(WatchGroup.ALL).writeActions(Sets.newHashSet(new PortOutAction(new PortNumber(2, null)))).build());
    expectedBuckets.add(Bucket.builder().watchPort(WatchPort.ANY).watchGroup(WatchGroup.ALL).writeActions(Sets.newHashSet(new PortOutAction(new PortNumber(1, null)))).build());
    assertEquals(expectedBuckets, new HashSet<>(buckets));
}
Also used : OFFactoryVer13(org.projectfloodlight.openflow.protocol.ver13.OFFactoryVer13) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) OFGroupDescStatsEntry(org.projectfloodlight.openflow.protocol.OFGroupDescStatsEntry) Builder(org.projectfloodlight.openflow.protocol.OFGroupDescStatsReply.Builder) ArrayList(java.util.ArrayList) GroupSpeakerData(org.openkilda.rulemanager.GroupSpeakerData) GroupId(org.openkilda.model.GroupId) OFBucket(org.projectfloodlight.openflow.protocol.OFBucket) Bucket(org.openkilda.rulemanager.group.Bucket) PortNumber(org.openkilda.rulemanager.ProtoConstants.PortNumber) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 92 with PortOutAction

use of org.openkilda.rulemanager.action.PortOutAction in project open-kilda by telstra.

the class MultiTableIngressYRuleGenerator method buildFlowIngressCommand.

private FlowSpeakerData buildFlowIngressCommand(Switch sw, FlowEndpoint ingressEndpoint) {
    List<Action> actions = new ArrayList<>(buildTransformActions(ingressEndpoint.getInnerVlanId(), sw.getFeatures()));
    actions.add(new PortOutAction(getOutPort(flowPath, flow)));
    FlowSpeakerDataBuilder<?, ?> builder = FlowSpeakerData.builder().switchId(ingressEndpoint.getSwitchId()).ofVersion(OfVersion.of(sw.getOfVersion())).cookie(flowPath.getCookie().toBuilder().yFlow(true).build()).table(OfTable.INGRESS).priority(getPriority(ingressEndpoint)).match(buildIngressMatch(ingressEndpoint, sw.getFeatures())).instructions(buildInstructions(sw, actions));
    if (sw.getFeatures().contains(SwitchFeature.RESET_COUNTS_FLAG)) {
        builder.flags(Sets.newHashSet(OfFlowFlag.RESET_COUNTERS));
    }
    return builder.build();
}
Also used : Action(org.openkilda.rulemanager.action.Action) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) ArrayList(java.util.ArrayList)

Example 93 with PortOutAction

use of org.openkilda.rulemanager.action.PortOutAction in project open-kilda by telstra.

the class SingleTableIngressRuleGenerator method buildFlowIngressCommand.

private FlowSpeakerData buildFlowIngressCommand(Switch sw, FlowEndpoint ingressEndpoint) {
    List<Action> actions = new ArrayList<>();
    Instructions instructions = Instructions.builder().applyActions(actions).build();
    // TODO should we check if switch supports encapsulation?
    actions.addAll(buildTransformActions(ingressEndpoint.getOuterVlanId(), sw.getFeatures()));
    actions.add(new PortOutAction(getOutPort(flowPath, flow)));
    addMeterToInstructions(flowPath.getMeterId(), sw, instructions);
    FlowSpeakerDataBuilder<?, ?> builder = FlowSpeakerData.builder().switchId(ingressEndpoint.getSwitchId()).ofVersion(OfVersion.of(sw.getOfVersion())).cookie(flowPath.getCookie()).table(OfTable.INPUT).priority(isFullPortEndpoint(ingressEndpoint) ? Constants.Priority.DEFAULT_FLOW_PRIORITY : Constants.Priority.FLOW_PRIORITY).match(buildMatch(ingressEndpoint, sw.getFeatures())).instructions(instructions);
    if (sw.getFeatures().contains(SwitchFeature.RESET_COUNTS_FLAG)) {
        builder.flags(Sets.newHashSet(OfFlowFlag.RESET_COUNTERS));
    }
    return builder.build();
}
Also used : Action(org.openkilda.rulemanager.action.Action) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) ArrayList(java.util.ArrayList) Instructions(org.openkilda.rulemanager.Instructions)

Example 94 with PortOutAction

use of org.openkilda.rulemanager.action.PortOutAction in project open-kilda by telstra.

the class FlowLoopTransitRuleGenerator method buildInstructions.

private Instructions buildInstructions(SwitchId switchId) {
    List<Action> applyActions = new ArrayList<>();
    if (FlowEncapsulationType.VXLAN.equals(encapsulation.getType())) {
        // After turning of VXLAN packet we must update eth_dst header because egress rule on the last switch
        // will match the packet by this field.
        applyActions.add(SetFieldAction.builder().field(ETH_SRC).value(switchId.toMacAddressAsLong()).build());
        applyActions.add(SetFieldAction.builder().field(ETH_DST).value(flowPath.getSrcSwitchId().toMacAddressAsLong()).build());
    }
    applyActions.add(new PortOutAction(new PortNumber(SpecialPortType.IN_PORT)));
    return Instructions.builder().applyActions(applyActions).build();
}
Also used : Action(org.openkilda.rulemanager.action.Action) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) SetFieldAction(org.openkilda.rulemanager.action.SetFieldAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) ArrayList(java.util.ArrayList) PortNumber(org.openkilda.rulemanager.ProtoConstants.PortNumber)

Example 95 with PortOutAction

use of org.openkilda.rulemanager.action.PortOutAction in project open-kilda by telstra.

the class RoundTripLatencyRuleGenerator method generateCommands.

@Override
public List<SpeakerData> generateCommands(Switch sw) {
    if (!sw.getFeatures().contains(NOVIFLOW_COPY_FIELD)) {
        return Collections.emptyList();
    }
    Set<FieldMatch> match = roundTripLatencyRuleMatch(sw);
    List<Action> actions = ImmutableList.of(actionAddRxTimestamp(), new PortOutAction(new PortNumber(SpecialPortType.CONTROLLER)));
    Instructions instructions = Instructions.builder().applyActions(actions).build();
    return Collections.singletonList(FlowSpeakerData.builder().switchId(sw.getSwitchId()).ofVersion(OfVersion.of(sw.getOfVersion())).cookie(new Cookie(ROUND_TRIP_LATENCY_RULE_COOKIE)).table(OfTable.INPUT).priority(ROUND_TRIP_LATENCY_RULE_PRIORITY).match(match).instructions(instructions).build());
}
Also used : Cookie(org.openkilda.model.cookie.Cookie) Action(org.openkilda.rulemanager.action.Action) CopyFieldAction(org.openkilda.rulemanager.action.noviflow.CopyFieldAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) FieldMatch(org.openkilda.rulemanager.match.FieldMatch) Instructions(org.openkilda.rulemanager.Instructions) PortNumber(org.openkilda.rulemanager.ProtoConstants.PortNumber)

Aggregations

PortOutAction (org.openkilda.rulemanager.action.PortOutAction)102 Action (org.openkilda.rulemanager.action.Action)80 PortNumber (org.openkilda.rulemanager.ProtoConstants.PortNumber)76 SetFieldAction (org.openkilda.rulemanager.action.SetFieldAction)60 FlowSpeakerData (org.openkilda.rulemanager.FlowSpeakerData)59 SpeakerData (org.openkilda.rulemanager.SpeakerData)56 Test (org.junit.Test)53 PushVlanAction (org.openkilda.rulemanager.action.PushVlanAction)48 FieldMatch (org.openkilda.rulemanager.match.FieldMatch)45 Flow (org.openkilda.model.Flow)40 PopVlanAction (org.openkilda.rulemanager.action.PopVlanAction)40 Instructions (org.openkilda.rulemanager.Instructions)33 PopVxlanAction (org.openkilda.rulemanager.action.PopVxlanAction)30 ArrayList (java.util.ArrayList)27 PushVxlanAction (org.openkilda.rulemanager.action.PushVxlanAction)26 MeterSpeakerData (org.openkilda.rulemanager.MeterSpeakerData)18 Cookie (org.openkilda.model.cookie.Cookie)17 MeterAction (org.openkilda.rulemanager.action.MeterAction)15 FlowPath (org.openkilda.model.FlowPath)14 RoutingMetadata (org.openkilda.rulemanager.utils.RoutingMetadata)14