use of org.openkilda.rulemanager.Instructions in project open-kilda by telstra.
the class LldpTransitRuleGenerator method generateCommands.
@Override
public List<SpeakerData> generateCommands(Switch sw) {
Set<FieldMatch> match = Sets.newHashSet(FieldMatch.builder().field(Field.ETH_TYPE).value(EthType.LLDP).build());
Instructions instructions = buildSendToControllerInstructions();
Cookie cookie = new Cookie(LLDP_TRANSIT_COOKIE);
return buildCommands(sw, cookie, OfTable.TRANSIT, Priority.LLDP_TRANSIT_ISL_PRIORITY, match, instructions);
}
use of org.openkilda.rulemanager.Instructions in project open-kilda by telstra.
the class Server42IslRttInputRuleGenerator method generateCommands.
@Override
public List<SpeakerData> generateCommands(Switch sw) {
int udpOffset = config.getServer42IslRttUdpPortOffset();
Set<FieldMatch> match = buildMatch(server42Port, udpOffset + islPort, sw.getSwitchId());
long ethDst = new SwitchId(config.getServer42IslRttMagicMacAddress()).toLong();
List<Action> actions = Lists.newArrayList(SetFieldAction.builder().field(Field.UDP_SRC).value(SERVER_42_ISL_RTT_FORWARD_UDP_PORT).build(), SetFieldAction.builder().field(Field.ETH_DST).value(ethDst).build(), new PortOutAction(new PortNumber(islPort)));
Instructions instructions = Instructions.builder().applyActions(actions).build();
return Collections.singletonList(FlowSpeakerData.builder().switchId(sw.getSwitchId()).ofVersion(OfVersion.of(sw.getOfVersion())).cookie(new Cookie(encodeServer42IslRttInput(islPort))).table(OfTable.INPUT).priority(SERVER_42_ISL_RTT_INPUT_PRIORITY).match(match).instructions(instructions).build());
}
use of org.openkilda.rulemanager.Instructions in project open-kilda by telstra.
the class MultiTableIngressYRuleGeneratorTest 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());
}
use of org.openkilda.rulemanager.Instructions in project open-kilda by telstra.
the class InputLldpRuleGeneratorTest method buildCorrectRuleForOf13Test.
@Test
public void buildCorrectRuleForOf13Test() {
FlowEndpoint endpoint = new FlowEndpoint(SW.getSwitchId(), PORT_NUMBER_1, 0, 0, true, false);
FlowSideAdapter overlapAdapter = new FlowSourceAdapter(Flow.builder().flowId("some").srcSwitch(SW).destSwitch(buildSwitch("OF_13", Collections.emptySet())).detectConnectedDevices(DetectConnectedDevices.builder().srcLldp(false).srcSwitchLldp(false).build()).build());
InputLldpRuleGenerator generator = InputLldpRuleGenerator.builder().ingressEndpoint(endpoint).multiTable(true).overlappingIngressAdapters(Sets.newHashSet(overlapAdapter)).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 PortColourCookie(CookieType.LLDP_INPUT_CUSTOMER_TYPE, PORT_NUMBER_1), flowCommandData.getCookie());
assertEquals(OfTable.INPUT, flowCommandData.getTable());
assertEquals(Priority.LLDP_INPUT_CUSTOMER_PRIORITY, flowCommandData.getPriority());
Set<FieldMatch> expectedMatch = Sets.newHashSet(FieldMatch.builder().field(Field.IN_PORT).value(PORT_NUMBER_1).build(), FieldMatch.builder().field(Field.ETH_TYPE).value(EthType.LLDP).build());
assertEqualsMatch(expectedMatch, flowCommandData.getMatch());
RoutingMetadata metadata = RoutingMetadata.builder().lldpFlag(true).build(SW.getFeatures());
Instructions expectedInstructions = Instructions.builder().writeMetadata(new OfMetadata(metadata.getValue(), metadata.getMask())).goToTable(OfTable.PRE_INGRESS).build();
assertEquals(expectedInstructions, flowCommandData.getInstructions());
assertTrue(flowCommandData.getFlags().isEmpty());
}
use of org.openkilda.rulemanager.Instructions in project open-kilda by telstra.
the class TransitYRuleGeneratorTest method assertTransitCommands.
private void assertTransitCommands(List<SpeakerData> commands, OfTable table, FlowTransitEncapsulation encapsulation) {
assertEquals(2, commands.size());
MeterSpeakerData meterCommandData = getCommand(MeterSpeakerData.class, commands);
FlowSpeakerData flowCommandData = getCommand(FlowSpeakerData.class, commands);
assertEquals(SWITCH_1.getSwitchId(), flowCommandData.getSwitchId());
assertEquals(SWITCH_1.getOfVersion(), flowCommandData.getOfVersion().toString());
assertTrue(flowCommandData.getDependsOn().contains(meterCommandData.getUuid()));
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());
}
Aggregations