Search in sources :

Example 1 with CreateLogicalPortRequest

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

the class BfdWorker method processPortCreateRequest.

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

Example 2 with CreateLogicalPortRequest

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

the class CommandBuilderImpl method buildLogicalPortInstallCommands.

@Override
public List<CreateLogicalPortRequest> buildLogicalPortInstallCommands(SwitchId switchId, List<LogicalPortInfoEntry> missingLogicalPorts) {
    String ipAddress = getSwitchIpAddress(switchId);
    List<CreateLogicalPortRequest> requests = new ArrayList<>();
    for (LogicalPortInfoEntry port : missingLogicalPorts) {
        requests.add(new CreateLogicalPortRequest(ipAddress, port.getPhysicalPorts(), port.getLogicalPortNumber(), LogicalPortMapper.INSTANCE.map(port.getType())));
    }
    return requests;
}
Also used : LogicalPortInfoEntry(org.openkilda.messaging.info.switches.LogicalPortInfoEntry) ArrayList(java.util.ArrayList) CreateLogicalPortRequest(org.openkilda.messaging.command.grpc.CreateLogicalPortRequest)

Example 3 with CreateLogicalPortRequest

use of org.openkilda.messaging.command.grpc.CreateLogicalPortRequest 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)

Example 4 with CreateLogicalPortRequest

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

Example 5 with CreateLogicalPortRequest

use of org.openkilda.messaging.command.grpc.CreateLogicalPortRequest 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)

Aggregations

CreateLogicalPortRequest (org.openkilda.messaging.command.grpc.CreateLogicalPortRequest)5 DeleteLogicalPortRequest (org.openkilda.messaging.command.grpc.DeleteLogicalPortRequest)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 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 LogicalPortInfoEntry (org.openkilda.messaging.info.switches.LogicalPortInfoEntry)1 InconsistentDataException (org.openkilda.wfm.topology.switchmanager.error.InconsistentDataException)1 InvalidDataException (org.openkilda.wfm.topology.switchmanager.error.InvalidDataException)1 SwitchNotFoundException (org.openkilda.wfm.topology.switchmanager.error.SwitchNotFoundException)1