Search in sources :

Example 11 with PortOutAction

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

the class TransitYRuleGeneratorTest method assertTransitCommand.

private void assertTransitCommand(List<SpeakerData> commands, OfTable table, FlowTransitEncapsulation encapsulation) {
    assertEquals(1, commands.size());
    FlowSpeakerData flowCommandData = getCommand(FlowSpeakerData.class, commands);
    assertEquals(SWITCH_1.getSwitchId(), flowCommandData.getSwitchId());
    assertEquals(SWITCH_1.getOfVersion(), flowCommandData.getOfVersion().toString());
    assertTrue(flowCommandData.getDependsOn().contains(SHARED_METER_UUID));
    assertEquals(COOKIE, flowCommandData.getCookie());
    assertEquals(table, flowCommandData.getTable());
    assertEquals(Priority.Y_FLOW_PRIORITY, flowCommandData.getPriority());
    Set<FieldMatch> expectedMatch;
    if (encapsulation.getType().equals(FlowEncapsulationType.TRANSIT_VLAN)) {
        expectedMatch = buildExpectedVlanMatch(PORT_NUMBER_1, encapsulation.getId());
    } else {
        expectedMatch = buildExpectedVxlanMatch(PORT_NUMBER_1, encapsulation.getId());
    }
    assertEqualsMatch(expectedMatch, flowCommandData.getMatch());
    Instructions expectedInstructions = Instructions.builder().applyActions(Lists.newArrayList(new PortOutAction(new PortNumber(PORT_NUMBER_2)))).goToMeter(SHARED_METER_ID).build();
    assertEquals(expectedInstructions, flowCommandData.getInstructions());
    assertEquals(Sets.newHashSet(OfFlowFlag.RESET_COUNTERS), flowCommandData.getFlags());
}
Also used : FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) FieldMatch(org.openkilda.rulemanager.match.FieldMatch) Instructions(org.openkilda.rulemanager.Instructions) PortNumber(org.openkilda.rulemanager.ProtoConstants.PortNumber)

Example 12 with PortOutAction

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

the class SingleTableServer42IngressRuleGenerator method buildIngressInstructions.

private Instructions buildIngressInstructions(Switch sw, int outerVlan) {
    List<Action> applyActions = new ArrayList<>(buildTransformActions(outerVlan, sw.getFeatures()));
    applyActions.add(new PortOutAction(getOutPort(flowPath, flow)));
    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)

Example 13 with PortOutAction

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

the class TransitYRuleGenerator method buildTransitCommand.

private SpeakerData buildTransitCommand(Switch sw, int inPort, int outPort) {
    Instructions instructions = Instructions.builder().applyActions(Lists.newArrayList(new PortOutAction(new PortNumber(outPort)))).build();
    if (sharedMeterId != null && sharedMeterId.getValue() != 0L) {
        addMeterToInstructions(sharedMeterId, sw, instructions);
    }
    FlowSpeakerDataBuilder<?, ?> builder = FlowSpeakerData.builder().switchId(sw.getSwitchId()).ofVersion(OfVersion.of(sw.getOfVersion())).cookie(flowPath.getCookie().toBuilder().yFlow(true).build()).table(multiTable ? OfTable.TRANSIT : OfTable.INPUT).priority(Priority.Y_FLOW_PRIORITY).match(makeTransitMatch(sw, inPort, encapsulation)).instructions(instructions);
    if (sw.getFeatures().contains(SwitchFeature.RESET_COUNTS_FLAG)) {
        builder.flags(Sets.newHashSet(OfFlowFlag.RESET_COUNTERS));
    }
    return builder.build();
}
Also used : PortOutAction(org.openkilda.rulemanager.action.PortOutAction) Instructions(org.openkilda.rulemanager.Instructions) PortNumber(org.openkilda.rulemanager.ProtoConstants.PortNumber)

Example 14 with PortOutAction

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

the class EgressRuleGenerator method buildApplyActions.

private List<Action> buildApplyActions(FlowEndpoint egressEndpoint, Switch sw) {
    List<Action> result = buildTransformActions(egressEndpoint, sw);
    result.add(new PortOutAction(new PortNumber(egressEndpoint.getPortNumber())));
    return result;
}
Also used : Action(org.openkilda.rulemanager.action.Action) PopVxlanAction(org.openkilda.rulemanager.action.PopVxlanAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) PortNumber(org.openkilda.rulemanager.ProtoConstants.PortNumber)

Example 15 with PortOutAction

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

the class MultiTableServer42IngressRuleGenerator method buildIngressInstructions.

private Instructions buildIngressInstructions(Switch sw, int innerVlan) {
    List<Action> applyActions = new ArrayList<>(buildTransformActions(innerVlan, sw.getFeatures()));
    applyActions.add(new PortOutAction(getOutPort(flowPath, flow)));
    return Instructions.builder().applyActions(applyActions).build();
}
Also used : SetFieldAction(org.openkilda.rulemanager.action.SetFieldAction) Action(org.openkilda.rulemanager.action.Action) PopVlanAction(org.openkilda.rulemanager.action.PopVlanAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) ArrayList(java.util.ArrayList)

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