use of org.openkilda.model.FlowEndpoint in project open-kilda by telstra.
the class EgressMirrorRuleGenerator method generateCommands.
@Override
public List<SpeakerData> generateCommands(Switch sw) {
List<SpeakerData> result = new ArrayList<>();
if (flowPath.isOneSwitchFlow() || flowPath.getSegments().isEmpty()) {
return result;
}
FlowMirrorPoints mirrorPoints = flowPath.getFlowMirrorPointsSet().stream().filter(points -> sw.getSwitchId().equals(points.getMirrorSwitchId())).findFirst().orElse(null);
if (mirrorPoints == null) {
return result;
}
PathSegment lastSegment = flowPath.getSegments().get(flowPath.getSegments().size() - 1);
FlowEndpoint egressEndpoint = checkAndBuildEgressEndpoint(flow, flowPath, sw.getSwitchId());
SpeakerData egressCommand = buildEgressCommand(sw, lastSegment.getDestPort(), egressEndpoint, mirrorPoints.getMirrorGroupId());
result.add(egressCommand);
SpeakerData groupCommand = buildGroup(sw, mirrorPoints, egressEndpoint.getPortNumber());
result.add(groupCommand);
egressCommand.getDependsOn().add(groupCommand.getUuid());
return result;
}
use of org.openkilda.model.FlowEndpoint in project open-kilda by telstra.
the class MultiTableServer42IngressRuleGeneratorTest method noOverlappingFlowsFullPortFlowTest.
@Test
public void noOverlappingFlowsFullPortFlowTest() {
MultiTableServer42IngressRuleGenerator generator = MultiTableServer42IngressRuleGenerator.builder().overlappingIngressAdapters(new HashSet<>()).build();
FlowEndpoint ingressEndpoint = new FlowEndpoint(SWITCH_ID_1, PORT_NUMBER_1, 0, 0);
assertFalse(generator.needToBuildServer42PreIngressRule(ingressEndpoint));
assertTrue(generator.needToBuildServer42InputRule(ingressEndpoint));
}
use of org.openkilda.model.FlowEndpoint in project open-kilda by telstra.
the class MultiTableServer42IngressRuleGeneratorTest method noOverlappingFlowsTest.
@Test
public void noOverlappingFlowsTest() {
MultiTableServer42IngressRuleGenerator generator = MultiTableServer42IngressRuleGenerator.builder().overlappingIngressAdapters(new HashSet<>()).build();
FlowEndpoint ingressEndpoint = new FlowEndpoint(SWITCH_ID_1, PORT_NUMBER_1, OUTER_VLAN_ID_1, INNER_VLAN_ID_1);
assertTrue(generator.needToBuildServer42PreIngressRule(ingressEndpoint));
assertTrue(generator.needToBuildServer42InputRule(ingressEndpoint));
}
use of org.openkilda.model.FlowEndpoint in project open-kilda by telstra.
the class InputLldpRuleGeneratorTest method buildLldpRuleWithoutLldpTest.
@Test
public void buildLldpRuleWithoutLldpTest() {
FlowEndpoint endpoint = new FlowEndpoint(SW.getSwitchId(), PORT_NUMBER_1, 0, 0, false, false);
InputLldpRuleGenerator generator = InputLldpRuleGenerator.builder().ingressEndpoint(endpoint).multiTable(true).overlappingIngressAdapters(new HashSet<>()).build();
assertEquals(0, generator.generateCommands(SW).size());
}
use of org.openkilda.model.FlowEndpoint 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());
}
Aggregations