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