Search in sources :

Example 1 with InstallTransitFlow

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

the class TestUtils method createTopology.

public static Set<CommandMessage> createTopology(final SwitchService switchService, final IslService islService) {
    Set<CommandMessage> commands = new HashSet<>();
    switchService.add(new SwitchInfoData(srcSwitchId, SwitchEventType.ADDED, address, name, "OVS 1"));
    switchService.add(new SwitchInfoData(firstTransitSwitchId, SwitchEventType.ADDED, address, name, "OVS 2"));
    switchService.add(new SwitchInfoData(secondTransitSwitchId, SwitchEventType.ADDED, address, name, "OVS 1"));
    switchService.add(new SwitchInfoData(dstSwitchId, SwitchEventType.ADDED, address, name, "OVS 2"));
    switchService.activate(new SwitchInfoData(srcSwitchId, SwitchEventType.ACTIVATED, address, name, "OVS 1"));
    switchService.activate(new SwitchInfoData(firstTransitSwitchId, SwitchEventType.ACTIVATED, address, name, "OVS 2"));
    switchService.activate(new SwitchInfoData(secondTransitSwitchId, SwitchEventType.ACTIVATED, address, name, "OVS 1"));
    switchService.activate(new SwitchInfoData(dstSwitchId, SwitchEventType.ACTIVATED, address, name, "OVS 2"));
    PathNode srcNode;
    PathNode dstNode;
    List<PathNode> list;
    srcNode = new PathNode(srcSwitchId, 1, 0);
    dstNode = new PathNode(firstTransitSwitchId, 2, 1);
    list = asList(srcNode, dstNode);
    islService.discoverLink(new IslInfoData(10L, list, portSpeed));
    islService.discoverLink(new IslInfoData(10L, Lists.reverse(list), portSpeed));
    srcNode = new PathNode(firstTransitSwitchId, 1, 0);
    dstNode = new PathNode(secondTransitSwitchId, 2, 1);
    list = asList(srcNode, dstNode);
    islService.discoverLink(new IslInfoData(10L, list, portSpeed));
    islService.discoverLink(new IslInfoData(10L, Lists.reverse(list), portSpeed));
    srcNode = new PathNode(secondTransitSwitchId, 1, 0);
    dstNode = new PathNode(dstSwitchId, 2, 1);
    list = asList(srcNode, dstNode);
    islService.discoverLink(new IslInfoData(10L, list, portSpeed));
    islService.discoverLink(new IslInfoData(10L, Lists.reverse(list), portSpeed));
    commands.add(new CommandMessage(new InstallIngressFlow(0L, flowId, COOKIE, srcSwitchId, DIRECT_INCOMING_PORT, DIRECT_OUTGOING_PORT, INPUT_VLAN_ID, TRANSIT_VLAN_ID, OutputVlanType.REPLACE, 10000L, 0L), METER_ID, DEFAULT_CORRELATION_ID, Destination.WFM));
    commands.add(new CommandMessage(new InstallTransitFlow(0L, flowId, COOKIE, firstTransitSwitchId, DIRECT_INCOMING_PORT, DIRECT_OUTGOING_PORT, TRANSIT_VLAN_ID), 0L, DEFAULT_CORRELATION_ID, Destination.WFM));
    commands.add(new CommandMessage(new InstallTransitFlow(0L, flowId, COOKIE, secondTransitSwitchId, DIRECT_INCOMING_PORT, DIRECT_OUTGOING_PORT, TRANSIT_VLAN_ID), 0L, DEFAULT_CORRELATION_ID, Destination.WFM));
    commands.add(new CommandMessage(new InstallEgressFlow(0L, flowId, COOKIE, dstSwitchId, DIRECT_INCOMING_PORT, DIRECT_OUTGOING_PORT, TRANSIT_VLAN_ID, OUTPUT_VLAN_ID, OutputVlanType.REPLACE), 0L, DEFAULT_CORRELATION_ID, Destination.WFM));
    commands.add(new CommandMessage(new InstallIngressFlow(0L, flowId, COOKIE, srcSwitchId, REVERSE_INGOING_PORT, REVERSE_OUTGOING_PORT, OUTPUT_VLAN_ID, TRANSIT_VLAN_ID, OutputVlanType.REPLACE, 10000L, 0L), METER_ID, DEFAULT_CORRELATION_ID, Destination.WFM));
    commands.add(new CommandMessage(new InstallTransitFlow(0L, flowId, COOKIE, srcSwitchId, REVERSE_INGOING_PORT, REVERSE_OUTGOING_PORT, TRANSIT_VLAN_ID), 0L, DEFAULT_CORRELATION_ID, Destination.WFM));
    commands.add(new CommandMessage(new InstallTransitFlow(0L, flowId, COOKIE, srcSwitchId, REVERSE_INGOING_PORT, REVERSE_OUTGOING_PORT, TRANSIT_VLAN_ID), 0L, DEFAULT_CORRELATION_ID, Destination.WFM));
    commands.add(new CommandMessage(new InstallEgressFlow(0L, flowId, COOKIE, srcSwitchId, REVERSE_INGOING_PORT, REVERSE_OUTGOING_PORT, 2, INPUT_VLAN_ID, OutputVlanType.REPLACE), 0L, DEFAULT_CORRELATION_ID, Destination.WFM));
    return commands;
}
Also used : InstallIngressFlow(org.openkilda.messaging.command.flow.InstallIngressFlow) InstallTransitFlow(org.openkilda.messaging.command.flow.InstallTransitFlow) IslInfoData(org.openkilda.messaging.info.event.IslInfoData) SwitchInfoData(org.openkilda.messaging.info.event.SwitchInfoData) PathNode(org.openkilda.messaging.info.event.PathNode) InstallEgressFlow(org.openkilda.messaging.command.flow.InstallEgressFlow) CommandMessage(org.openkilda.messaging.command.CommandMessage) HashSet(java.util.HashSet)

Example 2 with InstallTransitFlow

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

the class RecordHandler method doProcessTransitFlow.

/**
 * Processes transit flow installing message.
 *
 * @param message command message for flow installation
 */
private void doProcessTransitFlow(final CommandMessage message, String replyToTopic, Destination replyDestination) throws FlowCommandException {
    InstallTransitFlow command = (InstallTransitFlow) message.getData();
    try {
        installTransitFlow(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) InstallTransitFlow(org.openkilda.messaging.command.flow.InstallTransitFlow)

Example 3 with InstallTransitFlow

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

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

the class ReplaceInstallFlowTest method installTransitFlow.

@Test
public void installTransitFlow() throws IOException, InterruptedException {
    String value = Resources.toString(getClass().getResource("/install_transit_flow.json"), Charsets.UTF_8);
    InstallTransitFlow data = (InstallTransitFlow) prepareData(value);
    OFFlowAdd flowCommand = scheme.transitFlowMod(data.getInputPort(), data.getOutputPort(), data.getTransitVlanId(), 123L);
    runTest(value, flowCommand, null, null, null);
}
Also used : InstallTransitFlow(org.openkilda.messaging.command.flow.InstallTransitFlow) OFFlowAdd(org.projectfloodlight.openflow.protocol.OFFlowAdd) Test(org.junit.Test)

Example 5 with InstallTransitFlow

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

the class Flow method getInstallationCommands.

/**
 * Returns set of installation commands.
 *
 * @param path          sorted path
 * @param correlationId correlation id
 * @return set of {@link CommandMessage} instances
 */
public Set<CommandMessage> getInstallationCommands(final List<Isl> path, final String correlationId) {
    Set<CommandMessage> commands = new HashSet<>();
    Isl firstIsl = path.get(0);
    Isl lastIsl = path.get(path.size() - 1);
    if ((cookie & DIRECT_FLOW_COOKIE) == DIRECT_FLOW_COOKIE) {
        commands.add(new CommandMessage(new InstallIngressFlow(0L, flowId, cookie, sourceSwitch, sourcePort, firstIsl.getSourcePort(), sourceVlan, transitVlan, flowType, bandwidth, 0L), now(), correlationId, Destination.WFM));
        commands.add(new CommandMessage(new InstallEgressFlow(0L, flowId, cookie, destinationSwitch, lastIsl.getDestinationPort(), destinationPort, transitVlan, destinationVlan, flowType), now(), correlationId, Destination.WFM));
    } else {
        commands.add(new CommandMessage(new InstallIngressFlow(0L, flowId, cookie, destinationSwitch, sourcePort, lastIsl.getDestinationPort(), destinationVlan, transitVlan, getReverseFlowType(flowType), bandwidth, 0L), now(), correlationId, Destination.WFM));
        commands.add(new CommandMessage(new InstallEgressFlow(0L, flowId, cookie, sourceSwitch, firstIsl.getSourcePort(), sourcePort, transitVlan, sourceVlan, getReverseFlowType(flowType)), now(), correlationId, Destination.WFM));
    }
    for (int i = 0; i < path.size() - 1; i++) {
        Isl currentIsl = path.get(i);
        Isl nextIsl = path.get(i + 1);
        if ((cookie & DIRECT_FLOW_COOKIE) == DIRECT_FLOW_COOKIE) {
            commands.add(new CommandMessage(new InstallTransitFlow(0L, flowId, cookie, currentIsl.getDestinationSwitch(), currentIsl.getDestinationPort(), nextIsl.getSourcePort(), transitVlan), now(), correlationId, Destination.WFM));
        } else {
            commands.add(new CommandMessage(new InstallTransitFlow(0L, flowId, cookie, currentIsl.getDestinationSwitch(), nextIsl.getSourcePort(), currentIsl.getDestinationPort(), transitVlan), now(), correlationId, Destination.WFM));
        }
    }
    return commands;
}
Also used : InstallIngressFlow(org.openkilda.messaging.command.flow.InstallIngressFlow) InstallTransitFlow(org.openkilda.messaging.command.flow.InstallTransitFlow) InstallEgressFlow(org.openkilda.messaging.command.flow.InstallEgressFlow) CommandMessage(org.openkilda.messaging.command.CommandMessage) HashSet(java.util.HashSet)

Aggregations

InstallTransitFlow (org.openkilda.messaging.command.flow.InstallTransitFlow)5 InstallEgressFlow (org.openkilda.messaging.command.flow.InstallEgressFlow)3 InstallIngressFlow (org.openkilda.messaging.command.flow.InstallIngressFlow)3 HashSet (java.util.HashSet)2 SwitchOperationException (org.openkilda.floodlight.switchmanager.SwitchOperationException)2 CommandMessage (org.openkilda.messaging.command.CommandMessage)2 Test (org.junit.Test)1 BaseInstallFlow (org.openkilda.messaging.command.flow.BaseInstallFlow)1 InstallOneSwitchFlow (org.openkilda.messaging.command.flow.InstallOneSwitchFlow)1 InstallMissedFlowsRequest (org.openkilda.messaging.command.switches.InstallMissedFlowsRequest)1 IslInfoData (org.openkilda.messaging.info.event.IslInfoData)1 PathNode (org.openkilda.messaging.info.event.PathNode)1 SwitchInfoData (org.openkilda.messaging.info.event.SwitchInfoData)1 OFFlowAdd (org.projectfloodlight.openflow.protocol.OFFlowAdd)1