Search in sources :

Example 1 with InstallFlowForSwitchManagerRequest

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

the class RecordHandlerTest method shouldInstallServer42IslRttInputRule.

@Test
public void shouldInstallServer42IslRttInputRule() throws SwitchOperationException {
    int islPort = 123;
    PortColourCookie cookie = PortColourCookie.builder().portNumber(islPort).type(SERVER_42_ISL_RTT_INPUT).build();
    expect(switchManager.installServer42IslRttInputFlow(DATAPATH_ID, SERVER42_PORT, islPort)).andReturn(cookie.getValue()).once();
    replay(switchManager);
    InstallServer42Flow request = InstallServer42Flow.builder().id("test").switchId(SWITCH_ID).cookie(cookie.getValue()).inputPort(SERVER42_PORT).outputPort(0).server42MacAddress(SERVER42_MAC_ADDRESS).server42Vlan(SERVER42_VLAN).build();
    recordHandler.handleCommand(new CommandMessage(new InstallFlowForSwitchManagerRequest(request), 0, CORRELATION_ID));
    verify(switchManager);
}
Also used : InstallFlowForSwitchManagerRequest(org.openkilda.messaging.command.flow.InstallFlowForSwitchManagerRequest) PortColourCookie(org.openkilda.model.cookie.PortColourCookie) InstallServer42Flow(org.openkilda.messaging.command.flow.InstallServer42Flow) CommandMessage(org.openkilda.messaging.command.CommandMessage) Test(org.junit.Test)

Example 2 with InstallFlowForSwitchManagerRequest

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

the class RecordHandlerTest method installServer42SharedTest.

@Test
public void installServer42SharedTest() throws SwitchOperationException {
    FlowSharedSegmentCookie cookie = FlowSharedSegmentCookie.builder(SharedSegmentType.SERVER42_QINQ_OUTER_VLAN).portNumber(SERVER42_PORT).vlanId(VLAN_1).build();
    switchManager.installServer42OuterVlanMatchSharedFlow(DATAPATH_ID, cookie);
    expectLastCall().once();
    replay(switchManager);
    InstallServer42Flow request = InstallServer42Flow.builder().id("shared").switchId(SWITCH_ID).cookie(cookie.getValue()).inputPort(SERVER42_PORT).outputPort(0).build();
    recordHandler.handleCommand(new CommandMessage(new InstallFlowForSwitchManagerRequest(request), 0, CORRELATION_ID));
    verify(switchManager);
}
Also used : FlowSharedSegmentCookie(org.openkilda.model.cookie.FlowSharedSegmentCookie) InstallFlowForSwitchManagerRequest(org.openkilda.messaging.command.flow.InstallFlowForSwitchManagerRequest) InstallServer42Flow(org.openkilda.messaging.command.flow.InstallServer42Flow) CommandMessage(org.openkilda.messaging.command.CommandMessage) Test(org.junit.Test)

Example 3 with InstallFlowForSwitchManagerRequest

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

the class RecordHandlerTest method shouldInstallServer42IslRttOutputRule.

@Test
public void shouldInstallServer42IslRttOutputRule() throws SwitchOperationException {
    long cookie = SERVER_42_ISL_RTT_OUTPUT_COOKIE;
    expect(switchManager.installServer42IslRttOutputFlow(DATAPATH_ID, SERVER42_PORT, SERVER42_VLAN, SERVER42_MAC_ADDRESS)).andReturn(cookie).once();
    replay(switchManager);
    InstallServer42Flow request = InstallServer42Flow.builder().id("test").switchId(SWITCH_ID).cookie(cookie).inputPort(0).outputPort(SERVER42_PORT).server42MacAddress(SERVER42_MAC_ADDRESS).server42Vlan(SERVER42_VLAN).build();
    recordHandler.handleCommand(new CommandMessage(new InstallFlowForSwitchManagerRequest(request), 0, CORRELATION_ID));
    verify(switchManager);
}
Also used : InstallFlowForSwitchManagerRequest(org.openkilda.messaging.command.flow.InstallFlowForSwitchManagerRequest) InstallServer42Flow(org.openkilda.messaging.command.flow.InstallServer42Flow) CommandMessage(org.openkilda.messaging.command.CommandMessage) Test(org.junit.Test)

Example 4 with InstallFlowForSwitchManagerRequest

use of org.openkilda.messaging.command.flow.InstallFlowForSwitchManagerRequest 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 5 with InstallFlowForSwitchManagerRequest

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

Aggregations

InstallFlowForSwitchManagerRequest (org.openkilda.messaging.command.flow.InstallFlowForSwitchManagerRequest)10 Test (org.junit.Test)6 CommandMessage (org.openkilda.messaging.command.CommandMessage)6 InstallServer42Flow (org.openkilda.messaging.command.flow.InstallServer42Flow)6 ReinstallDefaultFlowForSwitchManagerRequest (org.openkilda.messaging.command.flow.ReinstallDefaultFlowForSwitchManagerRequest)3 RemoveFlowForSwitchManagerRequest (org.openkilda.messaging.command.flow.RemoveFlowForSwitchManagerRequest)3 MessageContext (org.openkilda.messaging.MessageContext)2 DeleteMeterRequest (org.openkilda.messaging.command.flow.DeleteMeterRequest)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 Tuple (org.apache.storm.tuple.Tuple)1 SpeakerDataResponse (org.openkilda.floodlight.api.response.SpeakerDataResponse)1