Search in sources :

Example 26 with RequestedFlow

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

the class RequestedFlowMapperTest method mapRequestedFlowToFlow.

@Test
public void mapRequestedFlowToFlow() {
    RequestedFlow requestedFlow = RequestedFlowMapper.INSTANCE.toRequestedFlow(flowRequest);
    Flow result = RequestedFlowMapper.INSTANCE.toFlow(requestedFlow);
    assertEquals(FLOW_ID, result.getFlowId());
    assertEquals(SRC_SWITCH_ID, result.getSrcSwitchId());
    assertEquals(DST_SWITCH_ID, result.getDestSwitchId());
    assertEquals(SRC_PORT, result.getSrcPort());
    assertEquals(SRC_VLAN, result.getSrcVlan());
    assertEquals(SRC_INNER_VLAN, result.getSrcInnerVlan());
    assertEquals(DST_PORT, result.getDestPort());
    assertEquals(DST_VLAN, result.getDestVlan());
    assertEquals(DST_INNER_VLAN, result.getDestInnerVlan());
    assertNull(result.getForwardPathId());
    assertNull(result.getReversePathId());
    assertTrue(result.isAllocateProtectedPath());
    assertNull(result.getProtectedForwardPathId());
    assertNull(result.getProtectedReversePathId());
    assertNull(result.getDiverseGroupId());
    assertNull(result.getAffinityGroupId());
    assertEquals(BANDWIDTH, result.getBandwidth());
    assertTrue(result.isIgnoreBandwidth());
    assertEquals(DESCRIPTION, result.getDescription());
    assertTrue(result.isPeriodicPings());
    assertEquals(ENCAPSULATION_TYPE, result.getEncapsulationType());
    assertNull(result.getStatus());
    assertEquals(MAX_LATENCY, result.getMaxLatency());
    assertEquals(PRIORITY, result.getPriority());
    assertNull(result.getTimeCreate());
    assertNull(result.getTimeModify());
    assertTrue(result.isPinned());
    assertEquals(new org.openkilda.model.DetectConnectedDevices(true, true, true, true, true, true, true, true), result.getDetectConnectedDevices());
    assertEquals(PATH_COMPUTATION_STRATEGY, result.getPathComputationStrategy());
    assertNull(result.getTargetPathComputationStrategy());
    assertTrue(result.isLooped());
    assertEquals(flow.getSrcSwitchId(), result.getSrcSwitchId());
}
Also used : RequestedFlow(org.openkilda.wfm.topology.flowhs.model.RequestedFlow) Flow(org.openkilda.model.Flow) RequestedFlow(org.openkilda.wfm.topology.flowhs.model.RequestedFlow) Test(org.junit.Test)

Example 27 with RequestedFlow

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

the class RequestedFlowMapperTest method mapFlowRequestToRequestedFlow.

@Test
public void mapFlowRequestToRequestedFlow() {
    RequestedFlow result = RequestedFlowMapper.INSTANCE.toRequestedFlow(flowRequest);
    assertEquals(FLOW_ID, result.getFlowId());
    assertEquals(SRC_SWITCH_ID, result.getSrcSwitch());
    assertEquals(SRC_PORT, result.getSrcPort());
    assertEquals(SRC_VLAN, result.getSrcVlan());
    assertEquals(SRC_INNER_VLAN, result.getSrcInnerVlan());
    assertEquals(DST_SWITCH_ID, result.getDestSwitch());
    assertEquals(DST_PORT, result.getDestPort());
    assertEquals(DST_VLAN, result.getDestVlan());
    assertEquals(DST_INNER_VLAN, result.getDestInnerVlan());
    assertEquals(PRIORITY, result.getPriority());
    assertTrue(result.isPinned());
    assertTrue(result.isAllocateProtectedPath());
    assertEquals(DIVERSE_FLOW_ID, result.getDiverseFlowId());
    assertEquals(DESCRIPTION, result.getDescription());
    assertEquals(BANDWIDTH, result.getBandwidth());
    assertTrue(result.isIgnoreBandwidth());
    assertTrue(result.isPeriodicPings());
    assertEquals(MAX_LATENCY, result.getMaxLatency());
    assertEquals(ENCAPSULATION_TYPE, result.getFlowEncapsulationType());
    assertEquals(PATH_COMPUTATION_STRATEGY, result.getPathComputationStrategy());
    assertEquals(new DetectConnectedDevices(true, true, true, true, true, true, true, true), result.getDetectConnectedDevices());
}
Also used : DetectConnectedDevices(org.openkilda.wfm.topology.flowhs.model.DetectConnectedDevices) RequestedFlow(org.openkilda.wfm.topology.flowhs.model.RequestedFlow) Test(org.junit.Test)

Example 28 with RequestedFlow

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

the class UpdateRequestAction method perform.

@Override
protected void perform(State from, State to, Event event, FlowSwapEndpointsContext context, FlowSwapEndpointsFsm stateMachine) {
    Flow firstOriginalFlow = stateMachine.getFirstOriginalFlow();
    Flow secondOriginalFlow = stateMachine.getSecondOriginalFlow();
    RequestedFlow firstTargetFlow = stateMachine.getFirstTargetFlow();
    RequestedFlow secondTargetFlow = stateMachine.getSecondTargetFlow();
    sendUpdateCommand(firstOriginalFlow, firstTargetFlow, secondTargetFlow.getFlowId(), stateMachine);
    sendUpdateCommand(secondOriginalFlow, secondTargetFlow, firstTargetFlow.getFlowId(), stateMachine);
}
Also used : RequestedFlow(org.openkilda.wfm.topology.flowhs.model.RequestedFlow) Flow(org.openkilda.model.Flow) RequestedFlow(org.openkilda.wfm.topology.flowhs.model.RequestedFlow)

Example 29 with RequestedFlow

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

the class InstallIngressRulesAction method perform.

@Override
protected void perform(State from, State to, Event event, FlowUpdateContext context, FlowUpdateFsm stateMachine) {
    String flowId = stateMachine.getFlowId();
    RequestedFlow requestedFlow = stateMachine.getTargetFlow();
    Flow flow = getFlow(flowId);
    FlowCommandBuilder commandBuilder = commandBuilderFactory.getBuilder(requestedFlow.getFlowEncapsulationType());
    FlowPath newPrimaryForward = getFlowPath(flow, stateMachine.getNewPrimaryForwardPath());
    FlowPath newPrimaryReverse = getFlowPath(flow, stateMachine.getNewPrimaryReversePath());
    SpeakerRequestBuildContext speakerContext = buildBaseSpeakerContextForInstall(newPrimaryForward.getSrcSwitchId(), newPrimaryReverse.getSrcSwitchId());
    Collection<FlowSegmentRequestFactory> commands = new ArrayList<>();
    switch(stateMachine.getEndpointUpdate()) {
        case SOURCE:
            speakerContext.getForward().setUpdateMeter(false);
            commands.addAll(getCommandsForSourceUpdate(commandBuilder, stateMachine, flow, newPrimaryForward, newPrimaryReverse, speakerContext));
            break;
        case DESTINATION:
            speakerContext.getReverse().setUpdateMeter(false);
            commands.addAll(getCommandsForDestinationUpdate(commandBuilder, stateMachine, flow, newPrimaryForward, newPrimaryReverse, speakerContext));
            break;
        case BOTH:
            speakerContext.getForward().setUpdateMeter(false);
            speakerContext.getReverse().setUpdateMeter(false);
            if (stateMachine.getFlowLoopOperation() == FlowLoopOperation.NONE) {
                commands.addAll(commandBuilder.buildIngressOnly(stateMachine.getCommandContext(), flow, newPrimaryForward, newPrimaryReverse, speakerContext));
            } else {
                commands.addAll(commandBuilder.buildIngressOnly(stateMachine.getCommandContext(), flow, newPrimaryForward, newPrimaryReverse, speakerContext).stream().filter(f -> f instanceof IngressFlowLoopSegmentRequestFactory).collect(Collectors.toList()));
            }
            break;
        default:
            commands.addAll(commandBuilder.buildIngressOnly(stateMachine.getCommandContext(), flow, newPrimaryForward, newPrimaryReverse, speakerContext));
            break;
    }
    // Installation of ingress rules for protected paths is skipped. These paths are activated on swap.
    stateMachine.clearPendingAndRetriedAndFailedCommands();
    if (commands.isEmpty()) {
        stateMachine.saveActionToHistory("No need to install ingress rules");
        stateMachine.fire(Event.INGRESS_IS_SKIPPED);
    } else {
        SpeakerInstallSegmentEmitter.INSTANCE.emitBatch(stateMachine.getCarrier(), commands, stateMachine.getIngressCommands());
        stateMachine.getIngressCommands().forEach((key, value) -> stateMachine.addPendingCommand(key, value.getSwitchId()));
        stateMachine.saveActionToHistory("Commands for installing ingress rules have been sent");
    }
}
Also used : FlowSegmentRequestFactory(org.openkilda.floodlight.api.request.factory.FlowSegmentRequestFactory) IngressFlowLoopSegmentRequestFactory(org.openkilda.floodlight.api.request.factory.IngressFlowLoopSegmentRequestFactory) ArrayList(java.util.ArrayList) FlowCommandBuilder(org.openkilda.wfm.topology.flowhs.service.FlowCommandBuilder) RequestedFlow(org.openkilda.wfm.topology.flowhs.model.RequestedFlow) FlowPath(org.openkilda.model.FlowPath) SpeakerRequestBuildContext(org.openkilda.wfm.share.model.SpeakerRequestBuildContext) Flow(org.openkilda.model.Flow) RequestedFlow(org.openkilda.wfm.topology.flowhs.model.RequestedFlow)

Example 30 with RequestedFlow

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

the class RevertFlowAction method revertFlow.

private void revertFlow(Flow flow, FlowUpdateFsm stateMachine) {
    flow.setDiverseGroupId(stateMachine.getOriginalDiverseFlowGroup());
    flow.setAffinityGroupId(stateMachine.getOriginalAffinityFlowGroup());
    RequestedFlow originalFlow = stateMachine.getOriginalFlow();
    Switch srcSwitch = switchRepository.findById(originalFlow.getSrcSwitch()).orElseThrow(() -> new FlowProcessingException(ErrorType.NOT_FOUND, format("Switch %s not found", originalFlow.getSrcSwitch())));
    flow.setSrcSwitch(srcSwitch);
    flow.setSrcPort(originalFlow.getSrcPort());
    flow.setSrcVlan(originalFlow.getSrcVlan());
    Switch destSwitch = switchRepository.findById(originalFlow.getDestSwitch()).orElseThrow(() -> new FlowProcessingException(ErrorType.NOT_FOUND, format("Switch %s not found", originalFlow.getDestSwitch())));
    flow.setDestSwitch(destSwitch);
    flow.setDestPort(originalFlow.getDestPort());
    flow.setDestVlan(originalFlow.getDestVlan());
    flow.setPriority(originalFlow.getPriority());
    flow.setPinned(originalFlow.isPinned());
    flow.setAllocateProtectedPath(originalFlow.isAllocateProtectedPath());
    flow.setDescription(originalFlow.getDescription());
    flow.setBandwidth(originalFlow.getBandwidth());
    flow.setIgnoreBandwidth(originalFlow.isIgnoreBandwidth());
    flow.setMaxLatency(originalFlow.getMaxLatency());
    flow.setPeriodicPings(originalFlow.isPeriodicPings());
    flow.setEncapsulationType(originalFlow.getFlowEncapsulationType());
    flow.setPathComputationStrategy(originalFlow.getPathComputationStrategy());
    flow.setTargetPathComputationStrategy(stateMachine.getOldTargetPathComputationStrategy());
}
Also used : Switch(org.openkilda.model.Switch) FlowProcessingException(org.openkilda.wfm.topology.flowhs.exception.FlowProcessingException) 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