use of org.openkilda.wfm.topology.switchmanager.error.SwitchNotFoundException in project open-kilda by telstra.
the class ValidationServiceImpl method validateMeters.
@Override
public ValidateMetersResult validateMeters(SwitchId switchId, List<MeterSpeakerData> presentMeters, List<MeterSpeakerData> expectedMeterSpeakerData) {
log.debug("Validating meters on switch {}", switchId);
Switch sw = switchRepository.findById(switchId).orElseThrow(() -> new SwitchNotFoundException(switchId));
boolean isESwitch = Switch.isNoviflowESwitch(sw.getOfDescriptionManufacturer(), sw.getOfDescriptionHardware());
List<MeterInfoEntry> actualMeters = presentMeters.stream().map(meter -> convertMeter(switchId, meter)).collect(toList());
List<MeterInfoEntry> expectedMeters = expectedMeterSpeakerData.stream().map(meter -> convertMeter(switchId, meter)).collect(toList());
ValidateMetersResult result = comparePresentedAndExpectedMeters(isESwitch, actualMeters, expectedMeters);
if (!result.getMissingMeters().isEmpty() && log.isErrorEnabled()) {
log.error("On switch {} the following meters are missed: {}", switchId, metersIntoLogRepresentation(result.getMissingMeters()));
}
if (!result.getExcessMeters().isEmpty() && log.isWarnEnabled()) {
log.warn("On switch {} the following meters are excessive: {}", switchId, metersIntoLogRepresentation(result.getExcessMeters()));
}
if (!result.getMisconfiguredMeters().isEmpty() && log.isWarnEnabled()) {
for (MeterInfoEntry meter : result.getMisconfiguredMeters()) {
log.warn("On switch {} meter {} is misconfigured: {}", switchId, meter.getMeterId(), getMisconfiguredMeterDifferenceAsString(meter.getExpected(), meter.getActual()));
}
}
return result;
}
use of org.openkilda.wfm.topology.switchmanager.error.SwitchNotFoundException in project open-kilda by telstra.
the class SwitchValidateFsm method emitRequests.
public void emitRequests(SwitchValidateState from, SwitchValidateState to, SwitchValidateEvent event, SwitchValidateContext context) {
try {
SwitchId switchId = getSwitchId();
log.info("The switch validate process for {} has been started (key={})", switchId, key);
// FIXME(surabujin): not reliable check - corresponding error from speaker is much more better
Optional<Switch> sw = switchRepository.findById(switchId);
if (!sw.isPresent()) {
throw new SwitchNotFoundException(switchId);
}
requestSwitchOfFlows();
requestSwitchOfGroups();
if (sw.get().getFeatures().contains(LAG)) {
// at this moment Kilda validated only LAG logical ports
Optional<String> ipAddress = sw.map(Switch::getSocketAddress).map(IpSocketAddress::getAddress);
if (ipAddress.isPresent()) {
requestLogicalPorts(ipAddress.get());
} else {
log.warn("Unable to get IP address of switch {} to get LAGs", switchId);
}
}
if (request.isProcessMeters()) {
requestSwitchMeters();
}
} catch (Exception ex) {
log.error("Failure in emitRequests", ex);
throw ex;
}
}
use of org.openkilda.wfm.topology.switchmanager.error.SwitchNotFoundException in project open-kilda by telstra.
the class DeleteLagPortFsm method createGrpcRequest.
void createGrpcRequest(DeleteLagState from, DeleteLagState to, DeleteLagEvent event, DeleteLagContext context) {
log.info("Removing LAG {} on switch {}. Key={}", request, switchId, key);
try {
lagPortOperationService.ensureDeleteIsPossible(switchId, request.getLogicalPortNumber());
String ipAddress = lagPortOperationService.getSwitchIpAddress(switchId);
grpcRequest = new DeleteLogicalPortRequest(ipAddress, request.getLogicalPortNumber());
} catch (LagPortNotFoundException | InvalidDataException | SwitchNotFoundException | InconsistentDataException e) {
log.error(format("Unable to delete LAG logical port %d on switch %s. Error: %s", request.getLogicalPortNumber(), switchId, e.getMessage()), e);
fire(ERROR, DeleteLagContext.builder().error(e).build());
}
}
use of org.openkilda.wfm.topology.switchmanager.error.SwitchNotFoundException in project open-kilda by telstra.
the class CreateLagPortFsm method createLagInDb.
void createLagInDb(CreateLagState from, CreateLagState to, CreateLagEvent event, CreateLagContext context) {
log.info("Creating LAG {} on switch {}. Key={}", request, switchId, key);
try {
HashSet<Integer> targetPorts = new HashSet<>(request.getPortNumbers());
lagLogicalPortNumber = lagPortOperationService.createLagPort(switchId, targetPorts);
String ipAddress = lagPortOperationService.getSwitchIpAddress(switchId);
grpcRequest = new CreateLogicalPortRequest(ipAddress, request.getPortNumbers(), lagLogicalPortNumber, LAG);
} catch (InvalidDataException | InconsistentDataException | SwitchNotFoundException e) {
log.error(format("Unable to handle %s. Error: %s", request, e.getMessage()), e);
fire(ERROR, CreateLagContext.builder().error(e).build());
}
}
Aggregations