Search in sources :

Example 21 with FlowEndpoint

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;
}
Also used : FlowEndpoint(org.openkilda.model.FlowEndpoint) ArrayList(java.util.ArrayList) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) FlowMirrorPoints(org.openkilda.model.FlowMirrorPoints) PathSegment(org.openkilda.model.PathSegment) SpeakerData(org.openkilda.rulemanager.SpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) GroupSpeakerData(org.openkilda.rulemanager.GroupSpeakerData)

Example 22 with FlowEndpoint

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));
}
Also used : FlowEndpoint(org.openkilda.model.FlowEndpoint) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 23 with FlowEndpoint

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));
}
Also used : FlowEndpoint(org.openkilda.model.FlowEndpoint) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 24 with FlowEndpoint

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());
}
Also used : FlowEndpoint(org.openkilda.model.FlowEndpoint) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 25 with FlowEndpoint

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());
}
Also used : FlowSourceAdapter(org.openkilda.adapter.FlowSourceAdapter) FieldMatch(org.openkilda.rulemanager.match.FieldMatch) RoutingMetadata(org.openkilda.rulemanager.utils.RoutingMetadata) Instructions(org.openkilda.rulemanager.Instructions) PortColourCookie(org.openkilda.model.cookie.PortColourCookie) OfMetadata(org.openkilda.rulemanager.OfMetadata) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) FlowEndpoint(org.openkilda.model.FlowEndpoint) FlowSideAdapter(org.openkilda.adapter.FlowSideAdapter) SpeakerData(org.openkilda.rulemanager.SpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) Test(org.junit.Test)

Aggregations

FlowEndpoint (org.openkilda.model.FlowEndpoint)105 Test (org.junit.Test)26 Flow (org.openkilda.model.Flow)22 ArrayList (java.util.ArrayList)15 RoutingMetadata (org.openkilda.floodlight.utils.metadata.RoutingMetadata)12 YFlow (org.openkilda.model.YFlow)11 FlowPath (org.openkilda.model.FlowPath)10 FlowSpeakerData (org.openkilda.rulemanager.FlowSpeakerData)9 SpeakerData (org.openkilda.rulemanager.SpeakerData)9 SwitchId (org.openkilda.model.SwitchId)8 YSubFlow (org.openkilda.model.YSubFlow)8 HashSet (java.util.HashSet)7 FlowSideAdapter (org.openkilda.adapter.FlowSideAdapter)7 FlowSourceAdapter (org.openkilda.adapter.FlowSourceAdapter)7 IngressFlowSegmentInstallCommand (org.openkilda.floodlight.command.flow.ingress.IngressFlowSegmentInstallCommand)7 EffectiveIds (org.openkilda.floodlight.model.EffectiveIds)7 FlowSegmentWrapperCommand (org.openkilda.floodlight.command.flow.FlowSegmentWrapperCommand)6 FlowProcessingException (org.openkilda.wfm.topology.flowhs.exception.FlowProcessingException)6 OFFlowAdd (org.projectfloodlight.openflow.protocol.OFFlowAdd)6 MessageContext (org.openkilda.messaging.MessageContext)5