Search in sources :

Example 16 with FlowKey

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey 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)

Example 17 with FlowKey

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

the class OpenflowpluginTestCommandProvider method createTestFlowPerfTest.

private FlowBuilder createTestFlowPerfTest(final String flowTypeArg, final String tableId, final int id) {
    final FlowBuilder flow = new FlowBuilder();
    String flowType = flowTypeArg;
    int flowId = id;
    if (flowType == null) {
        flowType = "f1";
    }
    flow.setPriority(flowId);
    switch(flowType) {
        case "f1":
            flowId += 1;
            flow.setMatch(createMatch1().build());
            flow.setInstructions(createDecNwTtlInstructions().build());
            break;
        default:
            LOG.warn("flow type not understood: {}", flowType);
    }
    final FlowKey key = new FlowKey(new FlowId(Long.toString(flowId)));
    if (null == flow.isBarrier()) {
        flow.setBarrier(Boolean.FALSE);
    }
    final BigInteger value = BigInteger.valueOf(10);
    flow.setCookie(new FlowCookie(value));
    flow.setCookieMask(new FlowCookie(value));
    flow.setHardTimeout(0);
    flow.setIdleTimeout(0);
    flow.setInstallHw(false);
    flow.setStrict(false);
    flow.setContainerName(null);
    flow.setFlags(new FlowModFlags(false, false, false, false, true));
    flow.setId(new FlowId("12"));
    flow.setTableId(getTableId(tableId));
    flow.setKey(key);
    flow.setFlowName(ORIGINAL_FLOW_NAME + "X" + flowType);
    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) 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)

Example 18 with FlowKey

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

the class OpenflowPluginBulkGroupTransactionProvider method createTestFlow.

private FlowBuilder createTestFlow(NodeBuilder nodeBuilder, String flowTypeArg, String tableId) {
    FlowBuilder flow = new FlowBuilder();
    long id = 123;
    String flowType = flowTypeArg;
    if (flowType == null) {
        flowType = "f1";
    }
    switch(flowType) {
        case "f1":
            id += 1;
            flow.setMatch(createMatch1().build());
            flow.setInstructions(createDecNwTtlInstructions().build());
            break;
        case "f2":
            id += 2;
            flow.setMatch(createMatch2().build());
            flow.setInstructions(createDropInstructions().build());
            break;
        case "f3":
            id += 3;
            flow.setMatch(createMatch3().build());
            flow.setInstructions(createDropInstructions().build());
            break;
        case "f4":
            id += 4;
            flow.setMatch(createEthernetMatch().build());
            flow.setInstructions(createDropInstructions().build());
            break;
        case "f82":
            id += 1;
            flow.setMatch(createMatch1().build());
            flow.setInstructions(createDropInstructions().build());
            break;
        case "f5":
            id += 5;
            flow.setMatch(createMatch1().build());
            flow.setInstructions(createAppyActionInstruction().build());
            break;
        case "f6":
            id += 6;
            flow.setMatch(createMatch1().build());
            flow.setInstructions(createGotoTableInstructions().build());
            break;
        case "f7":
            id += 7;
            flow.setMatch(createMatch1().build());
            flow.setInstructions(createMeterInstructions().build());
            break;
        case "f8":
            id += 8;
            flow.setMatch(createMatch1().build());
            flow.setInstructions(createAppyActionInstruction7().build());
            break;
        case "f9":
            id += 9;
            flow.setMatch(createMatch1().build());
            flow.setInstructions(createAppyActionInstruction2().build());
            break;
        case "f10":
            id += 10;
            flow.setMatch(createMatch1().build());
            flow.setInstructions(createAppyActionInstruction3().build());
            break;
        case "f14":
            id += 14;
            flow.setMatch(createMatch1().build());
            flow.setInstructions(createAppyActionInstruction7().build());
            break;
        case "f29":
            id += 29;
            flow.setMatch(createMatch1().build());
            flow.setInstructions(createAppyActionInstruction21().build());
            break;
        default:
            LOG.warn("flow type not understood: {}", flowType);
    }
    final FlowKey key = new FlowKey(new FlowId(Long.toString(id)));
    if (null == flow.isBarrier()) {
        flow.setBarrier(Boolean.FALSE);
    }
    // flow.setBufferId(12L);
    BigInteger value = BigInteger.valueOf(10);
    BigInteger outputPort = BigInteger.valueOf(4294967295L);
    flow.setCookie(new FlowCookie(value));
    flow.setCookieMask(new FlowCookie(value));
    flow.setHardTimeout(0);
    flow.setIdleTimeout(0);
    flow.setInstallHw(false);
    flow.setStrict(false);
    flow.setContainerName(null);
    flow.setFlags(new FlowModFlags(false, false, false, false, true));
    flow.setId(new FlowId("12"));
    flow.setTableId(getTableId(tableId));
    flow.setOutGroup(4294967295L);
    // set outport to OFPP_NONE (65535) to disable remove restriction for
    // flow
    flow.setOutPort(outputPort);
    flow.setKey(key);
    flow.setPriority(2);
    flow.setFlowName(originalFlowName + "X" + flowType);
    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) 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)

Example 19 with FlowKey

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

the class OpenflowpluginStatsTestCommandProvider method _flowStats.

public void _flowStats(CommandInterpreter ci) {
    int flowCount = 0;
    int flowStatsCount = 0;
    List<Node> nodes = getNodes();
    for (Node node2 : nodes) {
        NodeKey nodeKey = node2.getKey();
        InstanceIdentifier<FlowCapableNode> nodeRef = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class);
        ReadOnlyTransaction readOnlyTransaction = dataProviderService.newReadOnlyTransaction();
        FlowCapableNode node = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, nodeRef);
        if (node != null) {
            List<Table> tables = node.getTable();
            for (Table table2 : tables) {
                TableKey tableKey = table2.getKey();
                InstanceIdentifier<Table> tableRef = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class).child(Table.class, tableKey);
                Table table = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, tableRef);
                if (table != null) {
                    if (table.getFlow() != null) {
                        List<Flow> flows = table.getFlow();
                        for (Flow flow2 : flows) {
                            flowCount++;
                            FlowKey flowKey = flow2.getKey();
                            InstanceIdentifier<Flow> flowRef = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class).child(Table.class, tableKey).child(Flow.class, flowKey);
                            Flow flow = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, flowRef);
                            if (flow != null) {
                                FlowStatisticsData data = flow.getAugmentation(FlowStatisticsData.class);
                                if (null != data) {
                                    flowStatsCount++;
                                    LOG.debug("--------------------------------------------");
                                    ci.print(data);
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    if (flowCount == flowStatsCount) {
        LOG.debug("flowStats - Success");
    } else {
        LOG.debug("flowStats - Failed");
        LOG.debug("System fetchs stats data in 50 seconds interval, so pls wait and try again.");
    }
}
Also used : FlowStatisticsData(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowStatisticsData) AggregateFlowStatisticsData(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.AggregateFlowStatisticsData) FlowKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey) Table(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) TableKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey) Nodes(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow) ReadOnlyTransaction(org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction) NodeKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey)

Example 20 with FlowKey

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

the class SalFlowServiceImplTest method updateFlow.

private void updateFlow(short version) throws Exception {
    UpdateFlowInput mockedUpdateFlowInput = mock(UpdateFlowInput.class);
    UpdateFlowInput mockedUpdateFlowInput1 = mock(UpdateFlowInput.class);
    UpdatedFlow mockedUpdateFlow = new UpdatedFlowBuilder().setMatch(match).setTableId((short) 1).build();
    UpdatedFlow mockedUpdateFlow1 = new UpdatedFlowBuilder().setMatch(match).setTableId((short) 1).setPriority(1).build();
    when(mockedUpdateFlowInput.getUpdatedFlow()).thenReturn(mockedUpdateFlow);
    when(mockedUpdateFlowInput1.getUpdatedFlow()).thenReturn(mockedUpdateFlow1);
    FlowRef mockedFlowRef = mock(FlowRef.class);
    Mockito.doReturn(TABLE_II.child(Flow.class, new FlowKey(new FlowId(DUMMY_FLOW_ID)))).when(mockedFlowRef).getValue();
    when(mockedUpdateFlowInput.getFlowRef()).thenReturn(mockedFlowRef);
    when(mockedUpdateFlowInput1.getFlowRef()).thenReturn(mockedFlowRef);
    OriginalFlow mockedOriginalFlow = new OriginalFlowBuilder().setMatch(match).setTableId((short) 1).build();
    OriginalFlow mockedOriginalFlow1 = new OriginalFlowBuilder().setMatch(match).setTableId((short) 1).setPriority(2).build();
    when(mockedUpdateFlowInput.getOriginalFlow()).thenReturn(mockedOriginalFlow);
    when(mockedUpdateFlowInput1.getOriginalFlow()).thenReturn(mockedOriginalFlow1);
    SalFlowServiceImpl salFlowService = mockSalFlowService(version);
    verifyOutput(salFlowService.updateFlow(mockedUpdateFlowInput));
    verifyOutput(salFlowService.updateFlow(mockedUpdateFlowInput1));
}
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) UpdatedFlow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.UpdatedFlow) FlowRef(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowRef) OriginalFlow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.OriginalFlow) UpdateFlowInput(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowInput) OriginalFlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.OriginalFlowBuilder) UpdatedFlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.UpdatedFlowBuilder) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow) UpdatedFlow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.UpdatedFlow) OriginalFlow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.OriginalFlow)

Aggregations

FlowKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey)52 FlowId (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId)45 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)38 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)26 FlowBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder)26 TableKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey)23 Node (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)23 Nodes (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes)22 BigInteger (java.math.BigInteger)15 Table (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table)12 FlowCookie (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie)11 ArrayList (java.util.ArrayList)9 FlowModFlags (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags)9 Test (org.junit.Test)8 MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder)8 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)7 MatchInfo (org.opendaylight.genius.mdsalutil.MatchInfo)6 TableBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableBuilder)6 StaleFlow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.StaleFlow)6 StaleFlowKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.StaleFlowKey)6