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());
}
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());
}
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);
}
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");
}
}
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());
}
Aggregations