Search in sources :

Example 1 with SwitchErrorResponseException

use of org.openkilda.floodlight.error.SwitchErrorResponseException in project open-kilda by telstra.

the class TransitFlowSegmentCommandTest method errorOnFlowMod.

@Test
public void errorOnFlowMod() {
    switchFeaturesSetup(sw, true);
    replayAll();
    TransitFlowSegmentCommand command = makeCommand(encapsulationVlan);
    CompletableFuture<FlowSegmentReport> result = command.execute(commandProcessor);
    getWriteRecord(0).getFuture().completeExceptionally(new SwitchErrorResponseException(dpIdNext, of.errorMsgs().buildBadRequestErrorMsg().setCode(OFBadRequestCode.BAD_LEN).build()));
    verifyErrorCompletion(result, SwitchOperationException.class);
}
Also used : SwitchErrorResponseException(org.openkilda.floodlight.error.SwitchErrorResponseException) FlowSegmentReport(org.openkilda.floodlight.command.flow.FlowSegmentReport) Test(org.junit.Test) AbstractSpeakerCommandTest(org.openkilda.floodlight.command.AbstractSpeakerCommandTest)

Example 2 with SwitchErrorResponseException

use of org.openkilda.floodlight.error.SwitchErrorResponseException in project open-kilda by telstra.

the class EgressFlowSegmentCommandTest method errorOnFlowMod.

@Test
public void errorOnFlowMod() {
    switchFeaturesSetup(sw, true);
    replayAll();
    FlowEndpoint ingressEndpoint = new FlowEndpoint(mapSwitchId(dpId), 1, 0);
    EgressFlowSegmentCommand command = makeCommand(endpointEgressZeroVlan, ingressEndpoint, encapsulationVlan);
    CompletableFuture<FlowSegmentReport> result = command.execute(commandProcessor);
    getWriteRecord(0).getFuture().completeExceptionally(new SwitchErrorResponseException(dpIdNext, of.errorMsgs().buildBadRequestErrorMsg().setCode(OFBadRequestCode.BAD_LEN).build()));
    verifyErrorCompletion(result, SwitchOperationException.class);
}
Also used : FlowEndpoint(org.openkilda.model.FlowEndpoint) SwitchErrorResponseException(org.openkilda.floodlight.error.SwitchErrorResponseException) FlowSegmentReport(org.openkilda.floodlight.command.flow.FlowSegmentReport) Test(org.junit.Test) AbstractSpeakerCommandTest(org.openkilda.floodlight.command.AbstractSpeakerCommandTest)

Example 3 with SwitchErrorResponseException

use of org.openkilda.floodlight.error.SwitchErrorResponseException in project open-kilda by telstra.

the class IngressCommandInstallTest method errorOnMeterManipulation.

@Test
public void errorOnMeterManipulation() {
    switchFeaturesSetup(sw, true);
    expectMeterInstall(new SwitchErrorResponseException(dpIdNext, "fake fail to install meter error"));
    expectNoMoreOfMessages();
    reset(sessionService);
    reset(session);
    replayAll();
    IngressFlowSegmentBase command = makeCommand(endpointIngressSingleVlan, meterConfig, makeMetadata());
    CompletableFuture<FlowSegmentReport> result = command.execute(commandProcessor);
    verifyErrorCompletion(result, SwitchErrorResponseException.class);
}
Also used : SwitchErrorResponseException(org.openkilda.floodlight.error.SwitchErrorResponseException) FlowSegmentReport(org.openkilda.floodlight.command.flow.FlowSegmentReport) Test(org.junit.Test)

Example 4 with SwitchErrorResponseException

use of org.openkilda.floodlight.error.SwitchErrorResponseException in project open-kilda by telstra.

the class MeterInstallCommand method handleOfError.

@Override
public CompletableFuture<Optional<OFMessage>> handleOfError(OFErrorMsg response) {
    CompletableFuture<Optional<OFMessage>> future = new CompletableFuture<>();
    if (!isInstallConflict(response)) {
        future.completeExceptionally(new SwitchErrorResponseException(getSw().getId(), String.format("Can't install meter %s - %s", meterConfig.getId(), response)));
        return future;
    }
    log.info("Meter conflict detected sw:{} meter:{}", getSw().getId(), meterConfig.getId());
    MeterVerifyCommand verifyCommand = new MeterVerifyCommand(messageContext, switchId, meterConfig);
    propagateFutureResponse(future, commandProcessor.chain(verifyCommand).thenAccept(this::handleMeterVerify).thenApply(ignore -> Optional.empty()));
    return future;
}
Also used : SwitchMissingMeterException(org.openkilda.floodlight.error.SwitchMissingMeterException) OFMeterModFailedErrorMsg(org.projectfloodlight.openflow.protocol.errormsg.OFMeterModFailedErrorMsg) Getter(lombok.Getter) InvalidMeterIdException(org.openkilda.floodlight.error.InvalidMeterIdException) Session(org.openkilda.floodlight.service.session.Session) OFMeterModFailedCode(org.projectfloodlight.openflow.protocol.OFMeterModFailedCode) MessageContext(org.openkilda.messaging.MessageContext) CompletableFuture(java.util.concurrent.CompletableFuture) SwitchIncorrectMeterException(org.openkilda.floodlight.error.SwitchIncorrectMeterException) UnsupportedSwitchOperationException(org.openkilda.floodlight.error.UnsupportedSwitchOperationException) MeterId(org.openkilda.model.MeterId) SwitchId(org.openkilda.model.SwitchId) SpeakerCommandProcessor(org.openkilda.floodlight.command.SpeakerCommandProcessor) OFMeterMod(org.projectfloodlight.openflow.protocol.OFMeterMod) MeterConfig(org.openkilda.model.MeterConfig) OFMessage(org.projectfloodlight.openflow.protocol.OFMessage) Optional(java.util.Optional) OFErrorMsg(org.projectfloodlight.openflow.protocol.OFErrorMsg) IOfErrorResponseHandler(org.openkilda.floodlight.command.IOfErrorResponseHandler) SwitchErrorResponseException(org.openkilda.floodlight.error.SwitchErrorResponseException) SwitchMeterConflictException(org.openkilda.floodlight.error.SwitchMeterConflictException) CompletableFuture(java.util.concurrent.CompletableFuture) Optional(java.util.Optional) SwitchErrorResponseException(org.openkilda.floodlight.error.SwitchErrorResponseException)

Example 5 with SwitchErrorResponseException

use of org.openkilda.floodlight.error.SwitchErrorResponseException in project open-kilda by telstra.

the class GroupInstallCommand method handleOfError.

@Override
public CompletableFuture<Optional<OFMessage>> handleOfError(OFErrorMsg response) {
    CompletableFuture<Optional<OFMessage>> future = new CompletableFuture<>();
    if (!isInstallConflict(response)) {
        future.completeExceptionally(new SwitchErrorResponseException(getSw().getId(), String.format("Can't install group %s - %s", mirrorConfig.getGroupId(), response)));
        return future;
    }
    log.info("Group conflict detected sw:{} group:{}", getSw().getId(), mirrorConfig.getGroupId());
    GroupVerifyCommand verifyCommand = new GroupVerifyCommand(messageContext, switchId, mirrorConfig, flowTransitData);
    propagateFutureResponse(future, commandProcessor.chain(verifyCommand).thenAccept(this::handleGroupVerify).thenApply(ignore -> Optional.empty()));
    return future;
}
Also used : MirrorConfig(org.openkilda.model.MirrorConfig) Getter(lombok.Getter) Session(org.openkilda.floodlight.service.session.Session) OFGroupMod(org.projectfloodlight.openflow.protocol.OFGroupMod) FlowTransitData(org.openkilda.floodlight.model.FlowTransitData) MessageContext(org.openkilda.messaging.MessageContext) CompletableFuture(java.util.concurrent.CompletableFuture) InvalidGroupIdException(org.openkilda.floodlight.error.InvalidGroupIdException) OFGroupModFailedErrorMsg(org.projectfloodlight.openflow.protocol.errormsg.OFGroupModFailedErrorMsg) SwitchIncorrectMirrorGroupException(org.openkilda.floodlight.error.SwitchIncorrectMirrorGroupException) UnsupportedSwitchOperationException(org.openkilda.floodlight.error.UnsupportedSwitchOperationException) OFGroupModFailedCode(org.projectfloodlight.openflow.protocol.OFGroupModFailedCode) SwitchId(org.openkilda.model.SwitchId) SpeakerCommandProcessor(org.openkilda.floodlight.command.SpeakerCommandProcessor) SwitchGroupConflictException(org.openkilda.floodlight.error.SwitchGroupConflictException) OFMessage(org.projectfloodlight.openflow.protocol.OFMessage) Optional(java.util.Optional) SwitchMissingGroupException(org.openkilda.floodlight.error.SwitchMissingGroupException) OFErrorMsg(org.projectfloodlight.openflow.protocol.OFErrorMsg) IOfErrorResponseHandler(org.openkilda.floodlight.command.IOfErrorResponseHandler) GroupId(org.openkilda.model.GroupId) SwitchErrorResponseException(org.openkilda.floodlight.error.SwitchErrorResponseException) CompletableFuture(java.util.concurrent.CompletableFuture) Optional(java.util.Optional) SwitchErrorResponseException(org.openkilda.floodlight.error.SwitchErrorResponseException)

Aggregations

SwitchErrorResponseException (org.openkilda.floodlight.error.SwitchErrorResponseException)9 Test (org.junit.Test)6 FlowSegmentReport (org.openkilda.floodlight.command.flow.FlowSegmentReport)6 Optional (java.util.Optional)3 CompletableFuture (java.util.concurrent.CompletableFuture)3 EffectiveIds (org.openkilda.floodlight.model.EffectiveIds)3 Getter (lombok.Getter)2 AbstractSpeakerCommandTest (org.openkilda.floodlight.command.AbstractSpeakerCommandTest)2 IOfErrorResponseHandler (org.openkilda.floodlight.command.IOfErrorResponseHandler)2 SpeakerCommandProcessor (org.openkilda.floodlight.command.SpeakerCommandProcessor)2 UnsupportedSwitchOperationException (org.openkilda.floodlight.error.UnsupportedSwitchOperationException)2 Session (org.openkilda.floodlight.service.session.Session)2 MessageContext (org.openkilda.messaging.MessageContext)2 SwitchId (org.openkilda.model.SwitchId)2 OFErrorMsg (org.projectfloodlight.openflow.protocol.OFErrorMsg)2 OFMessage (org.projectfloodlight.openflow.protocol.OFMessage)2 InvalidGroupIdException (org.openkilda.floodlight.error.InvalidGroupIdException)1 InvalidMeterIdException (org.openkilda.floodlight.error.InvalidMeterIdException)1 SwitchGroupConflictException (org.openkilda.floodlight.error.SwitchGroupConflictException)1 SwitchIncorrectMeterException (org.openkilda.floodlight.error.SwitchIncorrectMeterException)1