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