Search in sources :

Example 6 with RequestedFlow

use of org.openkilda.wfm.topology.flowhs.model.RequestedFlow in project open-kilda by telstra.

the class RevertNewRulesAction method getSpeakerRequestBuildContextForRemoval.

private SpeakerRequestBuildContext getSpeakerRequestBuildContextForRemoval(FlowUpdateFsm stateMachine, boolean removeMeters) {
    RequestedFlow originalFlow = stateMachine.getOriginalFlow();
    RequestedFlow targetFlow = stateMachine.getTargetFlow();
    return buildSpeakerContextForRemovalIngressAndShared(targetFlow, originalFlow, removeMeters);
}
Also used : RequestedFlow(org.openkilda.wfm.topology.flowhs.model.RequestedFlow)

Example 7 with RequestedFlow

use of org.openkilda.wfm.topology.flowhs.model.RequestedFlow in project open-kilda by telstra.

the class RemoveOldRulesAction method getSpeakerRequestBuildContext.

private SpeakerRequestBuildContext getSpeakerRequestBuildContext(FlowUpdateFsm stateMachine, boolean removeMeters) {
    RequestedFlow originalFlow = stateMachine.getOriginalFlow();
    RequestedFlow targetFlow = stateMachine.getTargetFlow();
    return buildSpeakerContextForRemovalIngressAndShared(originalFlow, targetFlow, removeMeters);
}
Also used : RequestedFlow(org.openkilda.wfm.topology.flowhs.model.RequestedFlow)

Example 8 with RequestedFlow

use of org.openkilda.wfm.topology.flowhs.model.RequestedFlow in project open-kilda by telstra.

the class OnFinishedAction method updateFlowMonitoring.

private void updateFlowMonitoring(FlowUpdateFsm stateMachine) {
    // If was single flow do nothing
    RequestedFlow original = stateMachine.getOriginalFlow();
    RequestedFlow target = stateMachine.getTargetFlow();
    boolean originalNotSingle = !original.getSrcSwitch().equals(original.getDestSwitch());
    boolean targetNotSingle = !target.getSrcSwitch().equals(target.getDestSwitch());
    boolean srcUpdated = !(original.getSrcSwitch().equals(target.getSrcSwitch()) && original.getSrcPort() == target.getSrcPort() && original.getSrcVlan() == target.getSrcVlan() && original.getSrcInnerVlan() == target.getSrcInnerVlan());
    boolean dstUpdated = !(original.getDestSwitch().equals(target.getDestSwitch()) && original.getDestPort() == target.getDestPort() && original.getDestVlan() == target.getDestVlan() && original.getDestInnerVlan() == target.getDestInnerVlan());
    // clean up old if old not single
    if (originalNotSingle && (srcUpdated || dstUpdated)) {
        stateMachine.getCarrier().sendDeactivateFlowMonitoring(stateMachine.getFlowId(), original.getSrcSwitch(), original.getDestSwitch());
    }
    // setup new if new not single
    if (targetNotSingle && (srcUpdated || dstUpdated)) {
        stateMachine.getCarrier().sendActivateFlowMonitoring(target);
    }
}
Also used : RequestedFlow(org.openkilda.wfm.topology.flowhs.model.RequestedFlow)

Example 9 with RequestedFlow

use of org.openkilda.wfm.topology.flowhs.model.RequestedFlow in project open-kilda by telstra.

the class OnFinishedAction method sendPeriodicPingNotification.

private void sendPeriodicPingNotification(FlowUpdateFsm stateMachine) {
    RequestedFlow requestedFlow = stateMachine.getTargetFlow();
    stateMachine.getCarrier().sendPeriodicPingNotification(requestedFlow.getFlowId(), requestedFlow.isPeriodicPings());
}
Also used : RequestedFlow(org.openkilda.wfm.topology.flowhs.model.RequestedFlow)

Example 10 with RequestedFlow

use of org.openkilda.wfm.topology.flowhs.model.RequestedFlow in project open-kilda by telstra.

the class ValidateFlowsAction method perform.

@Override
protected void perform(State from, State to, Event event, FlowSwapEndpointsContext context, FlowSwapEndpointsFsm stateMachine) {
    RequestedFlow firstTargetFlow = stateMachine.getFirstTargetFlow();
    RequestedFlow secondTargetFlow = stateMachine.getSecondTargetFlow();
    if (!featureTogglesRepository.getOrDefault().getUpdateFlowEnabled()) {
        throw new FlowProcessingException(ErrorType.NOT_PERMITTED, "Flow update feature is disabled");
    }
    try {
        flowValidator.validateForSwapEndpoints(firstTargetFlow, secondTargetFlow);
    } catch (InvalidFlowException e) {
        stateMachine.fireValidationError(new ErrorData(e.getType(), FlowSwapEndpointsFsm.GENERIC_ERROR_MESSAGE, e.getMessage()));
        return;
    } catch (UnavailableFlowEndpointException e) {
        stateMachine.fireValidationError(new ErrorData(ErrorType.DATA_INVALID, FlowSwapEndpointsFsm.GENERIC_ERROR_MESSAGE, e.getMessage()));
        return;
    }
    try {
        transactionManager.doInTransaction(() -> {
            Flow foundFirstFlow = checkAndGetFlow(stateMachine.getFirstFlowId());
            Flow foundSecondFlow = checkAndGetFlow(stateMachine.getSecondFlowId());
            stateMachine.setFirstOriginalFlow(foundFirstFlow);
            stateMachine.setSecondOriginalFlow(foundSecondFlow);
            foundFirstFlow.setStatus(FlowStatus.IN_PROGRESS);
            foundSecondFlow.setStatus(FlowStatus.IN_PROGRESS);
        });
    } catch (FlowProcessingException e) {
        stateMachine.fireValidationError(new ErrorData(e.getErrorType(), FlowSwapEndpointsFsm.GENERIC_ERROR_MESSAGE, e.getMessage()));
        return;
    }
    stateMachine.saveNewEventToHistory(stateMachine.getFirstFlowId(), format("Current flow and flow %s were validated successfully", stateMachine.getSecondFlowId()), FlowEventData.Event.SWAP_ENDPOINTS);
    stateMachine.saveNewEventToHistory(stateMachine.getSecondFlowId(), format("Current flow and flow %s were validated successfully", stateMachine.getFirstFlowId()), FlowEventData.Event.SWAP_ENDPOINTS);
    stateMachine.fireNext();
}
Also used : UnavailableFlowEndpointException(org.openkilda.wfm.topology.flowhs.validation.UnavailableFlowEndpointException) FlowProcessingException(org.openkilda.wfm.topology.flowhs.exception.FlowProcessingException) RequestedFlow(org.openkilda.wfm.topology.flowhs.model.RequestedFlow) InvalidFlowException(org.openkilda.wfm.topology.flowhs.validation.InvalidFlowException) ErrorData(org.openkilda.messaging.error.ErrorData) Flow(org.openkilda.model.Flow) RequestedFlow(org.openkilda.wfm.topology.flowhs.model.RequestedFlow)

Aggregations

RequestedFlow (org.openkilda.wfm.topology.flowhs.model.RequestedFlow)34 Flow (org.openkilda.model.Flow)12 Test (org.junit.Test)10 DetectConnectedDevices (org.openkilda.wfm.topology.flowhs.model.DetectConnectedDevices)8 YFlow (org.openkilda.model.YFlow)4 YSubFlow (org.openkilda.model.YSubFlow)4 FlowProcessingException (org.openkilda.wfm.topology.flowhs.exception.FlowProcessingException)4 FlowPath (org.openkilda.model.FlowPath)3 InvalidFlowException (org.openkilda.wfm.topology.flowhs.validation.InvalidFlowException)3 UnavailableFlowEndpointException (org.openkilda.wfm.topology.flowhs.validation.UnavailableFlowEndpointException)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 ArrayList (java.util.ArrayList)2 Collection (java.util.Collection)2 FlowSegmentRequestFactory (org.openkilda.floodlight.api.request.factory.FlowSegmentRequestFactory)2 Switch (org.openkilda.model.Switch)2 CommandContext (org.openkilda.wfm.CommandContext)2 FlowCommandBuilder (org.openkilda.wfm.topology.flowhs.service.FlowCommandBuilder)2 Sets (com.google.common.collect.Sets)1 String.format (java.lang.String.format)1 HashSet (java.util.HashSet)1