use of org.openkilda.model.Switch 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.Switch in project open-kilda by telstra.
the class SwitchOperationsServiceTest method shouldValidateFlowMirrorPointsWhenUpdatingSwitchLldpProperties.
@Test(expected = IllegalSwitchPropertiesException.class)
public void shouldValidateFlowMirrorPointsWhenUpdatingSwitchLldpProperties() {
Switch mirrorSwitch = Switch.builder().switchId(TEST_SWITCH_ID).status(SwitchStatus.ACTIVE).build();
switchRepository.add(mirrorSwitch);
MirrorGroup mirrorGroup = MirrorGroup.builder().switchId(TEST_SWITCH_ID).groupId(new GroupId(12L)).pathId(new PathId("test_path_id")).flowId(TEST_FLOW_ID_1).mirrorGroupType(MirrorGroupType.TRAFFIC_INTEGRITY).mirrorDirection(MirrorDirection.INGRESS).build();
mirrorGroupRepository.add(mirrorGroup);
FlowMirrorPoints flowMirrorPoints = FlowMirrorPoints.builder().mirrorGroup(mirrorGroup).mirrorSwitch(mirrorSwitch).build();
flowMirrorPointsRepository.add(flowMirrorPoints);
createSwitchProperties(mirrorSwitch, 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.setMultiTable(true);
update.setSwitchLldp(true);
switchOperationsService.updateSwitchProperties(TEST_SWITCH_ID, update);
}
use of org.openkilda.model.Switch in project open-kilda by telstra.
the class SwitchOperationsServiceTest method shouldSetNullPopWhenPopIsEmptyString.
@Test
public void shouldSetNullPopWhenPopIsEmptyString() throws SwitchNotFoundException {
Switch sw = Switch.builder().switchId(TEST_SWITCH_ID).status(SwitchStatus.ACTIVE).build();
switchRepository.add(sw);
SwitchPatch switchPatch = new SwitchPatch("", null);
switchOperationsService.patchSwitch(TEST_SWITCH_ID, switchPatch);
Switch updatedSwitch = switchRepository.findById(TEST_SWITCH_ID).get();
assertNull(updatedSwitch.getPop());
}
use of org.openkilda.model.Switch in project open-kilda by telstra.
the class FeatureTogglesService method createOrUpdateFeatureToggles.
/**
* Create or update feature toggles.
* @param featureToggles feature toggles.
* @return updated feature toggles.
*/
public KildaFeatureToggles createOrUpdateFeatureToggles(KildaFeatureToggles featureToggles) {
log.info("Process feature-toggles update - toggles:{}", featureToggles);
KildaFeatureToggles before = featureTogglesRepository.getOrDefault();
KildaFeatureToggles after = transactionManager.doInTransaction(() -> {
Optional<KildaFeatureToggles> foundCurrent = featureTogglesRepository.find();
KildaFeatureToggles current;
if (foundCurrent.isPresent()) {
current = foundCurrent.get();
FeatureTogglesCloner.INSTANCE.copyNonNull(featureToggles, current);
} else {
current = featureToggles;
featureTogglesRepository.add(current);
}
featureTogglesRepository.detach(current);
FeatureTogglesCloner.INSTANCE.replaceNullProperties(KildaFeatureToggles.DEFAULTS, current);
return current;
});
if (!before.equals(after)) {
log.info("Emit feature-toggles update notification - toggles:{}", after);
carrier.featureTogglesUpdateNotification(after);
if (before.getServer42FlowRtt() != after.getServer42FlowRtt() || before.getServer42IslRtt() != after.getServer42IslRtt()) {
Collection<Switch> switches = switchRepository.findActive();
for (Switch sw : switches) {
log.info("Emit switch {} sync command", sw.getSwitchId());
carrier.requestSwitchSync(sw.getSwitchId());
}
}
}
return after;
}
use of org.openkilda.model.Switch in project open-kilda by telstra.
the class FlowOperationsServiceTest method createSwitch.
private Switch createSwitch(SwitchId switchId) {
Switch sw = Switch.builder().switchId(switchId).status(SwitchStatus.ACTIVE).build();
switchRepository.add(sw);
return sw;
}
Aggregations