Search in sources :

Example 31 with RequestedFlow

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

the class InstallNonIngressRulesAction 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());
    // primary path
    FlowPath newPrimaryForward = getFlowPath(flow, stateMachine.getNewPrimaryForwardPath());
    FlowPath newPrimaryReverse = getFlowPath(flow, stateMachine.getNewPrimaryReversePath());
    Collection<FlowSegmentRequestFactory> commands = buildCommands(commandBuilder, stateMachine, flow, newPrimaryForward, newPrimaryReverse);
    // protected path
    if (stateMachine.getNewProtectedForwardPath() != null && stateMachine.getNewProtectedReversePath() != null) {
        FlowPath newProtectedForward = getFlowPath(flow, stateMachine.getNewProtectedForwardPath());
        FlowPath newProtectedReverse = getFlowPath(flow, stateMachine.getNewProtectedReversePath());
        commands.addAll(buildCommands(commandBuilder, stateMachine, flow, newProtectedForward, newProtectedReverse));
    }
    stateMachine.clearPendingAndRetriedAndFailedCommands();
    if (commands.isEmpty()) {
        stateMachine.saveActionToHistory("No need to install non ingress rules");
        stateMachine.fire(Event.RULES_INSTALLED);
    } else {
        // emitting
        SpeakerInstallSegmentEmitter.INSTANCE.emitBatch(stateMachine.getCarrier(), commands, stateMachine.getNonIngressCommands());
        stateMachine.getNonIngressCommands().forEach((key, value) -> stateMachine.addPendingCommand(key, value.getSwitchId()));
        stateMachine.saveActionToHistory("Commands for installing non ingress rules have been sent");
    }
}
Also used : FlowSegmentRequestFactory(org.openkilda.floodlight.api.request.factory.FlowSegmentRequestFactory) FlowCommandBuilder(org.openkilda.wfm.topology.flowhs.service.FlowCommandBuilder) RequestedFlow(org.openkilda.wfm.topology.flowhs.model.RequestedFlow) FlowPath(org.openkilda.model.FlowPath) Flow(org.openkilda.model.Flow) RequestedFlow(org.openkilda.wfm.topology.flowhs.model.RequestedFlow)

Example 32 with RequestedFlow

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

the class FlowValidatorTest method shouldNotFailOnSwapWhenDifferentEndpointsOnFirstAndSecondFlow.

@Test
public void shouldNotFailOnSwapWhenDifferentEndpointsOnFirstAndSecondFlow() throws InvalidFlowException {
    RequestedFlow firstFlow = RequestedFlow.builder().flowId("firstFlow").srcSwitch(SWITCH_ID_1).srcPort(10).srcVlan(11).destSwitch(SWITCH_ID_2).destPort(12).destVlan(13).detectConnectedDevices(new DetectConnectedDevices()).build();
    RequestedFlow secondFlow = RequestedFlow.builder().flowId("secondFlow").srcSwitch(SWITCH_ID_1).srcPort(14).srcVlan(15).destSwitch(SWITCH_ID_2).destPort(16).destVlan(17).detectConnectedDevices(new DetectConnectedDevices()).build();
    flowValidator.checkForEqualsEndpoints(firstFlow, secondFlow);
}
Also used : DetectConnectedDevices(org.openkilda.wfm.topology.flowhs.model.DetectConnectedDevices) RequestedFlow(org.openkilda.wfm.topology.flowhs.model.RequestedFlow) Test(org.junit.Test)

Example 33 with RequestedFlow

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

the class FlowValidatorTest method shouldFailOnSwapWhenEqualsEndpointsOnFirstAndSecondFlow.

@Test(expected = InvalidFlowException.class)
public void shouldFailOnSwapWhenEqualsEndpointsOnFirstAndSecondFlow() throws InvalidFlowException {
    RequestedFlow firstFlow = RequestedFlow.builder().flowId("firstFlow").srcSwitch(SWITCH_ID_1).srcPort(10).srcVlan(11).destSwitch(SWITCH_ID_2).destPort(12).destVlan(13).detectConnectedDevices(new DetectConnectedDevices()).build();
    RequestedFlow secondFlow = RequestedFlow.builder().flowId("secondFlow").srcSwitch(SWITCH_ID_1).srcPort(10).srcVlan(11).destSwitch(SWITCH_ID_2).destPort(12).destVlan(13).detectConnectedDevices(new DetectConnectedDevices()).build();
    flowValidator.checkForEqualsEndpoints(firstFlow, secondFlow);
}
Also used : DetectConnectedDevices(org.openkilda.wfm.topology.flowhs.model.DetectConnectedDevices) RequestedFlow(org.openkilda.wfm.topology.flowhs.model.RequestedFlow) Test(org.junit.Test)

Example 34 with RequestedFlow

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

the class FlowValidatorTest method shouldNotFailOnCreateSingleTaggedFlowOnWbSeries.

@Test
public void shouldNotFailOnCreateSingleTaggedFlowOnWbSeries() throws InvalidFlowException, UnavailableFlowEndpointException {
    RequestedFlow flow = RequestedFlow.builder().flowId("firstFlow").srcSwitch(SWITCH_ID_1).srcPort(10).srcInnerVlan(11).destSwitch(SWITCH_ID_2).destPort(12).destInnerVlan(13).detectConnectedDevices(new DetectConnectedDevices()).build();
    flowValidator.validateQinQonWB(flow);
}
Also used : DetectConnectedDevices(org.openkilda.wfm.topology.flowhs.model.DetectConnectedDevices) RequestedFlow(org.openkilda.wfm.topology.flowhs.model.RequestedFlow) Test(org.junit.Test)

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