Search in sources :

Example 16 with FlowBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder in project openflowplugin by opendaylight.

the class LLDPPacketPuntEnforcer method createFlow.

static Flow createFlow() {
    FlowBuilder flowBuilder = new FlowBuilder();
    flowBuilder.setMatch(new MatchBuilder().build());
    flowBuilder.setInstructions(createSendToControllerInstructions().build());
    flowBuilder.setPriority(0);
    FlowKey key = new FlowKey(new FlowId(DEFAULT_FLOW_ID));
    flowBuilder.setBarrier(Boolean.FALSE);
    flowBuilder.setBufferId(OFConstants.OFP_NO_BUFFER);
    BigInteger value = BigInteger.valueOf(10L);
    flowBuilder.setCookie(new FlowCookie(value));
    flowBuilder.setCookieMask(new FlowCookie(value));
    flowBuilder.setHardTimeout(0);
    flowBuilder.setIdleTimeout(0);
    flowBuilder.setInstallHw(false);
    flowBuilder.setStrict(false);
    flowBuilder.setContainerName(null);
    flowBuilder.setFlags(new FlowModFlags(false, false, false, false, true));
    flowBuilder.setId(new FlowId("12"));
    flowBuilder.setTableId(TABLE_ID);
    flowBuilder.setKey(key);
    flowBuilder.setFlowName(LLDP_PUNT_WHOLE_PACKET_FLOW);
    return flowBuilder.build();
}
Also used : FlowId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId) FlowKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey) FlowCookie(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie) FlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder) FlowModFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags) BigInteger(java.math.BigInteger) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder)

Example 17 with FlowBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder in project openflowplugin by opendaylight.

the class OpenflowpluginTestCommandProvider method _testAllFlows.

/*
     * usage testAllFlows <dp>
     * ex: _perfFlowTest 1
     */
@SuppressWarnings("checkstyle:IllegalCatch")
public void _testAllFlows(final CommandInterpreter ci) {
    String dataPathID = ci.nextArgument();
    final int numberOfFlows = 82;
    if (dataPathID == null || dataPathID.trim().equals("")) {
        dataPathID = "1";
    }
    ci.println("*     Test All Flows    *");
    ci.println("*     dataPathID:::" + dataPathID + "");
    final String dataPath = "openflow:" + dataPathID;
    final String tableId = "0";
    final NodeBuilder tn = createTestNode(dataPath);
    FlowBuilder tf;
    for (int flow = 1; flow < numberOfFlows; flow++) {
        final String flowID = "f" + flow;
        try {
            tf = createTestFlow(tn, flowID, tableId);
            writeFlow(ci, tf, tn);
        } catch (RuntimeException e) {
            ci.println("--Test Failed--Issue found while adding flow" + flow);
            break;
        }
    }
}
Also used : FlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder) NodeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder)

Example 18 with FlowBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder in project openflowplugin by opendaylight.

the class OpenflowpluginTestCommandProvider method _perfFlowTest.

/*
     * usage testSwitchFlows <numberOfSwitches> <numberOfFlows> <warmup iterations> <Number Of Threads>
     * ex: _perfFlowTest 10 5 1 2
     */
public void _perfFlowTest(final CommandInterpreter ci) {
    final String numberOfSwtichesStr = ci.nextArgument();
    final String numberOfFlowsStr = ci.nextArgument();
    final String warmupIterationsStr = ci.nextArgument();
    final String threadCountStr = ci.nextArgument();
    final String warmUpStr = ci.nextArgument();
    int numberOfSwtiches = 0;
    int numberOfFlows = 0;
    int warmupIterations = 0;
    boolean warmUpIterations = false;
    int threadCount = 0;
    if (numberOfSwtichesStr != null && !numberOfSwtichesStr.trim().equals("")) {
        numberOfSwtiches = Integer.parseInt(numberOfSwtichesStr);
    } else {
        numberOfSwtiches = 2;
    }
    if (numberOfFlowsStr != null && !numberOfFlowsStr.trim().equals("")) {
        numberOfFlows = Integer.parseInt(numberOfFlowsStr);
    } else {
        numberOfFlows = 2;
    }
    if (warmupIterationsStr != null && !warmupIterationsStr.trim().equals("")) {
        warmupIterations = Integer.parseInt(warmupIterationsStr);
    } else {
        warmupIterations = 2;
    }
    if (threadCountStr != null && !threadCountStr.trim().equals("")) {
        threadCount = Integer.parseInt(threadCountStr);
    } else {
        threadCount = 2;
    }
    if (warmUpStr != null && !warmUpStr.trim().equals("") && warmUpStr.trim().equals("true")) {
        warmUpIterations = true;
    } else {
        warmUpIterations = false;
    }
    ci.println("*     Test Configurations*");
    ci.println("*     numberOfSwtiches:::" + numberOfSwtiches + "");
    ci.println("*     numberOfFlows:::" + numberOfFlows + "");
    ci.println("*     warmupIterations:::" + warmupIterations + "");
    ci.println("*     Number of Threads :::" + threadCount + "");
    ci.println("*     Warmup Required? :::" + warmUpIterations + "");
    String dataPath = "openflow:1";
    NodeBuilder tn;
    FlowBuilder tf;
    final String tableId = "0";
    if (warmUpIterations) {
        ci.println("----Warmup Started-----");
        for (int j = 1; j <= warmupIterations; j++) {
            for (int i = 1; i <= numberOfSwtiches; i++) {
                dataPath = "openflow:" + i;
                tn = createTestNode(dataPath);
                for (int flow = 1; flow < numberOfFlows; flow++) {
                    tf = createTestFlowPerfTest("f1", tableId, flow);
                    writeFlow(ci, tf, tn);
                }
            }
        }
        ci.println("----Warmup Done-----");
    }
    try {
        final ExecutorService executor = Executors.newFixedThreadPool(threadCount);
        int tableID = 0;
        for (int t = 0; t < threadCount; t++) {
            tableID = t + 1;
            final Runnable tRunnable = new TestFlowThread(numberOfSwtiches, numberOfFlows, ci, t, tableID);
            executor.execute(tRunnable);
        }
        executor.shutdown();
        executor.awaitTermination(1, TimeUnit.SECONDS);
    } catch (InterruptedException e) {
        ci.println("Exception:" + e.getMessage());
    }
}
Also used : FlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder) ExecutorService(java.util.concurrent.ExecutorService) NodeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder)

Example 19 with FlowBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder in project openflowplugin by opendaylight.

the class OpenflowpluginTestCommandProvider method _modifyMDFlow.

public void _modifyMDFlow(final CommandInterpreter ci) {
    final NodeBuilder tn = createTestNode(ci.nextArgument());
    final FlowBuilder tf = createTestFlow(tn, ci.nextArgument(), ci.nextArgument());
    tf.setFlowName(UPDATED_FLOW_NAME);
    writeFlow(ci, tf, tn);
    tf.setFlowName(ORIGINAL_FLOW_NAME);
    writeFlow(ci, tf, tn);
}
Also used : FlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder) NodeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder)

Example 20 with FlowBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder in project openflowplugin by opendaylight.

the class OpenflowpluginTestCommandProvider method createtablemiss.

private FlowBuilder createtablemiss() {
    final FlowBuilder flow = new FlowBuilder();
    final long id = 456;
    final MatchBuilder matchBuilder = new MatchBuilder();
    flow.setMatch(matchBuilder.build());
    flow.setInstructions(createSentToControllerInstructions().build());
    flow.setPriority(0);
    flow.setTableId((short) 0);
    final FlowKey key = new FlowKey(new FlowId(Long.toString(id)));
    flow.setKey(key);
    return flow;
}
Also used : FlowId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId) FlowKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey) FlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder) ArpMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder) Icmpv4MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv4MatchBuilder) TunnelIpv4MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.TunnelIpv4MatchBuilder) VlanMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatchBuilder) EthernetMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder) TcpFlagsMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.TcpFlagsMatchBuilder) Ipv4MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder) Ipv6MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder) IpMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder) Icmpv6MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv6MatchBuilder) SctpMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.SctpMatchBuilder) UdpMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatchBuilder) TcpMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatchBuilder) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder)

Aggregations

FlowBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder)62 FlowId (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId)39 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)37 FlowKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey)26 BigInteger (java.math.BigInteger)22 Test (org.junit.Test)19 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)15 FlowCookie (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie)15 MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder)13 Table (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table)12 FlowModFlags (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags)10 Node (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)10 ArrayList (java.util.ArrayList)9 TableKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey)9 Instruction (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction)8 NodeBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder)8 TableBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableBuilder)7 ReadWriteTransaction (org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction)6 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)6 InstructionsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder)6