use of org.openkilda.wfm.topology.switchmanager.error.LagPortNotFoundException in project open-kilda by telstra.
the class LagPortOperationService method ensureDeleteIsPossible.
/**
* Verify that LAG logical port can be removed (it exists and do not in use by any flow).
*/
public LagLogicalPort ensureDeleteIsPossible(SwitchId switchId, int logicalPortNumber) {
// locate switch first to produce correct error if switch is missing
Switch sw = querySwitch(switchId);
Optional<LagLogicalPort> port = lagLogicalPortRepository.findBySwitchIdAndPortNumber(switchId, logicalPortNumber);
if (!port.isPresent()) {
throw new LagPortNotFoundException(switchId, logicalPortNumber);
}
List<String> occupiedBy = flowRepository.findByEndpoint(switchId, logicalPortNumber).stream().map(Flow::getFlowId).collect(Collectors.toList());
if (!occupiedBy.isEmpty()) {
throw new InvalidDataException(format("Couldn't delete LAG port '%d' from switch %s because flows '%s' " + "use it as endpoint", logicalPortNumber, switchId, occupiedBy));
}
if (!isSwitchLagCapable(sw)) {
log.error("Processing request for remove existing LAG logical port #{} on switch {} without LAG support", logicalPortNumber, switchId);
}
return port.get();
}
use of org.openkilda.wfm.topology.switchmanager.error.LagPortNotFoundException 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());
}
}
Aggregations