Search in sources :

Example 1 with InstallOneSwitchFlow

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

the class RecordHandler method doProcessOneSwitchFlow.

/**
 * Processes one-switch flow installing message.
 *
 * @param message command message for flow installation
 */
private void doProcessOneSwitchFlow(final CommandMessage message, String replyToTopic, Destination replyDestination) throws FlowCommandException {
    InstallOneSwitchFlow command = (InstallOneSwitchFlow) message.getData();
    logger.debug("creating a flow through one switch: {}", command);
    try {
        installOneSwitchFlow(command);
        message.setDestination(replyDestination);
        context.getKafkaProducer().postMessage(replyToTopic, message);
    } catch (SwitchOperationException e) {
        throw new FlowCommandException(command.getId(), ErrorType.CREATION_FAILURE, e);
    }
}
Also used : SwitchOperationException(org.openkilda.floodlight.switchmanager.SwitchOperationException) InstallOneSwitchFlow(org.openkilda.messaging.command.flow.InstallOneSwitchFlow)

Example 2 with InstallOneSwitchFlow

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

the class RecordHandler method doSyncRulesRequest.

/**
 * Installs missed flows on the switch.
 * @param message with list of flows.
 */
private void doSyncRulesRequest(final CommandMessage message) {
    InstallMissedFlowsRequest request = (InstallMissedFlowsRequest) message.getData();
    final String switchId = request.getSwitchId();
    logger.debug("Processing rules to be updated for switch {}", switchId);
    for (BaseInstallFlow command : request.getFlowCommands()) {
        logger.debug("Processing command for switch {} {}", switchId, command);
        try {
            if (command instanceof InstallIngressFlow) {
                installIngressFlow((InstallIngressFlow) command);
            } else if (command instanceof InstallEgressFlow) {
                installEgressFlow((InstallEgressFlow) command);
            } else if (command instanceof InstallTransitFlow) {
                installTransitFlow((InstallTransitFlow) command);
            } else if (command instanceof InstallOneSwitchFlow) {
                installOneSwitchFlow((InstallOneSwitchFlow) command);
            }
        } catch (SwitchOperationException e) {
            logger.error("Error during flow installation", e);
        }
    }
}
Also used : InstallIngressFlow(org.openkilda.messaging.command.flow.InstallIngressFlow) SwitchOperationException(org.openkilda.floodlight.switchmanager.SwitchOperationException) InstallTransitFlow(org.openkilda.messaging.command.flow.InstallTransitFlow) InstallMissedFlowsRequest(org.openkilda.messaging.command.switches.InstallMissedFlowsRequest) InstallOneSwitchFlow(org.openkilda.messaging.command.flow.InstallOneSwitchFlow) BaseInstallFlow(org.openkilda.messaging.command.flow.BaseInstallFlow) InstallEgressFlow(org.openkilda.messaging.command.flow.InstallEgressFlow)

Example 3 with InstallOneSwitchFlow

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

the class ReplaceInstallFlowTest method installOneSwitchReplaceFlow.

@Test
public void installOneSwitchReplaceFlow() throws IOException, InterruptedException {
    String value = Resources.toString(getClass().getResource("/install_one_switch_replace_flow.json"), Charsets.UTF_8);
    InstallOneSwitchFlow data = (InstallOneSwitchFlow) prepareData(value);
    OFMeterMod meterCommand = scheme.installMeter(data.getBandwidth(), 1024, data.getMeterId());
    OFFlowAdd flowCommand = scheme.oneSwitchReplaceFlowMod(data.getInputPort(), data.getOutputPort(), data.getInputVlanId(), data.getOutputVlanId(), data.getMeterId(), 123L);
    runTest(value, flowCommand, meterCommand, null, null);
}
Also used : InstallOneSwitchFlow(org.openkilda.messaging.command.flow.InstallOneSwitchFlow) OFMeterMod(org.projectfloodlight.openflow.protocol.OFMeterMod) OFFlowAdd(org.projectfloodlight.openflow.protocol.OFFlowAdd) Test(org.junit.Test)

Example 4 with InstallOneSwitchFlow

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

the class ReplaceInstallFlowTest method installOneSwitchPushFlow.

@Test
public void installOneSwitchPushFlow() throws IOException, InterruptedException {
    String value = Resources.toString(getClass().getResource("/install_one_switch_push_flow.json"), Charsets.UTF_8);
    InstallOneSwitchFlow data = (InstallOneSwitchFlow) prepareData(value);
    OFMeterMod meterCommand = scheme.installMeter(data.getBandwidth(), 1024, data.getMeterId());
    OFFlowAdd flowCommand = scheme.oneSwitchPushFlowMod(data.getInputPort(), data.getOutputPort(), data.getOutputVlanId(), data.getMeterId(), 123L);
    runTest(value, flowCommand, meterCommand, null, null);
}
Also used : InstallOneSwitchFlow(org.openkilda.messaging.command.flow.InstallOneSwitchFlow) OFMeterMod(org.projectfloodlight.openflow.protocol.OFMeterMod) OFFlowAdd(org.projectfloodlight.openflow.protocol.OFFlowAdd) Test(org.junit.Test)

Example 5 with InstallOneSwitchFlow

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

the class ReplaceInstallFlowTest method installOneSwitchPopFlow.

@Test
public void installOneSwitchPopFlow() throws IOException, InterruptedException {
    String value = Resources.toString(getClass().getResource("/install_one_switch_pop_flow.json"), Charsets.UTF_8);
    InstallOneSwitchFlow data = (InstallOneSwitchFlow) prepareData(value);
    OFMeterMod meterCommand = scheme.installMeter(data.getBandwidth(), 1024, data.getMeterId());
    OFFlowAdd flowCommand = scheme.oneSwitchPopFlowMod(data.getInputPort(), data.getOutputPort(), data.getInputVlanId(), data.getMeterId(), 123L);
    runTest(value, flowCommand, meterCommand, null, null);
}
Also used : InstallOneSwitchFlow(org.openkilda.messaging.command.flow.InstallOneSwitchFlow) OFMeterMod(org.projectfloodlight.openflow.protocol.OFMeterMod) OFFlowAdd(org.projectfloodlight.openflow.protocol.OFFlowAdd) Test(org.junit.Test)

Aggregations

InstallOneSwitchFlow (org.openkilda.messaging.command.flow.InstallOneSwitchFlow)8 Test (org.junit.Test)5 OFFlowAdd (org.projectfloodlight.openflow.protocol.OFFlowAdd)4 OFMeterMod (org.projectfloodlight.openflow.protocol.OFMeterMod)4 SwitchOperationException (org.openkilda.floodlight.switchmanager.SwitchOperationException)2 CommandMessage (org.openkilda.messaging.command.CommandMessage)2 BaseInstallFlow (org.openkilda.messaging.command.flow.BaseInstallFlow)1 InstallEgressFlow (org.openkilda.messaging.command.flow.InstallEgressFlow)1 InstallIngressFlow (org.openkilda.messaging.command.flow.InstallIngressFlow)1 InstallTransitFlow (org.openkilda.messaging.command.flow.InstallTransitFlow)1 InstallMissedFlowsRequest (org.openkilda.messaging.command.switches.InstallMissedFlowsRequest)1 InfoMessage (org.openkilda.messaging.info.InfoMessage)1 FlowStatusResponse (org.openkilda.messaging.info.flow.FlowStatusResponse)1 FlowIdStatusPayload (org.openkilda.messaging.payload.flow.FlowIdStatusPayload)1 AbstractStormTest (org.openkilda.wfm.AbstractStormTest)1