use of org.openkilda.model.DetectConnectedDevices in project open-kilda by telstra.
the class FlowCommandFactory method needToInstallOrRemoveLldpFlow.
private boolean needToInstallOrRemoveLldpFlow(FlowPath path) {
Flow flow = path.getFlow();
boolean isForward = flow.isForward(path);
DetectConnectedDevices detect = flow.getDetectConnectedDevices();
return (isForward && (detect.isSrcLldp() || detect.isSrcSwitchLldp())) || (!isForward && (detect.isDstLldp() || detect.isDstSwitchLldp()));
}
use of org.openkilda.model.DetectConnectedDevices in project open-kilda by telstra.
the class BaseResourceAllocationAction method updateSwitchRelatedFlowProperties.
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 RequestedFlowMapperTest method mapFlowRequestToFlowTest.
@Test
public void mapFlowRequestToFlowTest() {
Flow flow = RequestedFlowMapper.INSTANCE.toFlow(FLOW_REQUEST);
assertEquals(FLOW_ID, flow.getFlowId());
assertEquals(SRC_SWITCH_ID, flow.getSrcSwitchId());
assertEquals(SRC_PORT.intValue(), flow.getSrcPort());
assertEquals(SRC_VLAN, flow.getSrcVlan());
assertEquals(SRC_INNER_VLAN, flow.getSrcInnerVlan());
assertEquals(DST_SWITCH_ID, flow.getDestSwitchId());
assertEquals(DST_PORT.intValue(), flow.getDestPort());
assertEquals(DST_VLAN, flow.getDestVlan());
assertEquals(DST_INNER_VLAN, flow.getDestInnerVlan());
assertEquals(PRIORITY, flow.getPriority());
assertEquals(DESCRIPTION, flow.getDescription());
assertEquals(BANDWIDTH, flow.getBandwidth());
assertEquals(MAX_LATENCY, flow.getMaxLatency());
assertEquals(MAX_LATENCY_TIER_2, flow.getMaxLatencyTier2());
assertEquals(FlowEncapsulationType.VXLAN, flow.getEncapsulationType());
assertEquals(PathComputationStrategy.COST, flow.getPathComputationStrategy());
assertEquals(LOOP_SWITCH_ID, flow.getLoopSwitchId());
assertTrue(flow.isPinned());
assertTrue(flow.isAllocateProtectedPath());
assertTrue(flow.isIgnoreBandwidth());
assertTrue(flow.isPeriodicPings());
assertEquals(new DetectConnectedDevices(true, true, true, true, true, true, true, true), flow.getDetectConnectedDevices());
}
use of org.openkilda.model.DetectConnectedDevices in project open-kilda by telstra.
the class SwitchOperationsServiceTest method shouldValidateFlowWithLldpFlagWhenUpdatingSwitchProperties.
@Test(expected = IllegalSwitchPropertiesException.class)
public void shouldValidateFlowWithLldpFlagWhenUpdatingSwitchProperties() {
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(true, false, true, false, 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 LLDP
SwitchPropertiesDto update = new SwitchPropertiesDto();
update.setSupportedTransitEncapsulation(Collections.singleton(org.openkilda.messaging.payload.flow.FlowEncapsulationType.TRANSIT_VLAN));
update.setMultiTable(false);
update.setSwitchLldp(false);
switchOperationsService.updateSwitchProperties(TEST_SWITCH_ID, update);
}
Aggregations