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