Search in sources :

Example 1 with DeleteLogicalPortRequest

use of org.openkilda.messaging.command.grpc.DeleteLogicalPortRequest in project open-kilda by telstra.

the class BfdWorker method processPortDeleteRequest.

/**
 * Send logical port (BFD) delete request.
 */
public void processPortDeleteRequest(String requestId, Endpoint logical) {
    Optional<String> address = lookupSwitchAddress(logical.getDatapath());
    if (!address.isPresent()) {
        processPortCrudErrorResponse(requestId, logical, makeSwitchAddressNotFoundError(logical.getDatapath()));
        return;
    }
    DeleteLogicalPortRequest request = new DeleteLogicalPortRequest(address.get(), logical.getPortNumber());
    emit(STREAM_GRPC_ID, getCurrentTuple(), makeGrpcTuple(requestId, request));
}
Also used : DeleteLogicalPortRequest(org.openkilda.messaging.command.grpc.DeleteLogicalPortRequest)

Example 2 with DeleteLogicalPortRequest

use of org.openkilda.messaging.command.grpc.DeleteLogicalPortRequest 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());
    }
}
Also used : LagPortNotFoundException(org.openkilda.wfm.topology.switchmanager.error.LagPortNotFoundException) DeleteLogicalPortRequest(org.openkilda.messaging.command.grpc.DeleteLogicalPortRequest) InvalidDataException(org.openkilda.wfm.topology.switchmanager.error.InvalidDataException) SwitchNotFoundException(org.openkilda.wfm.topology.switchmanager.error.SwitchNotFoundException) InconsistentDataException(org.openkilda.wfm.topology.switchmanager.error.InconsistentDataException)

Example 3 with DeleteLogicalPortRequest

use of org.openkilda.messaging.command.grpc.DeleteLogicalPortRequest in project open-kilda by telstra.

the class SwitchSyncFsm method sendLogicalPortsCommandsCommands.

protected void sendLogicalPortsCommandsCommands(SwitchSyncState from, SwitchSyncState to, SwitchSyncEvent event, Object context) {
    if (missingLogicalPorts.isEmpty() && excessLogicalPorts.isEmpty()) {
        log.info("Nothing to do with logical ports (switch={}, key={})", switchId, key);
        fire(NEXT);
        return;
    }
    if (!missingLogicalPorts.isEmpty()) {
        log.info("Request to install logical ports has been sent (switch={}, key={})", switchId, key);
        missingLogicalPortsPendingResponsesCount = missingLogicalPorts.size();
        for (CreateLogicalPortRequest createRequest : missingLogicalPorts) {
            carrier.sendCommandToSpeaker(key, createRequest);
        }
    }
    if (!excessLogicalPorts.isEmpty()) {
        log.info("Request to remove logical ports has been sent (switch={}, key={})", switchId, key);
        excessLogicalPortsPendingResponsesCount = excessLogicalPorts.size();
        for (DeleteLogicalPortRequest deleteRequest : excessLogicalPorts) {
            carrier.sendCommandToSpeaker(key, deleteRequest);
        }
    }
    continueIfLogicalPortsSynchronized();
}
Also used : DeleteLogicalPortRequest(org.openkilda.messaging.command.grpc.DeleteLogicalPortRequest) CreateLogicalPortRequest(org.openkilda.messaging.command.grpc.CreateLogicalPortRequest)

Example 4 with DeleteLogicalPortRequest

use of org.openkilda.messaging.command.grpc.DeleteLogicalPortRequest in project open-kilda by telstra.

the class MessageProcessor method handleCommandMessage.

private void handleCommandMessage(CommandMessage command, String key) {
    CommandData data = command.getData();
    String correlationId = command.getCorrelationId();
    CompletableFuture<Response> result;
    if (data instanceof CreateLogicalPortRequest) {
        result = handleCreateLogicalPortRequest((CreateLogicalPortRequest) data);
    } else if (data instanceof DumpLogicalPortsRequest) {
        result = handleDumpLogicalPortsRequest((DumpLogicalPortsRequest) data);
    } else if (data instanceof GetSwitchInfoRequest) {
        result = handleGetSwitchInfoRequest((GetSwitchInfoRequest) data);
    } else if (data instanceof GetPacketInOutStatsRequest) {
        result = handleGetPacketInOutStatsRequest((GetPacketInOutStatsRequest) data);
    } else if (data instanceof DeleteLogicalPortRequest) {
        result = handleDeleteLogicalPortRequest((DeleteLogicalPortRequest) data);
    } else {
        result = unhandledMessage(command);
    }
    result.thenAccept(response -> sendResponse(response, correlationId, key));
}
Also used : GetSwitchInfoResponse(org.openkilda.messaging.info.grpc.GetSwitchInfoResponse) CreateLogicalPortResponse(org.openkilda.messaging.info.grpc.CreateLogicalPortResponse) GetPacketInOutStatsResponse(org.openkilda.messaging.info.grpc.GetPacketInOutStatsResponse) DeleteLogicalPortResponse(org.openkilda.messaging.info.grpc.DeleteLogicalPortResponse) DumpLogicalPortsResponse(org.openkilda.messaging.info.grpc.DumpLogicalPortsResponse) DeleteLogicalPortRequest(org.openkilda.messaging.command.grpc.DeleteLogicalPortRequest) GetSwitchInfoRequest(org.openkilda.messaging.command.grpc.GetSwitchInfoRequest) DumpLogicalPortsRequest(org.openkilda.messaging.command.grpc.DumpLogicalPortsRequest) GetPacketInOutStatsRequest(org.openkilda.messaging.command.grpc.GetPacketInOutStatsRequest) CommandData(org.openkilda.messaging.command.CommandData) CreateLogicalPortRequest(org.openkilda.messaging.command.grpc.CreateLogicalPortRequest)

Aggregations

DeleteLogicalPortRequest (org.openkilda.messaging.command.grpc.DeleteLogicalPortRequest)4 CreateLogicalPortRequest (org.openkilda.messaging.command.grpc.CreateLogicalPortRequest)2 CommandData (org.openkilda.messaging.command.CommandData)1 DumpLogicalPortsRequest (org.openkilda.messaging.command.grpc.DumpLogicalPortsRequest)1 GetPacketInOutStatsRequest (org.openkilda.messaging.command.grpc.GetPacketInOutStatsRequest)1 GetSwitchInfoRequest (org.openkilda.messaging.command.grpc.GetSwitchInfoRequest)1 CreateLogicalPortResponse (org.openkilda.messaging.info.grpc.CreateLogicalPortResponse)1 DeleteLogicalPortResponse (org.openkilda.messaging.info.grpc.DeleteLogicalPortResponse)1 DumpLogicalPortsResponse (org.openkilda.messaging.info.grpc.DumpLogicalPortsResponse)1 GetPacketInOutStatsResponse (org.openkilda.messaging.info.grpc.GetPacketInOutStatsResponse)1 GetSwitchInfoResponse (org.openkilda.messaging.info.grpc.GetSwitchInfoResponse)1 InconsistentDataException (org.openkilda.wfm.topology.switchmanager.error.InconsistentDataException)1 InvalidDataException (org.openkilda.wfm.topology.switchmanager.error.InvalidDataException)1 LagPortNotFoundException (org.openkilda.wfm.topology.switchmanager.error.LagPortNotFoundException)1 SwitchNotFoundException (org.openkilda.wfm.topology.switchmanager.error.SwitchNotFoundException)1