Search in sources :

Example 56 with Instructions

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

the class TablePassThroughDefaultRuleGeneratorTest method shouldBuildCorrectRuleForOf13.

@Test
public void shouldBuildCorrectRuleForOf13() {
    Switch sw = buildSwitch("OF_13", Collections.emptySet());
    TablePassThroughDefaultRuleGenerator generator = TablePassThroughDefaultRuleGenerator.builder().cookie(new Cookie(MULTITABLE_EGRESS_PASS_THROUGH_COOKIE)).tableId(OfTable.EGRESS).goToTableId(OfTable.TRANSIT).build();
    List<SpeakerData> commands = generator.generateCommands(sw);
    assertEquals(1, commands.size());
    FlowSpeakerData flowCommandData = getCommand(FlowSpeakerData.class, commands);
    assertEquals(sw.getSwitchId(), flowCommandData.getSwitchId());
    assertEquals(sw.getOfVersion(), flowCommandData.getOfVersion().toString());
    assertTrue(flowCommandData.getDependsOn().isEmpty());
    assertEquals(new Cookie(MULTITABLE_EGRESS_PASS_THROUGH_COOKIE), flowCommandData.getCookie());
    assertEquals(OfTable.EGRESS, flowCommandData.getTable());
    assertEquals(MINIMAL_POSITIVE_PRIORITY, flowCommandData.getPriority());
    assertTrue(flowCommandData.getMatch().isEmpty());
    Instructions instructions = flowCommandData.getInstructions();
    assertNull(instructions.getApplyActions());
    assertNull(instructions.getWriteActions());
    assertNull(instructions.getGoToMeter());
    assertEquals(OfTable.TRANSIT, instructions.getGoToTable());
}
Also used : Cookie(org.openkilda.model.cookie.Cookie) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) Switch(org.openkilda.model.Switch) Utils.buildSwitch(org.openkilda.rulemanager.Utils.buildSwitch) Instructions(org.openkilda.rulemanager.Instructions) SpeakerData(org.openkilda.rulemanager.SpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) Test(org.junit.Test)

Example 57 with Instructions

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

the class SingleTableIngressYRuleGeneratorTest method assertIngressCommand.

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

Example 58 with Instructions

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

the class Server42IslRttTurningRuleGenerator method generateCommands.

@Override
public List<SpeakerData> generateCommands(Switch sw) {
    Set<FieldMatch> match = buildMatch(new MacAddress(config.getServer42IslRttMagicMacAddress()));
    List<Action> actions = new ArrayList<>();
    actions.add(SetFieldAction.builder().field(UDP_SRC).value(SERVER_42_ISL_RTT_REVERSE_UDP_PORT).build());
    actions.add(new PortOutAction(new PortNumber(SpecialPortType.IN_PORT)));
    Instructions instructions = Instructions.builder().applyActions(actions).build();
    return Collections.singletonList(FlowSpeakerData.builder().switchId(sw.getSwitchId()).ofVersion(OfVersion.of(sw.getOfVersion())).cookie(new Cookie(SERVER_42_ISL_RTT_TURNING_COOKIE)).table(OfTable.INPUT).priority(SERVER_42_ISL_RTT_TURNING_PRIORITY).match(match).instructions(instructions).build());
}
Also used : Cookie(org.openkilda.model.cookie.Cookie) Action(org.openkilda.rulemanager.action.Action) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) SetFieldAction(org.openkilda.rulemanager.action.SetFieldAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) FieldMatch(org.openkilda.rulemanager.match.FieldMatch) ArrayList(java.util.ArrayList) Instructions(org.openkilda.rulemanager.Instructions) MacAddress(org.openkilda.model.MacAddress) PortNumber(org.openkilda.rulemanager.ProtoConstants.PortNumber)

Example 59 with Instructions

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

the class EgressRuleGeneratorTest method assertEgressCommands.

private void assertEgressCommands(List<SpeakerData> commands, OfTable table, FlowTransitEncapsulation encapsulation, List<Action> expectedApplyActions) {
    assertEquals(1, commands.size());
    FlowSpeakerData flowCommandData = getCommand(FlowSpeakerData.class, commands);
    assertEquals(SWITCH_2.getSwitchId(), flowCommandData.getSwitchId());
    assertEquals(SWITCH_2.getOfVersion(), flowCommandData.getOfVersion().toString());
    assertTrue(flowCommandData.getDependsOn().isEmpty());
    assertEquals(COOKIE, flowCommandData.getCookie());
    assertEquals(table, flowCommandData.getTable());
    assertEquals(Priority.FLOW_PRIORITY, flowCommandData.getPriority());
    Set<FieldMatch> expectedMatch;
    if (encapsulation.getType().equals(FlowEncapsulationType.TRANSIT_VLAN)) {
        expectedMatch = buildExpectedVlanMatch(PORT_NUMBER_3, encapsulation.getId());
    } else {
        expectedMatch = buildExpectedVxlanMatch(PORT_NUMBER_3, encapsulation.getId());
    }
    assertEqualsMatch(expectedMatch, flowCommandData.getMatch());
    Instructions expectedInstructions = Instructions.builder().applyActions(expectedApplyActions).build();
    assertEquals(expectedInstructions, flowCommandData.getInstructions());
    assertTrue(flowCommandData.getFlags().isEmpty());
}
Also used : FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) FieldMatch(org.openkilda.rulemanager.match.FieldMatch) Instructions(org.openkilda.rulemanager.Instructions)

Example 60 with Instructions

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

the class MultiTableIngressRuleGeneratorTest method assertIngressCommand.

private void assertIngressCommand(FlowSpeakerData command, int expectedPriority, Set<FieldMatch> expectedMatch, List<Action> expectedApplyActions, MeterId expectedMeter, OfMetadata expectedMetadata) {
    assertEquals(SWITCH_1.getSwitchId(), command.getSwitchId());
    assertEquals(SWITCH_1.getOfVersion(), command.getOfVersion().toString());
    assertEquals(COOKIE, command.getCookie());
    assertEquals(OfTable.INGRESS, command.getTable());
    assertEquals(expectedPriority, command.getPriority());
    assertEqualsMatch(expectedMatch, command.getMatch());
    Instructions expectedInstructions = Instructions.builder().applyActions(expectedApplyActions).goToTable(OfTable.POST_INGRESS).goToMeter(expectedMeter).writeMetadata(expectedMetadata).build();
    assertEquals(expectedInstructions, command.getInstructions());
    assertEquals(Sets.newHashSet(OfFlowFlag.RESET_COUNTERS), command.getFlags());
}
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