use of org.openkilda.floodlight.error.SwitchOperationException in project open-kilda by telstra.
the class RecordHandler method doDumpSwitchPortsDescriptionRequest.
private void doDumpSwitchPortsDescriptionRequest(CommandMessage message) {
DumpSwitchPortsDescriptionRequest request = (DumpSwitchPortsDescriptionRequest) message.getData();
final IKafkaProducerService producerService = getKafkaProducer();
final String replyToTopic = context.getKafkaNorthboundTopic();
try {
SwitchId switchId = request.getSwitchId();
logger.info("Dump ALL ports description for switch {}", switchId);
SwitchPortsDescription response = getSwitchPortsDescription(switchId);
InfoMessage infoMessage = new InfoMessage(response, message.getTimestamp(), message.getCorrelationId());
producerService.sendMessageAndTrack(replyToTopic, infoMessage);
} catch (SwitchOperationException e) {
logger.error("Unable to dump switch port descriptions request", e);
anError(ErrorType.NOT_FOUND).withMessage(e.getMessage()).withDescription("Unable to dump switch port descriptions request").withCorrelationId(message.getCorrelationId()).withTopic(replyToTopic).sendVia(producerService);
}
}
use of org.openkilda.floodlight.error.SwitchOperationException in project open-kilda by telstra.
the class RecordHandler method doRemoveIslDefaultRule.
private void doRemoveIslDefaultRule(CommandMessage message) {
RemoveIslDefaultRulesCommand toRemove = (RemoveIslDefaultRulesCommand) message.getData();
RemoveIslDefaultRulesResult result = new RemoveIslDefaultRulesResult(toRemove.getSrcSwitch(), toRemove.getSrcPort(), toRemove.getDstSwitch(), toRemove.getDstPort(), true);
DatapathId dpid = DatapathId.of(toRemove.getSrcSwitch().toLong());
try {
context.getSwitchManager().removeMultitableEndpointIslRules(dpid, toRemove.getSrcPort());
context.getSwitchManager().removeServer42IslRttInputFlow(dpid, toRemove.getSrcPort());
} catch (SwitchOperationException e) {
logger.error("Failed to remove isl rules for switch: '{}'", toRemove.getSrcSwitch(), e);
result.setSuccess(false);
}
getKafkaProducer().sendMessageAndTrack(context.getKafkaSwitchManagerTopic(), record.key(), new InfoMessage(result, System.currentTimeMillis(), message.getCorrelationId(), context.getRegion()));
}
use of org.openkilda.floodlight.error.SwitchOperationException in project open-kilda by telstra.
the class RecordHandler method dumpGroupsRequest.
private void dumpGroupsRequest(SwitchId switchId, java.util.function.Consumer<MessageData> sender) {
try {
logger.debug("Loading installed groups for switch {}", switchId);
List<OFGroupDescStatsEntry> ofGroupDescStatsEntries = context.getSwitchManager().dumpGroups(DatapathId.of(switchId.toLong()));
List<GroupEntry> groups = ofGroupDescStatsEntries.stream().map(OfFlowStatsMapper.INSTANCE::toFlowGroupEntry).collect(Collectors.toList());
SwitchGroupEntries response = SwitchGroupEntries.builder().switchId(switchId).groupEntries(groups).build();
sender.accept(response);
} catch (SwitchOperationException e) {
logger.error("Dumping of groups on switch '{}' was unsuccessful: {}", switchId, e.getMessage());
ErrorData errorData = anError(ErrorType.NOT_FOUND).withMessage(e.getMessage()).withDescription("The switch was not found when requesting a groups dump.").buildData();
sender.accept(errorData);
}
}
use of org.openkilda.floodlight.error.SwitchOperationException in project open-kilda by telstra.
the class RecordHandler method doDumpPortDescriptionRequest.
private void doDumpPortDescriptionRequest(CommandMessage message) {
DumpPortDescriptionRequest request = (DumpPortDescriptionRequest) message.getData();
final IKafkaProducerService producerService = getKafkaProducer();
final String replyToTopic = context.getKafkaNorthboundTopic();
try {
SwitchId switchId = request.getSwitchId();
logger.info("Get port {}_{} description", switchId, request.getPortNumber());
SwitchPortsDescription switchPortsDescription = getSwitchPortsDescription(switchId);
int port = request.getPortNumber();
PortDescription response = switchPortsDescription.getPortsDescription().stream().filter(x -> x.getPortNumber() == port).findFirst().orElseThrow(() -> new SwitchOperationException(DatapathId.of(switchId.toLong()), format("Port %s_%d does not exists.", switchId, port)));
InfoMessage infoMessage = new InfoMessage(response, message.getTimestamp(), message.getCorrelationId());
producerService.sendMessageAndTrack(replyToTopic, infoMessage);
} catch (SwitchOperationException e) {
logger.error("Unable to dump port description request", e);
anError(ErrorType.NOT_FOUND).withMessage(e.getMessage()).withDescription("Unable to dump port description request").withCorrelationId(message.getCorrelationId()).withTopic(replyToTopic).sendVia(producerService);
}
}
use of org.openkilda.floodlight.error.SwitchOperationException in project open-kilda by telstra.
the class FlowSegmentReport method assembleResponse.
private SpeakerResponse assembleResponse() {
FlowErrorResponseBuilder errorResponse = makeErrorTemplate();
try {
raiseError();
return makeSuccessReply();
} catch (SwitchNotFoundException e) {
errorResponse.errorCode(ErrorCode.SWITCH_UNAVAILABLE);
} catch (SessionErrorResponseException e) {
decodeError(errorResponse, e.getErrorResponse());
} catch (SwitchMissingFlowsException e) {
errorResponse.errorCode(ErrorCode.MISSING_OF_FLOWS);
errorResponse.description(e.getMessage());
} catch (SwitchOperationException e) {
errorResponse.errorCode(ErrorCode.UNKNOWN);
errorResponse.description(e.getMessage());
} catch (Exception e) {
log.error(String.format("Unhandled exception while processing command %s", command), e);
errorResponse.errorCode(ErrorCode.UNKNOWN);
}
FlowErrorResponse response = errorResponse.build();
log.error("Command {} have failed - {} {}", command, response.getErrorCode(), response.getDescription());
return response;
}
Aggregations