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