Search in sources :

Example 56 with Switch

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);
}
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 57 with Switch

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);
}
Also used : PathId(org.openkilda.model.PathId) SwitchPropertiesDto(org.openkilda.messaging.model.SwitchPropertiesDto) MirrorGroup(org.openkilda.model.MirrorGroup) Switch(org.openkilda.model.Switch) FlowMirrorPoints(org.openkilda.model.FlowMirrorPoints) GroupId(org.openkilda.model.GroupId) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Example 58 with Switch

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());
}
Also used : Switch(org.openkilda.model.Switch) SwitchPatch(org.openkilda.messaging.model.SwitchPatch) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Example 59 with Switch

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;
}
Also used : Switch(org.openkilda.model.Switch) KildaFeatureToggles(org.openkilda.model.KildaFeatureToggles)

Example 60 with Switch

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;
}
Also used : Switch(org.openkilda.model.Switch)

Aggregations

Switch (org.openkilda.model.Switch)230 Test (org.junit.Test)126 Flow (org.openkilda.model.Flow)68 SwitchId (org.openkilda.model.SwitchId)67 InMemoryGraphBasedTest (org.openkilda.persistence.inmemory.InMemoryGraphBasedTest)46 FlowPath (org.openkilda.model.FlowPath)34 PathId (org.openkilda.model.PathId)32 Utils.buildSwitch (org.openkilda.rulemanager.Utils.buildSwitch)32 PathComputer (org.openkilda.pce.PathComputer)28 GetPathsResult (org.openkilda.pce.GetPathsResult)23 List (java.util.List)22 SwitchProperties (org.openkilda.model.SwitchProperties)21 FlowSpeakerData (org.openkilda.rulemanager.FlowSpeakerData)20 SpeakerData (org.openkilda.rulemanager.SpeakerData)19 String.format (java.lang.String.format)17 Set (java.util.Set)17 Isl (org.openkilda.model.Isl)15 HashSet (java.util.HashSet)14 ArrayList (java.util.ArrayList)13 Collections (java.util.Collections)13