Search in sources :

Example 1 with DetectConnectedDevices

use of org.openkilda.model.DetectConnectedDevices in project open-kilda by telstra.

the class ResourcesAllocationAction method updateSwitchRelatedFlowProperties.

// TODO: refactor FlowCreate and unify ResourcesAllocationAction with BaseResourceAllocationAction to avoid
// code duplication.
private void updateSwitchRelatedFlowProperties(Flow flow) {
    Map<SwitchId, SwitchProperties> switchProperties = LazyMap.lazyMap(new HashMap<>(), switchId -> switchPropertiesRepository.findBySwitchId(switchId).orElse(null));
    DetectConnectedDevices.DetectConnectedDevicesBuilder detectConnectedDevices = flow.getDetectConnectedDevices().toBuilder();
    SwitchProperties srcSwitchProps = switchProperties.get(flow.getSrcSwitchId());
    if (srcSwitchProps != null) {
        detectConnectedDevices.srcSwitchLldp(srcSwitchProps.isSwitchLldp());
        detectConnectedDevices.srcSwitchArp(srcSwitchProps.isSwitchArp());
    }
    SwitchProperties destSwitchProps = switchProperties.get(flow.getDestSwitchId());
    if (destSwitchProps != null) {
        switchProperties.put(flow.getDestSwitchId(), destSwitchProps);
        detectConnectedDevices.dstSwitchLldp(destSwitchProps.isSwitchLldp());
        detectConnectedDevices.dstSwitchArp(destSwitchProps.isSwitchArp());
    }
    flow.setDetectConnectedDevices(detectConnectedDevices.build());
}
Also used : SwitchId(org.openkilda.model.SwitchId) DetectConnectedDevices(org.openkilda.model.DetectConnectedDevices) SwitchProperties(org.openkilda.model.SwitchProperties)

Example 2 with DetectConnectedDevices

use of org.openkilda.model.DetectConnectedDevices in project open-kilda by telstra.

the class UpdateFlowAction method updateFlow.

private RequestedFlow updateFlow(Flow flow, RequestedFlow targetFlow) {
    if (targetFlow.getDiverseFlowId() != null) {
        if (targetFlow.getDiverseFlowId().isEmpty()) {
            flow.setDiverseGroupId(null);
        } else {
            flow.setDiverseGroupId(getOrCreateDiverseFlowGroupId(targetFlow.getDiverseFlowId()));
        }
    } else if (targetFlow.isAllocateProtectedPath()) {
        if (flow.getDiverseGroupId() == null) {
            flow.setDiverseGroupId(getOrCreateDiverseFlowGroupId(flow.getFlowId()));
        }
    }
    if (targetFlow.getAffinityFlowId() != null) {
        if (targetFlow.getAffinityFlowId().isEmpty()) {
            flow.setAffinityGroupId(null);
        } else {
            flow.setAffinityGroupId(getOrCreateAffinityFlowGroupId(targetFlow.getAffinityFlowId()));
        }
    }
    Switch srcSwitch = switchRepository.findById(targetFlow.getSrcSwitch()).orElseThrow(() -> new FlowProcessingException(ErrorType.NOT_FOUND, format("Switch %s not found", targetFlow.getSrcSwitch())));
    flow.setSrcSwitch(srcSwitch);
    flow.setSrcPort(targetFlow.getSrcPort());
    flow.setSrcVlan(targetFlow.getSrcVlan());
    flow.setSrcInnerVlan(targetFlow.getSrcInnerVlan());
    DetectConnectedDevices.DetectConnectedDevicesBuilder detectConnectedDevices = flow.getDetectConnectedDevices().toBuilder();
    detectConnectedDevices.srcLldp(targetFlow.getDetectConnectedDevices().isSrcLldp());
    detectConnectedDevices.srcArp(targetFlow.getDetectConnectedDevices().isSrcArp());
    Switch destSwitch = switchRepository.findById(targetFlow.getDestSwitch()).orElseThrow(() -> new FlowProcessingException(ErrorType.NOT_FOUND, format("Switch %s not found", targetFlow.getDestSwitch())));
    flow.setDestSwitch(destSwitch);
    flow.setDestPort(targetFlow.getDestPort());
    flow.setDestVlan(targetFlow.getDestVlan());
    flow.setDestInnerVlan(targetFlow.getDestInnerVlan());
    detectConnectedDevices.dstLldp(targetFlow.getDetectConnectedDevices().isDstLldp());
    detectConnectedDevices.dstArp(targetFlow.getDetectConnectedDevices().isDstArp());
    flow.setDetectConnectedDevices(detectConnectedDevices.build());
    if (targetFlow.getPriority() != null) {
        flow.setPriority(targetFlow.getPriority());
    }
    flow.setPinned(targetFlow.isPinned());
    flow.setAllocateProtectedPath(targetFlow.isAllocateProtectedPath());
    if (targetFlow.getDescription() != null) {
        flow.setDescription(targetFlow.getDescription());
    }
    flow.setBandwidth(targetFlow.getBandwidth());
    flow.setIgnoreBandwidth(targetFlow.isIgnoreBandwidth());
    flow.setStrictBandwidth(targetFlow.isStrictBandwidth());
    if (targetFlow.getMaxLatency() != null) {
        flow.setMaxLatency(targetFlow.getMaxLatency());
    }
    if (targetFlow.getMaxLatencyTier2() != null) {
        flow.setMaxLatencyTier2(targetFlow.getMaxLatencyTier2());
    }
    flow.setPeriodicPings(targetFlow.isPeriodicPings());
    if (targetFlow.getFlowEncapsulationType() != null) {
        flow.setEncapsulationType(targetFlow.getFlowEncapsulationType());
    } else {
        targetFlow.setFlowEncapsulationType(flow.getEncapsulationType());
    }
    if (targetFlow.getPathComputationStrategy() != null) {
        flow.setPathComputationStrategy(targetFlow.getPathComputationStrategy());
        flow.setTargetPathComputationStrategy(null);
    } else {
        if (flow.getTargetPathComputationStrategy() != null) {
            targetFlow.setPathComputationStrategy(flow.getTargetPathComputationStrategy());
            flow.setPathComputationStrategy(flow.getTargetPathComputationStrategy());
            flow.setTargetPathComputationStrategy(null);
        } else {
            targetFlow.setPathComputationStrategy(flow.getPathComputationStrategy());
        }
    }
    flow.setLoopSwitchId(targetFlow.getLoopSwitchId());
    return targetFlow;
}
Also used : Switch(org.openkilda.model.Switch) FlowProcessingException(org.openkilda.wfm.topology.flowhs.exception.FlowProcessingException) DetectConnectedDevices(org.openkilda.model.DetectConnectedDevices)

Example 3 with DetectConnectedDevices

use of org.openkilda.model.DetectConnectedDevices in project open-kilda by telstra.

the class SwitchOperationsServiceTest method shouldValidateFlowWhenUpdatingServer42PortSwitchProperties.

@Test(expected = IllegalSwitchPropertiesException.class)
public void shouldValidateFlowWhenUpdatingServer42PortSwitchProperties() {
    Switch firstSwitch = Switch.builder().switchId(TEST_SWITCH_ID).status(SwitchStatus.ACTIVE).build();
    Switch secondSwitch = Switch.builder().switchId(TEST_SWITCH_ID_2).status(SwitchStatus.ACTIVE).build();
    switchRepository.add(firstSwitch);
    switchRepository.add(secondSwitch);
    Flow flow = Flow.builder().flowId(TEST_FLOW_ID_1).srcSwitch(firstSwitch).srcPort(TEST_FLOW_SRC_PORT).destSwitch(secondSwitch).detectConnectedDevices(new DetectConnectedDevices(false, true, false, true, false, false, false, false)).build();
    flowRepository.add(flow);
    createSwitchProperties(firstSwitch, Collections.singleton(FlowEncapsulationType.TRANSIT_VLAN), true, false, false);
    SwitchPropertiesDto update = new SwitchPropertiesDto();
    update.setSupportedTransitEncapsulation(Collections.singleton(org.openkilda.messaging.payload.flow.FlowEncapsulationType.TRANSIT_VLAN));
    update.setServer42Port(TEST_FLOW_SRC_PORT);
    switchOperationsService.updateSwitchProperties(TEST_SWITCH_ID, update);
}
Also used : SwitchPropertiesDto(org.openkilda.messaging.model.SwitchPropertiesDto) Switch(org.openkilda.model.Switch) DetectConnectedDevices(org.openkilda.model.DetectConnectedDevices) Flow(org.openkilda.model.Flow) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Example 4 with DetectConnectedDevices

use of org.openkilda.model.DetectConnectedDevices in project open-kilda by telstra.

the class SwitchOperationsServiceTest method shouldValidateFlowWithArpFlagWhenUpdatingSwitchProperties.

@Test(expected = IllegalSwitchPropertiesException.class)
public void shouldValidateFlowWithArpFlagWhenUpdatingSwitchProperties() {
    Switch firstSwitch = Switch.builder().switchId(TEST_SWITCH_ID).status(SwitchStatus.ACTIVE).build();
    Switch secondSwitch = Switch.builder().switchId(TEST_SWITCH_ID_2).status(SwitchStatus.ACTIVE).build();
    switchRepository.add(firstSwitch);
    switchRepository.add(secondSwitch);
    Flow flow = Flow.builder().flowId(TEST_FLOW_ID_1).srcSwitch(firstSwitch).destSwitch(secondSwitch).detectConnectedDevices(new DetectConnectedDevices(false, true, false, true, false, false, false, false)).build();
    flowRepository.add(flow);
    createSwitchProperties(firstSwitch, Collections.singleton(FlowEncapsulationType.TRANSIT_VLAN), true, false, false);
    // user can't disable multiTable if some flows has enabled detect connected devices via ARP
    SwitchPropertiesDto update = new SwitchPropertiesDto();
    update.setSupportedTransitEncapsulation(Collections.singleton(org.openkilda.messaging.payload.flow.FlowEncapsulationType.TRANSIT_VLAN));
    update.setMultiTable(false);
    update.setSwitchArp(false);
    switchOperationsService.updateSwitchProperties(TEST_SWITCH_ID, update);
}
Also used : SwitchPropertiesDto(org.openkilda.messaging.model.SwitchPropertiesDto) Switch(org.openkilda.model.Switch) DetectConnectedDevices(org.openkilda.model.DetectConnectedDevices) Flow(org.openkilda.model.Flow) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Example 5 with DetectConnectedDevices

use of org.openkilda.model.DetectConnectedDevices in project open-kilda by telstra.

the class FlowCommandFactory method needToInstallOrRemoveArpFlow.

private boolean needToInstallOrRemoveArpFlow(FlowPath path) {
    Flow flow = path.getFlow();
    boolean isForward = flow.isForward(path);
    DetectConnectedDevices detect = flow.getDetectConnectedDevices();
    return (isForward && (detect.isSrcArp() || detect.isSrcSwitchArp())) || (!isForward && (detect.isDstArp() || detect.isDstSwitchArp()));
}
Also used : DetectConnectedDevices(org.openkilda.model.DetectConnectedDevices) InstallTransitFlow(org.openkilda.messaging.command.flow.InstallTransitFlow) InstallServer42IngressFlow(org.openkilda.messaging.command.flow.InstallServer42IngressFlow) InstallOneSwitchMirrorFlow(org.openkilda.messaging.command.flow.InstallOneSwitchMirrorFlow) Flow(org.openkilda.model.Flow) InstallIngressLoopFlow(org.openkilda.messaging.command.flow.InstallIngressLoopFlow) InstallIngressMirrorFlow(org.openkilda.messaging.command.flow.InstallIngressMirrorFlow) InstallTransitLoopFlow(org.openkilda.messaging.command.flow.InstallTransitLoopFlow) InstallOneSwitchFlow(org.openkilda.messaging.command.flow.InstallOneSwitchFlow) InstallEgressFlow(org.openkilda.messaging.command.flow.InstallEgressFlow) InstallEgressMirrorFlow(org.openkilda.messaging.command.flow.InstallEgressMirrorFlow) InstallIngressFlow(org.openkilda.messaging.command.flow.InstallIngressFlow)

Aggregations

DetectConnectedDevices (org.openkilda.model.DetectConnectedDevices)9 Flow (org.openkilda.model.Flow)6 Test (org.junit.Test)4 Switch (org.openkilda.model.Switch)4 SwitchPropertiesDto (org.openkilda.messaging.model.SwitchPropertiesDto)3 InMemoryGraphBasedTest (org.openkilda.persistence.inmemory.InMemoryGraphBasedTest)3 InstallEgressFlow (org.openkilda.messaging.command.flow.InstallEgressFlow)2 InstallEgressMirrorFlow (org.openkilda.messaging.command.flow.InstallEgressMirrorFlow)2 InstallIngressFlow (org.openkilda.messaging.command.flow.InstallIngressFlow)2 InstallIngressLoopFlow (org.openkilda.messaging.command.flow.InstallIngressLoopFlow)2 InstallIngressMirrorFlow (org.openkilda.messaging.command.flow.InstallIngressMirrorFlow)2 InstallOneSwitchFlow (org.openkilda.messaging.command.flow.InstallOneSwitchFlow)2 InstallOneSwitchMirrorFlow (org.openkilda.messaging.command.flow.InstallOneSwitchMirrorFlow)2 InstallServer42IngressFlow (org.openkilda.messaging.command.flow.InstallServer42IngressFlow)2 InstallTransitFlow (org.openkilda.messaging.command.flow.InstallTransitFlow)2 InstallTransitLoopFlow (org.openkilda.messaging.command.flow.InstallTransitLoopFlow)2 SwitchId (org.openkilda.model.SwitchId)2 SwitchProperties (org.openkilda.model.SwitchProperties)2 FlowProcessingException (org.openkilda.wfm.topology.flowhs.exception.FlowProcessingException)1