Search in sources :

Example 66 with Instructions

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

the class Server42FlowRttTurningRuleGenerator method generateCommands.

@Override
public List<SpeakerData> generateCommands(Switch sw) {
    Set<SwitchFeature> features = sw.getFeatures();
    if (!features.contains(NOVIFLOW_SWAP_ETH_SRC_ETH_DST) && !features.contains(KILDA_OVS_SWAP_FIELD)) {
        return Collections.emptyList();
    }
    Set<FieldMatch> match = buildMatch(sw.getSwitchId());
    Instructions instructions = buildInstructions(sw, SERVER_42_FLOW_RTT_REVERSE_UDP_PORT);
    return Collections.singletonList(FlowSpeakerData.builder().switchId(sw.getSwitchId()).ofVersion(OfVersion.of(sw.getOfVersion())).cookie(new Cookie(SERVER_42_FLOW_RTT_TURNING_COOKIE)).table(OfTable.INPUT).priority(SERVER_42_FLOW_RTT_TURNING_PRIORITY).match(match).instructions(instructions).build());
}
Also used : Cookie(org.openkilda.model.cookie.Cookie) FieldMatch(org.openkilda.rulemanager.match.FieldMatch) Instructions(org.openkilda.rulemanager.Instructions) SwitchFeature(org.openkilda.model.SwitchFeature)

Example 67 with Instructions

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

the class MultiTableIngressRuleGeneratorTest method assertPreIngressCommand.

private void assertPreIngressCommand(FlowSpeakerData command, CookieBase cookie, int expectedPriority, Set<FieldMatch> expectedMatch, List<Action> expectedApplyActions, OfMetadata expectedMetadata) {
    assertEquals(SWITCH_1.getSwitchId(), command.getSwitchId());
    assertEquals(SWITCH_1.getOfVersion(), command.getOfVersion().toString());
    assertEquals(cookie, command.getCookie());
    assertEquals(OfTable.PRE_INGRESS, command.getTable());
    assertEquals(expectedPriority, command.getPriority());
    assertTrue(command.getDependsOn().isEmpty());
    assertEqualsMatch(expectedMatch, command.getMatch());
    Instructions expectedInstructions = Instructions.builder().writeMetadata(expectedMetadata).applyActions(expectedApplyActions).goToTable(OfTable.INGRESS).build();
    assertEquals(expectedInstructions, command.getInstructions());
    assertTrue(command.getFlags().isEmpty());
}
Also used : Instructions(org.openkilda.rulemanager.Instructions)

Example 68 with Instructions

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

the class MultiTableServer42IngressRuleGeneratorTest method assertIngressCommand.

private void assertIngressCommand(FlowSpeakerData command, int expectedPriority, Set<FieldMatch> expectedMatch, List<Action> expectedApplyActions) {
    assertEquals(SWITCH_1.getSwitchId(), command.getSwitchId());
    assertEquals(SWITCH_1.getOfVersion(), command.getOfVersion().toString());
    assertEquals(SERVER_42_INGRESS_COOKIE, command.getCookie());
    assertEquals(OfTable.INGRESS, command.getTable());
    assertEquals(expectedPriority, command.getPriority());
    assertEqualsMatch(expectedMatch, command.getMatch());
    Instructions expectedInstructions = Instructions.builder().applyActions(expectedApplyActions).build();
    assertEquals(expectedInstructions, command.getInstructions());
    assertEquals(Sets.newHashSet(OfFlowFlag.RESET_COUNTERS), command.getFlags());
}
Also used : Instructions(org.openkilda.rulemanager.Instructions)

Example 69 with Instructions

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

the class OfInstructionsConverterTest method convertInstructionsTest.

@Test
public void convertInstructionsTest() {
    OFFactory factory = new OFFactoryVer13();
    Instructions instructions = Instructions.builder().goToTable(OfTable.PRE_INGRESS).goToMeter(new MeterId(2)).writeMetadata(new OfMetadata(123, 234)).applyActions(buildActions()).build();
    List<OFInstruction> actual = OfInstructionsConverter.INSTANCE.convertInstructions(instructions, factory);
    assertEquals(4, actual.size());
    assertTrue(actual.contains(factory.instructions().gotoTable(TableId.of(1))));
    assertTrue(actual.contains(factory.instructions().buildMeter().setMeterId(2).build()));
    assertTrue(actual.contains(factory.instructions().buildWriteMetadata().setMetadata(U64.of(123)).setMetadataMask(U64.of(234)).build()));
    OFInstructionApplyActions applyActionsInstruction = (OFInstructionApplyActions) actual.get(3);
    assertEquals(12, applyActionsInstruction.getActions().size());
    List<OFAction> expectedActions = buildActions(factory);
    assertTrue(applyActionsInstruction.getActions().containsAll(expectedActions));
}
Also used : OfMetadata(org.openkilda.rulemanager.OfMetadata) OFInstructionApplyActions(org.projectfloodlight.openflow.protocol.instruction.OFInstructionApplyActions) OFInstruction(org.projectfloodlight.openflow.protocol.instruction.OFInstruction) OFFactoryVer13(org.projectfloodlight.openflow.protocol.ver13.OFFactoryVer13) OFFactory(org.projectfloodlight.openflow.protocol.OFFactory) OFAction(org.projectfloodlight.openflow.protocol.action.OFAction) Instructions(org.openkilda.rulemanager.Instructions) MeterId(org.openkilda.model.MeterId) Test(org.junit.Test)

Example 70 with Instructions

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

the class MultiTableIngressYRuleGenerator method buildInstructions.

private Instructions buildInstructions(Switch sw, List<Action> actions) {
    Instructions instructions = Instructions.builder().applyActions(actions).goToTable(OfTable.POST_INGRESS).build();
    addMeterToInstructions(sharedMeterId, sw, instructions);
    return instructions;
}
Also used : Instructions(org.openkilda.rulemanager.Instructions)

Aggregations

Instructions (org.openkilda.rulemanager.Instructions)84 FieldMatch (org.openkilda.rulemanager.match.FieldMatch)55 PortOutAction (org.openkilda.rulemanager.action.PortOutAction)40 FlowSpeakerData (org.openkilda.rulemanager.FlowSpeakerData)35 Action (org.openkilda.rulemanager.action.Action)34 Cookie (org.openkilda.model.cookie.Cookie)31 SpeakerData (org.openkilda.rulemanager.SpeakerData)29 Test (org.junit.Test)26 PortNumber (org.openkilda.rulemanager.ProtoConstants.PortNumber)25 SetFieldAction (org.openkilda.rulemanager.action.SetFieldAction)24 ArrayList (java.util.ArrayList)14 PortColourCookie (org.openkilda.model.cookie.PortColourCookie)14 RoutingMetadata (org.openkilda.rulemanager.utils.RoutingMetadata)13 Switch (org.openkilda.model.Switch)12 Utils.buildSwitch (org.openkilda.rulemanager.Utils.buildSwitch)12 MeterSpeakerData (org.openkilda.rulemanager.MeterSpeakerData)11 PopVxlanAction (org.openkilda.rulemanager.action.PopVxlanAction)10 MeterAction (org.openkilda.rulemanager.action.MeterAction)9 PushVlanAction (org.openkilda.rulemanager.action.PushVlanAction)9 OfMetadata (org.openkilda.rulemanager.OfMetadata)8