Search in sources :

Example 1 with PortConfigurationResponse

use of org.openkilda.messaging.info.switches.PortConfigurationResponse in project open-kilda by telstra.

the class RecordHandler method doConfigurePort.

private void doConfigurePort(final CommandMessage message) {
    PortConfigurationRequest request = (PortConfigurationRequest) message.getData();
    logger.info("Port configuration request. Switch '{}', Port '{}'", request.getSwitchId(), request.getPortNumber());
    final IKafkaProducerService producerService = getKafkaProducer();
    final String replyToTopic = context.getKafkaNorthboundTopic();
    try {
        ISwitchManager switchManager = context.getSwitchManager();
        DatapathId dpId = DatapathId.of(request.getSwitchId().toLong());
        switchManager.configurePort(dpId, request.getPortNumber(), request.getAdminDown());
        InfoMessage infoMessage = new InfoMessage(new PortConfigurationResponse(request.getSwitchId(), request.getPortNumber()), message.getTimestamp(), message.getCorrelationId());
        producerService.sendMessageAndTrack(replyToTopic, infoMessage);
    } catch (SwitchOperationException e) {
        logger.error("Port configuration request failed. " + e.getMessage(), e);
        anError(ErrorType.DATA_INVALID).withMessage(e.getMessage()).withDescription("Port configuration request failed").withCorrelationId(message.getCorrelationId()).withTopic(replyToTopic).sendVia(producerService);
    }
}
Also used : PortConfigurationRequest(org.openkilda.messaging.command.switches.PortConfigurationRequest) SwitchOperationException(org.openkilda.floodlight.error.SwitchOperationException) UnsupportedSwitchOperationException(org.openkilda.floodlight.error.UnsupportedSwitchOperationException) ISwitchManager(org.openkilda.floodlight.switchmanager.ISwitchManager) IKafkaProducerService(org.openkilda.floodlight.service.kafka.IKafkaProducerService) InfoMessage(org.openkilda.messaging.info.InfoMessage) DatapathId(org.projectfloodlight.openflow.types.DatapathId) PortConfigurationResponse(org.openkilda.messaging.info.switches.PortConfigurationResponse)

Aggregations

SwitchOperationException (org.openkilda.floodlight.error.SwitchOperationException)1 UnsupportedSwitchOperationException (org.openkilda.floodlight.error.UnsupportedSwitchOperationException)1 IKafkaProducerService (org.openkilda.floodlight.service.kafka.IKafkaProducerService)1 ISwitchManager (org.openkilda.floodlight.switchmanager.ISwitchManager)1 PortConfigurationRequest (org.openkilda.messaging.command.switches.PortConfigurationRequest)1 InfoMessage (org.openkilda.messaging.info.InfoMessage)1 PortConfigurationResponse (org.openkilda.messaging.info.switches.PortConfigurationResponse)1 DatapathId (org.projectfloodlight.openflow.types.DatapathId)1