Search in sources :

Example 66 with Switch

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

the class SwitchOperationsServiceTest method shouldValidateMultiTableFlagWhenUpdatingSwitchProperties.

@Test(expected = IllegalSwitchPropertiesException.class)
public void shouldValidateMultiTableFlagWhenUpdatingSwitchProperties() {
    Switch sw = Switch.builder().switchId(TEST_SWITCH_ID).status(SwitchStatus.ACTIVE).build();
    switchRepository.add(sw);
    createSwitchProperties(sw, Collections.singleton(FlowEncapsulationType.TRANSIT_VLAN), true, true, false);
    // user can't disable multiTable without disabling LLDP
    SwitchPropertiesDto update = new SwitchPropertiesDto();
    update.setSupportedTransitEncapsulation(Collections.singleton(org.openkilda.messaging.payload.flow.FlowEncapsulationType.TRANSIT_VLAN));
    update.setMultiTable(false);
    update.setSwitchLldp(true);
    switchOperationsService.updateSwitchProperties(TEST_SWITCH_ID, update);
}
Also used : SwitchPropertiesDto(org.openkilda.messaging.model.SwitchPropertiesDto) Switch(org.openkilda.model.Switch) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Example 67 with Switch

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

the class SwitchFsm method offlineEnter.

public void offlineEnter(SwitchFsmState from, SwitchFsmState to, SwitchFsmEvent event, SwitchFsmContext context) {
    logWrapper.onSwitchOffline(switchId);
    if (context.isMissingInPeriodicDumps()) {
        log.info("Force switch {} to become OFFLINE due to missing in {} consecutive network dumps (last seen " + "dump generation {}, actual generation {})", switchId, options.getSwitchOfflineGenerationLag(), lastPeriodicDumpGenerationContainingSwitch, context.getPeriodicDumpGeneration());
    }
    transactionManager.doInTransaction(transactionRetryPolicy, () -> {
        Switch sw = lookupSwitchCreateIfMissing();
        updatePersistentStatus(sw, SwitchStatus.INACTIVE);
        persistSwitchConnections(sw, context.getAvailabilityData());
    });
    context.getOutput().sendSwitchStateChanged(switchId, SwitchStatus.INACTIVE);
    for (AbstractPort port : portByNumber.values()) {
        updateOnlineStatus(port, context, OnlineStatus.of(false, context.getIsRegionOffline()));
    }
}
Also used : Switch(org.openkilda.model.Switch)

Example 68 with Switch

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

the class SwitchFsm method persistSwitchData.

private void persistSwitchData(SpeakerSwitchView speakerSwitchView, SwitchAvailabilityData availabilityData) {
    Switch sw = lookupSwitchCreateIfMissing();
    IpSocketAddress socketAddress = speakerSwitchView.getSwitchSocketAddress();
    sw.setSocketAddress(socketAddress);
    sw.setHostname(speakerSwitchView.getHostname());
    SpeakerSwitchDescription description = speakerSwitchView.getDescription();
    sw.setDescription(String.format("%s %s %s", description.getManufacturer(), speakerSwitchView.getOfVersion(), description.getSoftware()));
    sw.setOfVersion(speakerSwitchView.getOfVersion());
    sw.setOfDescriptionManufacturer(description.getManufacturer());
    sw.setOfDescriptionHardware(description.getHardware());
    sw.setOfDescriptionSoftware(description.getSoftware());
    sw.setOfDescriptionSerialNumber(description.getSerialNumber());
    sw.setOfDescriptionDatapath(description.getDatapath());
    sw.setStatus(SwitchStatus.INACTIVE);
    sw.setFeatures(speakerSwitchView.getFeatures());
    persistSwitchProperties(sw);
    persistSwitchConnections(sw, availabilityData);
}
Also used : Switch(org.openkilda.model.Switch) IpSocketAddress(org.openkilda.model.IpSocketAddress) SpeakerSwitchDescription(org.openkilda.messaging.model.SpeakerSwitchDescription)

Example 69 with Switch

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

the class NetworkHistoryService method loadNetworkHistory.

// -- private --
private Collection<HistoryFacts> loadNetworkHistory() {
    RepositoryFactory repositoryFactory = persistenceManager.getRepositoryFactory();
    SwitchRepository switchRepository = repositoryFactory.createSwitchRepository();
    HashMap<SwitchId, HistoryFacts> switchById = new HashMap<>();
    for (Switch switchEntry : switchRepository.findAll()) {
        SwitchId switchId = switchEntry.getSwitchId();
        SwitchStatus switchStatus = switchEntry.getStatus();
        switchById.put(switchId, new HistoryFacts(switchId, switchStatus));
    }
    IslRepository islRepository = repositoryFactory.createIslRepository();
    for (Isl islEntry : islRepository.findAll()) {
        HistoryFacts history = switchById.get(islEntry.getSrcSwitchId());
        if (history == null) {
            log.error("Orphaned ISL relation - {}-{} (read race condition?)", islEntry.getSrcSwitchId(), islEntry.getSrcPort());
            continue;
        }
        islRepository.detach(islEntry);
        history.addLink(islEntry);
    }
    return switchById.values();
}
Also used : IslRepository(org.openkilda.persistence.repositories.IslRepository) Isl(org.openkilda.model.Isl) Switch(org.openkilda.model.Switch) HashMap(java.util.HashMap) SwitchRepository(org.openkilda.persistence.repositories.SwitchRepository) SwitchId(org.openkilda.model.SwitchId) RepositoryFactory(org.openkilda.persistence.repositories.RepositoryFactory) HistoryFacts(org.openkilda.wfm.topology.network.model.facts.HistoryFacts) SwitchStatus(org.openkilda.model.SwitchStatus)

Example 70 with Switch

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

the class NetworkPortService method savePortProperties.

private PortProperties savePortProperties(Endpoint endpoint, boolean discoveryEnabled) {
    Switch sw = switchRepository.findById(endpoint.getDatapath()).orElseThrow(() -> new PersistenceException(format("Switch %s not found.", endpoint.getDatapath())));
    PortProperties portProperties = portPropertiesRepository.getBySwitchIdAndPort(endpoint.getDatapath(), endpoint.getPortNumber()).orElseGet(() -> {
        PortProperties newProps = PortProperties.builder().switchObj(sw).port(endpoint.getPortNumber()).build();
        portPropertiesRepository.add(newProps);
        return newProps;
    });
    portProperties.setDiscoveryEnabled(discoveryEnabled);
    return portProperties;
}
Also used : Switch(org.openkilda.model.Switch) PersistenceException(org.openkilda.persistence.exceptions.PersistenceException) PortProperties(org.openkilda.model.PortProperties)

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