Search in sources :

Example 21 with FlowSegmentRequestFactory

use of org.openkilda.floodlight.api.request.factory.FlowSegmentRequestFactory in project open-kilda by telstra.

the class SpeakerFlowSegmentRequestBuilder method makeLoopRequests.

private List<FlowSegmentRequestFactory> makeLoopRequests(CommandContext context, FlowPath path, FlowTransitEncapsulation encapsulation, FlowSideAdapter ingressSide, FlowSideAdapter egressSide, PathSegment segment) {
    List<FlowSegmentRequestFactory> result = new ArrayList<>(2);
    PathSegmentSide segmentSide = makePathSegmentSourceSide(segment);
    UUID commandId = commandIdGenerator.generate();
    MessageContext messageContext = new MessageContext(commandId.toString(), context.getCorrelationId());
    FlowSegmentCookie cookie = path.getCookie().toBuilder().looped(true).build();
    result.add(IngressFlowLoopSegmentRequestFactory.builder().messageContext(messageContext).metadata(makeMetadata(path.getFlow().getFlowId(), cookie, segmentSide.isMultiTable())).endpoint(ingressSide.getEndpoint()).build());
    FlowPathDirection reverse = cookie.getDirection() == FlowPathDirection.FORWARD ? FlowPathDirection.REVERSE : FlowPathDirection.FORWARD;
    Cookie transitCookie = path.getCookie().toBuilder().looped(true).direction(reverse).build();
    result.add(TransitFlowLoopSegmentRequestFactory.builder().messageContext(messageContext).switchId(segment.getSrcSwitch().getSwitchId()).egressSwitchId(egressSide.getEndpoint().getSwitchId()).metadata(makeMetadata(path.getFlow().getFlowId(), transitCookie, segmentSide.isMultiTable())).port(segment.getSrcPort()).encapsulation(encapsulation).build());
    return result;
}
Also used : Cookie(org.openkilda.model.cookie.Cookie) FlowSegmentCookie(org.openkilda.model.cookie.FlowSegmentCookie) IngressMirrorFlowSegmentRequestFactory(org.openkilda.floodlight.api.request.factory.IngressMirrorFlowSegmentRequestFactory) IngressFlowSegmentRequestFactory(org.openkilda.floodlight.api.request.factory.IngressFlowSegmentRequestFactory) EgressMirrorFlowSegmentRequestFactory(org.openkilda.floodlight.api.request.factory.EgressMirrorFlowSegmentRequestFactory) EgressFlowSegmentRequestFactory(org.openkilda.floodlight.api.request.factory.EgressFlowSegmentRequestFactory) TransitFlowSegmentRequestFactory(org.openkilda.floodlight.api.request.factory.TransitFlowSegmentRequestFactory) FlowSegmentRequestFactory(org.openkilda.floodlight.api.request.factory.FlowSegmentRequestFactory) FlowSegmentCookie(org.openkilda.model.cookie.FlowSegmentCookie) ArrayList(java.util.ArrayList) MessageContext(org.openkilda.messaging.MessageContext) UUID(java.util.UUID) FlowPathDirection(org.openkilda.model.FlowPathDirection)

Example 22 with FlowSegmentRequestFactory

use of org.openkilda.floodlight.api.request.factory.FlowSegmentRequestFactory in project open-kilda by telstra.

the class SpeakerFlowSegmentRequestBuilder method makeIngressSegmentRequests.

private List<FlowSegmentRequestFactory> makeIngressSegmentRequests(CommandContext context, FlowPath path, FlowTransitEncapsulation encapsulation, FlowSideAdapter flowSide, PathSegment segment, FlowSideAdapter egressFlowSide, RulesContext rulesContext, MirrorContext mirrorContext) {
    PathSegmentSide segmentSide = makePathSegmentSourceSide(segment);
    UUID commandId = commandIdGenerator.generate();
    MessageContext messageContext = new MessageContext(commandId.toString(), context.getCorrelationId());
    FlowSegmentMetadata metadata = makeMetadata(path, ensureEqualMultiTableFlag(path.isSrcWithMultiTable(), segmentSide.isMultiTable(), String.format("First flow(id:%s, path:%s) segment and flow path level multi-table flag values " + "are incompatible to each other - flow path(%s) != segment(%s)", path.getFlow().getFlowId(), path.getPathId(), path.isSrcWithMultiTable(), segmentSide.isMultiTable())));
    List<FlowSegmentRequestFactory> ingressFactories = new ArrayList<>();
    if (!mirrorContext.isBuildMirrorFactoryOnly()) {
        ingressFactories.add(IngressFlowSegmentRequestFactory.builder().messageContext(messageContext).metadata(metadata).endpoint(flowSide.getEndpoint()).meterConfig(getMeterConfig(path)).egressSwitchId(egressFlowSide.getEndpoint().getSwitchId()).islPort(segmentSide.getEndpoint().getPortNumber()).encapsulation(encapsulation).rulesContext(rulesContext).build());
    }
    Optional<MirrorConfig> mirrorConfig = makeMirrorConfig(path, segmentSide.getEndpoint(), mirrorContext);
    if (mirrorConfig.isPresent() || mirrorContext.isRemoveFlowOperation()) {
        FlowSegmentCookie mirrorCookie = path.getCookie().toBuilder().mirror(true).build();
        ingressFactories.add(IngressMirrorFlowSegmentRequestFactory.builder().messageContext(new MessageContext(commandIdGenerator.generate().toString(), context.getCorrelationId())).metadata(makeMetadata(metadata.getFlowId(), mirrorCookie, metadata.isMultiTable())).endpoint(flowSide.getEndpoint()).meterConfig(getMeterConfig(path)).egressSwitchId(egressFlowSide.getEndpoint().getSwitchId()).islPort(segmentSide.getEndpoint().getPortNumber()).encapsulation(encapsulation).rulesContext(rulesContext.toBuilder().updateMeter(false).installServer42IngressRule(false).installServer42InputRule(false).installServer42OuterVlanMatchSharedRule(false).build()).mirrorConfig(mirrorConfig.orElse(null)).build());
    }
    return ingressFactories;
}
Also used : IngressMirrorFlowSegmentRequestFactory(org.openkilda.floodlight.api.request.factory.IngressMirrorFlowSegmentRequestFactory) IngressFlowSegmentRequestFactory(org.openkilda.floodlight.api.request.factory.IngressFlowSegmentRequestFactory) EgressMirrorFlowSegmentRequestFactory(org.openkilda.floodlight.api.request.factory.EgressMirrorFlowSegmentRequestFactory) EgressFlowSegmentRequestFactory(org.openkilda.floodlight.api.request.factory.EgressFlowSegmentRequestFactory) TransitFlowSegmentRequestFactory(org.openkilda.floodlight.api.request.factory.TransitFlowSegmentRequestFactory) FlowSegmentRequestFactory(org.openkilda.floodlight.api.request.factory.FlowSegmentRequestFactory) FlowSegmentCookie(org.openkilda.model.cookie.FlowSegmentCookie) MirrorConfig(org.openkilda.model.MirrorConfig) ArrayList(java.util.ArrayList) MessageContext(org.openkilda.messaging.MessageContext) UUID(java.util.UUID) FlowSegmentMetadata(org.openkilda.floodlight.model.FlowSegmentMetadata)

Example 23 with FlowSegmentRequestFactory

use of org.openkilda.floodlight.api.request.factory.FlowSegmentRequestFactory in project open-kilda by telstra.

the class ResourcesAllocationAction method createSpeakerRequestFactories.

private void createSpeakerRequestFactories(FlowCreateFsm stateMachine, Flow flow) {
    final FlowCommandBuilder commandBuilder = commandBuilderFactory.getBuilder(flow.getEncapsulationType());
    final CommandContext commandContext = stateMachine.getCommandContext();
    List<FlowSegmentRequestFactory> requestFactories;
    // ingress
    requestFactories = stateMachine.getIngressCommands();
    SpeakerRequestBuildContext buildContext = buildBaseSpeakerContextForInstall(flow.getSrcSwitchId(), flow.getDestSwitchId());
    requestFactories.addAll(commandBuilder.buildIngressOnly(stateMachine.getCommandContext(), flow, buildContext));
    // non ingress
    requestFactories = stateMachine.getNonIngressCommands();
    requestFactories.addAll(commandBuilder.buildAllExceptIngress(commandContext, flow));
    if (flow.isAllocateProtectedPath()) {
        requestFactories.addAll(commandBuilder.buildAllExceptIngress(commandContext, flow, flow.getProtectedForwardPath(), flow.getProtectedReversePath()));
    }
}
Also used : FlowSegmentRequestFactory(org.openkilda.floodlight.api.request.factory.FlowSegmentRequestFactory) CommandContext(org.openkilda.wfm.CommandContext) FlowCommandBuilder(org.openkilda.wfm.topology.flowhs.service.FlowCommandBuilder) SpeakerRequestBuildContext(org.openkilda.wfm.share.model.SpeakerRequestBuildContext)

Example 24 with FlowSegmentRequestFactory

use of org.openkilda.floodlight.api.request.factory.FlowSegmentRequestFactory in project open-kilda by telstra.

the class RollbackInstalledRulesAction method perform.

@Override
protected void perform(State from, State to, Event event, FlowCreateContext context, FlowCreateFsm stateMachine) {
    stateMachine.getPendingCommands().clear();
    stateMachine.getFailedCommands().clear();
    Map<UUID, SpeakerCommandObserver> pendingRequests = stateMachine.getPendingCommands();
    for (FlowSegmentRequestFactory factory : stateMachine.getSentCommands()) {
        FlowSegmentRequest request = factory.makeRemoveRequest(commandIdGenerator.generate());
        SpeakerCommandObserver commandObserver = new SpeakerCommandObserver(speakerCommandFsmBuilder, request);
        commandObserver.start();
        // TODO ensure no conflicts
        pendingRequests.put(request.getCommandId(), commandObserver);
    }
    stateMachine.saveActionToHistory(String.format("Commands to rollback installed rules have been sent. Total amount: %s", pendingRequests.size()));
}
Also used : FlowSegmentRequestFactory(org.openkilda.floodlight.api.request.factory.FlowSegmentRequestFactory) FlowSegmentRequest(org.openkilda.floodlight.api.request.FlowSegmentRequest) SpeakerCommandObserver(org.openkilda.wfm.topology.flowhs.service.SpeakerCommandObserver) UUID(java.util.UUID)

Example 25 with FlowSegmentRequestFactory

use of org.openkilda.floodlight.api.request.factory.FlowSegmentRequestFactory in project open-kilda by telstra.

the class HandleNotCompletedCommandsAction method perform.

@Override
public void perform(State from, State to, Event event, FlowDeleteContext context, FlowDeleteFsm stateMachine) {
    for (UUID commandId : stateMachine.getPendingCommands()) {
        FlowSegmentRequestFactory notCompletedCommand = stateMachine.getRemoveCommands().get(commandId);
        if (notCompletedCommand != null) {
            stateMachine.saveErrorToHistory("Command is not finished yet", format("Completing the removal operation although the command may not be finished yet: " + "commandId %s, switch %s, cookie %s", commandId, notCompletedCommand.getSwitchId(), notCompletedCommand.getCookie()));
        }
    }
    log.debug("Abandoning all pending commands: {}", stateMachine.getPendingCommands());
    stateMachine.clearPendingCommands();
}
Also used : FlowSegmentRequestFactory(org.openkilda.floodlight.api.request.factory.FlowSegmentRequestFactory) UUID(java.util.UUID)

Aggregations

FlowSegmentRequestFactory (org.openkilda.floodlight.api.request.factory.FlowSegmentRequestFactory)53 UUID (java.util.UUID)33 Flow (org.openkilda.model.Flow)21 ArrayList (java.util.ArrayList)19 FlowErrorResponse (org.openkilda.floodlight.flow.response.FlowErrorResponse)15 SpeakerFlowSegmentResponse (org.openkilda.floodlight.api.response.SpeakerFlowSegmentResponse)14 FlowCommandBuilder (org.openkilda.wfm.topology.flowhs.service.FlowCommandBuilder)14 FlowPath (org.openkilda.model.FlowPath)12 IngressFlowSegmentRequestFactory (org.openkilda.floodlight.api.request.factory.IngressFlowSegmentRequestFactory)11 SpeakerRequestBuildContext (org.openkilda.wfm.share.model.SpeakerRequestBuildContext)11 FlowSegmentRequest (org.openkilda.floodlight.api.request.FlowSegmentRequest)9 EgressMirrorFlowSegmentRequestFactory (org.openkilda.floodlight.api.request.factory.EgressMirrorFlowSegmentRequestFactory)7 EgressFlowSegmentRequestFactory (org.openkilda.floodlight.api.request.factory.EgressFlowSegmentRequestFactory)6 IngressMirrorFlowSegmentRequestFactory (org.openkilda.floodlight.api.request.factory.IngressMirrorFlowSegmentRequestFactory)6 TransitFlowSegmentRequestFactory (org.openkilda.floodlight.api.request.factory.TransitFlowSegmentRequestFactory)6 Switch (org.openkilda.model.Switch)5 FlowSegmentCookie (org.openkilda.model.cookie.FlowSegmentCookie)5 MirrorContext (org.openkilda.wfm.share.model.MirrorContext)5 Test (org.junit.Test)4 SpeakerResponse (org.openkilda.floodlight.api.response.SpeakerResponse)4