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());
}
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());
}
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());
}
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());
}
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());
}
Aggregations