Search in sources :

Example 96 with FlowEndpoint

use of org.openkilda.model.FlowEndpoint in project open-kilda by telstra.

the class EgressRuleGenerator method generateCommands.

@Override
public List<SpeakerData> generateCommands(Switch sw) {
    if (flowPath.isOneSwitchFlow() || flowPath.getSegments().isEmpty()) {
        return new ArrayList<>();
    }
    PathSegment lastSegment = flowPath.getSegments().get(flowPath.getSegments().size() - 1);
    FlowEndpoint endpoint = checkAndBuildEgressEndpoint(flow, flowPath, sw.getSwitchId());
    return Lists.newArrayList(buildEgressCommand(sw, lastSegment.getDestPort(), endpoint));
}
Also used : FlowEndpoint(org.openkilda.model.FlowEndpoint) ArrayList(java.util.ArrayList) PathSegment(org.openkilda.model.PathSegment)

Example 97 with FlowEndpoint

use of org.openkilda.model.FlowEndpoint in project open-kilda by telstra.

the class FlowPathMapper method mapToPathNodes.

/**
 * Convert {@link FlowPath} to {@link PathNodePayload}.
 */
public List<PathNodePayload> mapToPathNodes(FlowPath flowPath) {
    List<PathNodePayload> resultList = new ArrayList<>();
    Flow flow = flowPath.getFlow();
    FlowEndpoint ingress = FlowSideAdapter.makeIngressAdapter(flow, flowPath).getEndpoint();
    FlowEndpoint egress = FlowSideAdapter.makeEgressAdapter(flow, flowPath).getEndpoint();
    List<PathSegment> pathSegments = flowPath.getSegments();
    Iterator<PathSegment> leftIter = pathSegments.iterator();
    Iterator<PathSegment> rightIter = pathSegments.iterator();
    if (!rightIter.hasNext()) {
        resultList.add(new PathNodePayload(flowPath.getSrcSwitchId(), ingress.getPortNumber(), egress.getPortNumber()));
    } else {
        PathSegment left;
        PathSegment right = rightIter.next();
        resultList.add(new PathNodePayload(ingress.getSwitchId(), ingress.getPortNumber(), right.getSrcPort()));
        while (rightIter.hasNext()) {
            left = leftIter.next();
            right = rightIter.next();
            resultList.add(new PathNodePayload(left.getDestSwitchId(), left.getDestPort(), right.getSrcPort()));
        }
        resultList.add(new PathNodePayload(egress.getSwitchId(), right.getDestPort(), egress.getPortNumber()));
    }
    return resultList;
}
Also used : FlowEndpoint(org.openkilda.model.FlowEndpoint) PathNodePayload(org.openkilda.messaging.payload.flow.PathNodePayload) ArrayList(java.util.ArrayList) PathSegment(org.openkilda.model.PathSegment) Flow(org.openkilda.model.Flow)

Example 98 with FlowEndpoint

use of org.openkilda.model.FlowEndpoint in project open-kilda by telstra.

the class EgressFlowSegmentInstallCommandTest method makeCommand.

protected EgressFlowSegmentInstallCommand makeCommand(FlowEndpoint endpoint, FlowEndpoint ingressEndpoint, FlowTransitEncapsulation encapsulation, FlowSegmentMetadata metadata) {
    MessageContext messageContext = new MessageContext();
    UUID commandId = UUID.randomUUID();
    int islPort = 6;
    return new EgressFlowSegmentInstallCommand(messageContext, commandId, metadata, endpoint, ingressEndpoint, islPort, encapsulation, null);
}
Also used : MessageContext(org.openkilda.messaging.MessageContext) UUID(java.util.UUID) FlowEndpoint(org.openkilda.model.FlowEndpoint)

Example 99 with FlowEndpoint

use of org.openkilda.model.FlowEndpoint in project open-kilda by telstra.

the class EgressFlowSegmentRemoveCommandTest method happyPathTransitVlan.

@Test
public void happyPathTransitVlan() throws Exception {
    FlowEndpoint ingressEndpoint = new FlowEndpoint(mapSwitchId(dpId), 1, 0);
    EgressFlowSegmentRemoveCommand command = makeCommand(endpointEgressZeroVlan, ingressEndpoint, encapsulationVlan);
    executeCommand(command, 1);
    OFFlowDeleteStrict expected = of.buildFlowDeleteStrict().setPriority(EgressFlowSegmentRemoveCommand.FLOW_PRIORITY).setCookie(U64.of(command.getCookie().getValue())).setCookieMask(U64.NO_MASK).setMatch(OfAdapter.INSTANCE.matchVlanId(of, of.buildMatch(), command.getEncapsulation().getId()).setExact(MatchField.IN_PORT, OFPort.of(command.getIngressIslPort())).build()).build();
    verifyOfMessageEquals(expected, getWriteRecord(0).getRequest());
}
Also used : OFFlowDeleteStrict(org.projectfloodlight.openflow.protocol.OFFlowDeleteStrict) FlowEndpoint(org.openkilda.model.FlowEndpoint) Test(org.junit.Test)

Example 100 with FlowEndpoint

use of org.openkilda.model.FlowEndpoint in project open-kilda by telstra.

the class EgressFlowSegmentRemoveCommandTest method makeCommand.

@Override
protected EgressFlowSegmentRemoveCommand makeCommand(FlowEndpoint endpoint, FlowEndpoint ingressEndpoint, FlowTransitEncapsulation encapsulation) {
    MessageContext messageContext = new MessageContext();
    UUID commandId = UUID.randomUUID();
    FlowSegmentMetadata metadata = new FlowSegmentMetadata("egress-flow-segment-remove-flow-id", new Cookie(101), false);
    int islPort = 8;
    return new EgressFlowSegmentRemoveCommand(messageContext, commandId, metadata, endpoint, ingressEndpoint, islPort, encapsulation, null);
}
Also used : Cookie(org.openkilda.model.cookie.Cookie) MessageContext(org.openkilda.messaging.MessageContext) UUID(java.util.UUID) FlowSegmentMetadata(org.openkilda.floodlight.model.FlowSegmentMetadata) FlowEndpoint(org.openkilda.model.FlowEndpoint)

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