Search in sources :

Example 1 with ReinstallDefaultFlowForSwitchManagerRequest

use of org.openkilda.messaging.command.flow.ReinstallDefaultFlowForSwitchManagerRequest in project open-kilda by telstra.

the class ControllerToSpeakerSharedProxyBolt method handleRegionNotFoundError.

private void handleRegionNotFoundError(CommandMessage commandMessage, SwitchId switchId) {
    String errorDetails = String.format("Switch %s not found", switchId.toString());
    ErrorData errorData = new ErrorData(ErrorType.NOT_FOUND, errorDetails, errorDetails);
    ErrorMessage errorMessage = new ErrorMessage(errorData, System.currentTimeMillis(), commandMessage.getCorrelationId(), null);
    Tuple input = getCurrentTuple();
    if (commandMessage.getData() instanceof DumpRulesForFlowHsRequest || commandMessage.getData() instanceof DumpMetersForFlowHsRequest) {
        MessageContext messageContext = new MessageContext(commandMessage);
        SpeakerDataResponse result = new SpeakerDataResponse(messageContext, errorData);
        // FIXME(surabujin): there is no subscriber on this stream now
        getOutput().emit(Stream.FLOWHS_WORKER, input, makeFlowHsWorkerTuple(commandMessage.getCorrelationId(), result));
    } else if (commandMessage.getData() instanceof DumpRulesForSwitchManagerRequest || commandMessage.getData() instanceof DumpMetersForSwitchManagerRequest || commandMessage.getData() instanceof InstallFlowForSwitchManagerRequest || commandMessage.getData() instanceof RemoveFlowForSwitchManagerRequest || commandMessage.getData() instanceof ReinstallDefaultFlowForSwitchManagerRequest) {
        getOutput().emit(Stream.KILDA_SWITCH_MANAGER, input, makeSwitchManagerTuple(commandMessage.getCorrelationId(), errorMessage));
    } else if (commandMessage.getData() instanceof DumpSwitchPortsDescriptionRequest || commandMessage.getData() instanceof DumpPortDescriptionRequest || commandMessage.getData() instanceof DumpRulesRequest || commandMessage.getData() instanceof DumpMetersRequest || commandMessage.getData() instanceof DeleteMeterRequest || commandMessage.getData() instanceof PortConfigurationRequest) {
        getOutput().emit(Stream.NORTHBOUND_REPLY, input, makeNorthboundTuple(commandMessage.getCorrelationId(), errorMessage));
    } else {
        log.error("Unable to lookup region for message: {}. switch is not tracked.", commandMessage);
    }
}
Also used : RemoveFlowForSwitchManagerRequest(org.openkilda.messaging.command.flow.RemoveFlowForSwitchManagerRequest) ReinstallDefaultFlowForSwitchManagerRequest(org.openkilda.messaging.command.flow.ReinstallDefaultFlowForSwitchManagerRequest) InstallFlowForSwitchManagerRequest(org.openkilda.messaging.command.flow.InstallFlowForSwitchManagerRequest) DumpPortDescriptionRequest(org.openkilda.messaging.command.switches.DumpPortDescriptionRequest) SpeakerDataResponse(org.openkilda.floodlight.api.response.SpeakerDataResponse) DumpMetersRequest(org.openkilda.messaging.command.switches.DumpMetersRequest) PortConfigurationRequest(org.openkilda.messaging.command.switches.PortConfigurationRequest) DumpMetersForFlowHsRequest(org.openkilda.messaging.command.switches.DumpMetersForFlowHsRequest) DumpMetersForSwitchManagerRequest(org.openkilda.messaging.command.switches.DumpMetersForSwitchManagerRequest) DumpRulesRequest(org.openkilda.messaging.command.switches.DumpRulesRequest) DumpSwitchPortsDescriptionRequest(org.openkilda.messaging.command.switches.DumpSwitchPortsDescriptionRequest) DumpRulesForFlowHsRequest(org.openkilda.messaging.command.switches.DumpRulesForFlowHsRequest) MessageContext(org.openkilda.messaging.MessageContext) ErrorMessage(org.openkilda.messaging.error.ErrorMessage) DumpRulesForSwitchManagerRequest(org.openkilda.messaging.command.switches.DumpRulesForSwitchManagerRequest) DeleteMeterRequest(org.openkilda.messaging.command.flow.DeleteMeterRequest) ErrorData(org.openkilda.messaging.error.ErrorData) Tuple(org.apache.storm.tuple.Tuple)

Example 2 with ReinstallDefaultFlowForSwitchManagerRequest

use of org.openkilda.messaging.command.flow.ReinstallDefaultFlowForSwitchManagerRequest in project open-kilda by telstra.

the class CommandBuilderImplTest method reinstallServer42RuleTest.

@Test
public void reinstallServer42RuleTest() {
    List<ReinstallDefaultFlowForSwitchManagerRequest> commands = commandBuilder.buildCommandsToReinstallRules(SWITCH_ID_A, Lists.newArrayList(Cookie.SERVER_42_FLOW_RTT_OUTPUT_VLAN_COOKIE));
    assertEquals(1, commands.size());
    assertEquals(ReinstallServer42FlowForSwitchManagerRequest.class, commands.get(0).getClass());
    ReinstallServer42FlowForSwitchManagerRequest server42Command = (ReinstallServer42FlowForSwitchManagerRequest) commands.get(0);
    assertEquals(SERVER42_MAC_ADDRESS, server42Command.getServer42MacAddress());
    assertEquals(SERVER42_PORT, server42Command.getServer42Port());
    assertEquals(SERVER42_VLAN, server42Command.getServer42Vlan());
}
Also used : ReinstallDefaultFlowForSwitchManagerRequest(org.openkilda.messaging.command.flow.ReinstallDefaultFlowForSwitchManagerRequest) ReinstallServer42FlowForSwitchManagerRequest(org.openkilda.messaging.command.flow.ReinstallServer42FlowForSwitchManagerRequest) Test(org.junit.Test)

Example 3 with ReinstallDefaultFlowForSwitchManagerRequest

use of org.openkilda.messaging.command.flow.ReinstallDefaultFlowForSwitchManagerRequest in project open-kilda by telstra.

the class SwitchSyncFsm method sendRulesCommands.

protected void sendRulesCommands(SwitchSyncState from, SwitchSyncState to, SwitchSyncEvent event, Object context) {
    if (missingRules.isEmpty() && excessRules.isEmpty() && misconfiguredRules.isEmpty()) {
        log.info("Nothing to do with rules (switch={}, key={})", switchId, key);
        fire(NEXT);
        return;
    }
    if (!missingRules.isEmpty()) {
        log.info("Request to install switch rules has been sent (switch={}, key={})", switchId, key);
        missingRulesPendingResponsesCount = missingRules.size();
        for (BaseFlow command : missingRules) {
            carrier.sendCommandToSpeaker(key, new InstallFlowForSwitchManagerRequest(command));
        }
    }
    if (!excessRules.isEmpty()) {
        log.info("Request to remove switch rules has been sent (switch={}, key={})", switchId, key);
        excessRulesPendingResponsesCount = excessRules.size();
        for (RemoveFlow command : excessRules) {
            carrier.sendCommandToSpeaker(key, new RemoveFlowForSwitchManagerRequest(switchId, command));
        }
    }
    if (!misconfiguredRules.isEmpty()) {
        log.info("Request to reinstall default switch rules has been sent (switch={}, key={})", switchId, key);
        reinstallDefaultRulesPendingResponsesCount = misconfiguredRules.size();
        for (ReinstallDefaultFlowForSwitchManagerRequest command : misconfiguredRules) {
            carrier.sendCommandToSpeaker(key, command);
        }
    }
    continueIfRulesSynchronized();
}
Also used : RemoveFlowForSwitchManagerRequest(org.openkilda.messaging.command.flow.RemoveFlowForSwitchManagerRequest) ReinstallDefaultFlowForSwitchManagerRequest(org.openkilda.messaging.command.flow.ReinstallDefaultFlowForSwitchManagerRequest) RemoveFlow(org.openkilda.messaging.command.flow.RemoveFlow) BaseFlow(org.openkilda.messaging.command.flow.BaseFlow) InstallFlowForSwitchManagerRequest(org.openkilda.messaging.command.flow.InstallFlowForSwitchManagerRequest)

Example 4 with ReinstallDefaultFlowForSwitchManagerRequest

use of org.openkilda.messaging.command.flow.ReinstallDefaultFlowForSwitchManagerRequest in project open-kilda by telstra.

the class CommandBuilderImpl method buildCommandsToReinstallRules.

@Override
public List<ReinstallDefaultFlowForSwitchManagerRequest> buildCommandsToReinstallRules(SwitchId switchId, List<Long> reinstallRulesCookies) {
    SwitchProperties properties = getSwitchProperties(switchId);
    List<ReinstallDefaultFlowForSwitchManagerRequest> commands = new ArrayList<>();
    for (Long cookie : reinstallRulesCookies) {
        if (isDefaultRuleWithSpecialRequirements(cookie)) {
            commands.add(new ReinstallServer42FlowForSwitchManagerRequest(switchId, cookie, properties.getServer42MacAddress(), properties.getServer42Vlan(), properties.getServer42Port()));
        } else {
            commands.add(new ReinstallDefaultFlowForSwitchManagerRequest(switchId, cookie));
        }
    }
    return commands;
}
Also used : ReinstallDefaultFlowForSwitchManagerRequest(org.openkilda.messaging.command.flow.ReinstallDefaultFlowForSwitchManagerRequest) ArrayList(java.util.ArrayList) SwitchProperties(org.openkilda.model.SwitchProperties) ReinstallServer42FlowForSwitchManagerRequest(org.openkilda.messaging.command.flow.ReinstallServer42FlowForSwitchManagerRequest)

Example 5 with ReinstallDefaultFlowForSwitchManagerRequest

use of org.openkilda.messaging.command.flow.ReinstallDefaultFlowForSwitchManagerRequest in project open-kilda by telstra.

the class RecordHandler method handleCommand.

@VisibleForTesting
void handleCommand(CommandMessage message) {
    logger.debug("Handling message: '{}'.", message);
    CommandData data = message.getData();
    if (data instanceof DiscoverIslCommandData) {
        doDiscoverIslCommand((DiscoverIslCommandData) data, message.getCorrelationId());
    } else if (data instanceof DiscoverPathCommandData) {
        doDiscoverPathCommand(data);
    } else if (data instanceof RemoveFlowForSwitchManagerRequest) {
        doDeleteFlowForSwitchManager(message);
    } else if (data instanceof ModifyFlowMeterForSwitchManagerRequest) {
        doModifyFlowMeterForSwitchManager(message);
    } else if (data instanceof ModifyDefaultMeterForSwitchManagerRequest) {
        doModifyDefaultMeterForSwitchManager(message);
    } else if (data instanceof ReinstallDefaultFlowForSwitchManagerRequest) {
        doReinstallDefaultFlowForSwitchManager(message);
    } else if (data instanceof NetworkCommandData) {
        doNetworkDump((NetworkCommandData) data);
    } else if (data instanceof SwitchRulesDeleteRequest) {
        doDeleteSwitchRules(message);
    } else if (data instanceof SwitchRulesInstallRequest) {
        doInstallSwitchRules(message);
    } else if (data instanceof DumpRulesForFlowHsRequest) {
        doDumpRulesForFlowHsRequest(message);
    } else if (data instanceof DumpRulesRequest) {
        doDumpRulesRequest(message);
    } else if (data instanceof DumpRulesForSwitchManagerRequest) {
        doDumpRulesForSwitchManagerRequest(message);
    } else if (data instanceof InstallFlowForSwitchManagerRequest) {
        doInstallFlowForSwitchManager(message);
    } else if (data instanceof DeleterMeterForSwitchManagerRequest) {
        doDeleteMeter(message, context.getKafkaSwitchManagerTopic());
    } else if (data instanceof DeleteMeterRequest) {
        doDeleteMeter(message, context.getKafkaNorthboundTopic());
    } else if (data instanceof PortConfigurationRequest) {
        doConfigurePort(message);
    } else if (data instanceof DumpSwitchPortsDescriptionRequest) {
        doDumpSwitchPortsDescriptionRequest(message);
    } else if (data instanceof DumpPortDescriptionRequest) {
        doDumpPortDescriptionRequest(message);
    } else if (data instanceof DumpMetersRequest) {
        doDumpMetersRequest(message);
    } else if (data instanceof DumpMetersForSwitchManagerRequest) {
        doDumpMetersForSwitchManagerRequest(message);
    } else if (data instanceof DumpMetersForFlowHsRequest) {
        doDumpMetersForFlowHsRequest(message);
    } else if (data instanceof MeterModifyCommandRequest) {
        doModifyMeterRequest(message);
    } else if (data instanceof AliveRequest) {
        doAliveRequest(message);
    } else if (data instanceof InstallIslDefaultRulesCommand) {
        doInstallIslDefaultRule(message);
    } else if (data instanceof RemoveIslDefaultRulesCommand) {
        doRemoveIslDefaultRule(message);
    } else if (data instanceof DumpGroupsForSwitchManagerRequest) {
        doDumpGroupsForSwitchManagerRequest(message);
    } else if (data instanceof DumpGroupsForFlowHsRequest) {
        doDumpGroupsForFlowHsRequest(message);
    } else if (data instanceof InstallGroupRequest) {
        doInstallGroupRequest(message);
    } else if (data instanceof ModifyGroupRequest) {
        doModifyGroupRequest(message);
    } else if (data instanceof DeleteGroupRequest) {
        doDeleteGroupRequest(message);
    } else if (data instanceof BroadcastWrapper) {
        handleBroadcastCommand(message, (BroadcastWrapper) data);
    } else {
        handlerNotFound(data);
    }
}
Also used : DumpGroupsForFlowHsRequest(org.openkilda.messaging.command.switches.DumpGroupsForFlowHsRequest) RemoveFlowForSwitchManagerRequest(org.openkilda.messaging.command.flow.RemoveFlowForSwitchManagerRequest) InstallGroupRequest(org.openkilda.messaging.command.switches.InstallGroupRequest) DumpGroupsForSwitchManagerRequest(org.openkilda.messaging.command.switches.DumpGroupsForSwitchManagerRequest) InstallFlowForSwitchManagerRequest(org.openkilda.messaging.command.flow.InstallFlowForSwitchManagerRequest) InstallIslDefaultRulesCommand(org.openkilda.messaging.payload.switches.InstallIslDefaultRulesCommand) DumpMetersRequest(org.openkilda.messaging.command.switches.DumpMetersRequest) BroadcastWrapper(org.openkilda.messaging.command.BroadcastWrapper) DumpMetersForSwitchManagerRequest(org.openkilda.messaging.command.switches.DumpMetersForSwitchManagerRequest) DumpMetersForFlowHsRequest(org.openkilda.messaging.command.switches.DumpMetersForFlowHsRequest) DumpRulesRequest(org.openkilda.messaging.command.switches.DumpRulesRequest) ModifyDefaultMeterForSwitchManagerRequest(org.openkilda.messaging.command.flow.ModifyDefaultMeterForSwitchManagerRequest) DumpRulesForSwitchManagerRequest(org.openkilda.messaging.command.switches.DumpRulesForSwitchManagerRequest) ModifyGroupRequest(org.openkilda.messaging.command.switches.ModifyGroupRequest) DiscoverIslCommandData(org.openkilda.messaging.command.discovery.DiscoverIslCommandData) ReinstallDefaultFlowForSwitchManagerRequest(org.openkilda.messaging.command.flow.ReinstallDefaultFlowForSwitchManagerRequest) SwitchRulesInstallRequest(org.openkilda.messaging.command.switches.SwitchRulesInstallRequest) DumpPortDescriptionRequest(org.openkilda.messaging.command.switches.DumpPortDescriptionRequest) RemoveIslDefaultRulesCommand(org.openkilda.messaging.payload.switches.RemoveIslDefaultRulesCommand) ModifyFlowMeterForSwitchManagerRequest(org.openkilda.messaging.command.flow.ModifyFlowMeterForSwitchManagerRequest) DeleteGroupRequest(org.openkilda.messaging.command.switches.DeleteGroupRequest) PortConfigurationRequest(org.openkilda.messaging.command.switches.PortConfigurationRequest) DeleterMeterForSwitchManagerRequest(org.openkilda.messaging.command.switches.DeleterMeterForSwitchManagerRequest) DumpSwitchPortsDescriptionRequest(org.openkilda.messaging.command.switches.DumpSwitchPortsDescriptionRequest) DumpRulesForFlowHsRequest(org.openkilda.messaging.command.switches.DumpRulesForFlowHsRequest) MeterModifyCommandRequest(org.openkilda.messaging.command.flow.MeterModifyCommandRequest) SwitchRulesDeleteRequest(org.openkilda.messaging.command.switches.SwitchRulesDeleteRequest) NetworkCommandData(org.openkilda.messaging.command.discovery.NetworkCommandData) DiscoverIslCommandData(org.openkilda.messaging.command.discovery.DiscoverIslCommandData) PortsCommandData(org.openkilda.messaging.command.discovery.PortsCommandData) DiscoverPathCommandData(org.openkilda.messaging.command.discovery.DiscoverPathCommandData) CommandData(org.openkilda.messaging.command.CommandData) NetworkCommandData(org.openkilda.messaging.command.discovery.NetworkCommandData) DeleteMeterRequest(org.openkilda.messaging.command.flow.DeleteMeterRequest) AliveRequest(org.openkilda.messaging.AliveRequest) DiscoverPathCommandData(org.openkilda.messaging.command.discovery.DiscoverPathCommandData) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

ReinstallDefaultFlowForSwitchManagerRequest (org.openkilda.messaging.command.flow.ReinstallDefaultFlowForSwitchManagerRequest)6 InstallFlowForSwitchManagerRequest (org.openkilda.messaging.command.flow.InstallFlowForSwitchManagerRequest)3 ReinstallServer42FlowForSwitchManagerRequest (org.openkilda.messaging.command.flow.ReinstallServer42FlowForSwitchManagerRequest)3 RemoveFlowForSwitchManagerRequest (org.openkilda.messaging.command.flow.RemoveFlowForSwitchManagerRequest)3 DeleteMeterRequest (org.openkilda.messaging.command.flow.DeleteMeterRequest)2 RemoveFlow (org.openkilda.messaging.command.flow.RemoveFlow)2 DumpMetersForFlowHsRequest (org.openkilda.messaging.command.switches.DumpMetersForFlowHsRequest)2 DumpMetersForSwitchManagerRequest (org.openkilda.messaging.command.switches.DumpMetersForSwitchManagerRequest)2 DumpMetersRequest (org.openkilda.messaging.command.switches.DumpMetersRequest)2 DumpPortDescriptionRequest (org.openkilda.messaging.command.switches.DumpPortDescriptionRequest)2 DumpRulesForFlowHsRequest (org.openkilda.messaging.command.switches.DumpRulesForFlowHsRequest)2 DumpRulesForSwitchManagerRequest (org.openkilda.messaging.command.switches.DumpRulesForSwitchManagerRequest)2 DumpRulesRequest (org.openkilda.messaging.command.switches.DumpRulesRequest)2 DumpSwitchPortsDescriptionRequest (org.openkilda.messaging.command.switches.DumpSwitchPortsDescriptionRequest)2 PortConfigurationRequest (org.openkilda.messaging.command.switches.PortConfigurationRequest)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Tuple (org.apache.storm.tuple.Tuple)1 Test (org.junit.Test)1