Search in sources :

Example 26 with TableId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId 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 27 with TableId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId in project openflowplugin by opendaylight.

the class MultipartReplyTranslatorUtil method translateTable.

private static MultipartReplyFlowTableStats translateTable(final MultipartReply msg) {
    MultipartReplyFlowTableStatsBuilder message = new MultipartReplyFlowTableStatsBuilder();
    MultipartReplyTableCase caseBody = (MultipartReplyTableCase) msg.getMultipartReplyBody();
    MultipartReplyTable replyBody = caseBody.getMultipartReplyTable();
    List<TableStats> swTablesStats = replyBody.getTableStats();
    List<FlowTableAndStatisticsMap> salFlowStats = new ArrayList<>();
    // TODO: Duplicate code: look at OpendaylightFlowTableStatisticsServiceImpl method transformToNotification
    for (TableStats swTableStats : swTablesStats) {
        FlowTableAndStatisticsMapBuilder statisticsBuilder = new FlowTableAndStatisticsMapBuilder();
        statisticsBuilder.setActiveFlows(new Counter32(swTableStats.getActiveCount()));
        statisticsBuilder.setPacketsLookedUp(new Counter64(swTableStats.getLookupCount()));
        statisticsBuilder.setPacketsMatched(new Counter64(swTableStats.getMatchedCount()));
        statisticsBuilder.setTableId(new TableId(swTableStats.getTableId()));
        salFlowStats.add(statisticsBuilder.build());
    }
    message.setFlowTableAndStatisticsMap(salFlowStats);
    return message.build();
}
Also used : MultipartReplyFlowTableStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.multipart.reply.multipart.reply.body.MultipartReplyFlowTableStatsBuilder) FlowTableAndStatisticsMap(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.and.statistics.map.FlowTableAndStatisticsMap) Counter32(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32) TableId(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId) Counter64(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter64) MultipartReplyTableCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableCase) ArrayList(java.util.ArrayList) MultipartReplyTable(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.MultipartReplyTable) FlowTableAndStatisticsMapBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.and.statistics.map.FlowTableAndStatisticsMapBuilder) MultipartReplyFlowTableStats(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.multipart.reply.multipart.reply.body.MultipartReplyFlowTableStats) TableStats(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.multipart.reply.table.TableStats)

Example 28 with TableId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId in project openflowplugin by opendaylight.

the class FlowUtils method createDirectMacToMacFlow.

/**
 * Returns a {@link FlowBuilder} forwarding all packets to controller port.
 */
public static FlowBuilder createDirectMacToMacFlow(final Short tableId, final int priority, final MacAddress srcMac, final MacAddress dstMac, final NodeConnectorRef dstPort) {
    FlowBuilder macToMacFlow = new FlowBuilder().setTableId(tableId).setFlowName("mac2mac");
    macToMacFlow.setId(new FlowId(Long.toString(macToMacFlow.hashCode())));
    EthernetMatch ethernetMatch = new EthernetMatchBuilder().setEthernetSource(new EthernetSourceBuilder().setAddress(srcMac).build()).setEthernetDestination(new EthernetDestinationBuilder().setAddress(dstMac).build()).build();
    MatchBuilder match = new MatchBuilder();
    match.setEthernetMatch(ethernetMatch);
    Uri outputPort = dstPort.getValue().firstKeyOf(NodeConnector.class, NodeConnectorKey.class).getId();
    Action outputToControllerAction = new ActionBuilder().setOrder(0).setAction(new OutputActionCaseBuilder().setOutputAction(new OutputActionBuilder().setMaxLength(Integer.valueOf(0xffff)).setOutputNodeConnector(outputPort).build()).build()).build();
    // Create an Apply Action
    ApplyActions applyActions = new ApplyActionsBuilder().setAction(ImmutableList.of(outputToControllerAction)).build();
    // Wrap our Apply Action in an Instruction
    Instruction applyActionsInstruction = new InstructionBuilder().setOrder(0).setInstruction(new ApplyActionsCaseBuilder().setApplyActions(applyActions).build()).build();
    // Put our Instruction in a list of Instructions
    macToMacFlow.setMatch(new MatchBuilder().setEthernetMatch(ethernetMatch).build()).setInstructions(new InstructionsBuilder().setInstruction(ImmutableList.of(applyActionsInstruction)).build()).setPriority(priority).setBufferId(OFConstants.OFP_NO_BUFFER).setHardTimeout(0).setIdleTimeout(0).setFlags(new FlowModFlags(false, false, false, false, false));
    return macToMacFlow;
}
Also used : OutputActionCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCaseBuilder) InstructionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder) Action(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action) OutputActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputActionBuilder) ActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder) NodeConnector(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector) FlowModFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags) Instruction(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction) Uri(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri) EthernetMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder) InstructionsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder) FlowId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId) EthernetDestinationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetDestinationBuilder) EthernetMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatch) FlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder) EthernetSourceBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetSourceBuilder) ApplyActionsCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder) OutputActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputActionBuilder) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder) EthernetMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder) ApplyActionsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActionsBuilder) NodeConnectorKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey) ApplyActions(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActions)

Example 29 with TableId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId in project openflowplugin by opendaylight.

the class OpendaylightFlowStatisticsServiceDelegateImplTest method testGetAggregateFlowStatisticsFromFlowTableForAllFlows.

@Test
public void testGetAggregateFlowStatisticsFromFlowTableForAllFlows() throws Exception {
    GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder input = new GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder().setNode(createNodeRef("unitProt:123")).setTableId(new TableId((short) 1));
    Mockito.when(translator.translate(Matchers.any(MultipartReply.class), Matchers.eq(deviceInfo), Matchers.any())).thenReturn(new AggregatedFlowStatisticsBuilder().setByteCount(new Counter64(BigInteger.valueOf(50L))).setPacketCount(new Counter64(BigInteger.valueOf(51L))).setFlowCount(new Counter32(52L)).build());
    rpcResult = RpcResultBuilder.<Object>success(Collections.singletonList(new MultipartReplyMessageBuilder().setType(MultipartType.OFPMPAGGREGATE).setVersion(OFConstants.OFP_VERSION_1_3).setFlags(new MultipartRequestFlags(false)).setMultipartReplyBody(new MultipartReplyAggregateCaseBuilder().setMultipartReplyAggregate(new MultipartReplyAggregateBuilder().setByteCount(BigInteger.valueOf(50L)).setPacketCount(BigInteger.valueOf(51L)).setFlowCount(52L).build()).build()).build())).build();
    final Future<RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput>> resultFuture = flowStatisticsServiceDelegate.getAggregateFlowStatisticsFromFlowTableForAllFlows(input.build());
    Assert.assertTrue(resultFuture.isDone());
    final RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput> rpcResultCompatible = resultFuture.get();
    Assert.assertTrue(rpcResultCompatible.isSuccessful());
    Assert.assertEquals(MultipartType.OFPMPAGGREGATE, requestInput.getValue().getType());
    Mockito.verify(notificationPublishService, Mockito.timeout(NOTIFICATION_WAIT_TIMEOUT_MS)).offerNotification(Matchers.any(Notification.class));
}
Also used : TableId(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId) MultipartReply(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) MultipartRequestFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags) AggregatedFlowStatisticsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.get.aggregate.flow.statistics.from.flow.table._for.given.match.output.AggregatedFlowStatisticsBuilder) Notification(org.opendaylight.yangtools.yang.binding.Notification) Counter32(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32) MultipartReplyAggregateBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.aggregate._case.MultipartReplyAggregateBuilder) Counter64(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter64) GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder) MultipartReplyMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder) GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput) MultipartReplyAggregateCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCaseBuilder) AbstractSingleStatsServiceTest(org.opendaylight.openflowplugin.impl.statistics.services.AbstractSingleStatsServiceTest) Test(org.junit.Test)

Example 30 with TableId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId in project openflowplugin by opendaylight.

the class OpendaylightFlowStatisticsServiceDelegateImplTest method testGetAllFlowStatisticsFromFlowTable.

@Test
public void testGetAllFlowStatisticsFromFlowTable() throws Exception {
    GetAllFlowStatisticsFromFlowTableInputBuilder input = new GetAllFlowStatisticsFromFlowTableInputBuilder().setNode(createNodeRef("unitProt:123")).setTableId(new TableId((short) 1));
    rpcResult = buildFlowStatsReply();
    final Future<RpcResult<GetAllFlowStatisticsFromFlowTableOutput>> resultFuture = flowStatisticsServiceDelegate.getAllFlowStatisticsFromFlowTable(input.build());
    Assert.assertTrue(resultFuture.isDone());
    final RpcResult<GetAllFlowStatisticsFromFlowTableOutput> rpcResultCompatible = resultFuture.get();
    Assert.assertTrue(rpcResultCompatible.isSuccessful());
    Assert.assertEquals(MultipartType.OFPMPFLOW, requestInput.getValue().getType());
    Mockito.verify(notificationPublishService, Mockito.timeout(NOTIFICATION_WAIT_TIMEOUT_MS)).offerNotification(Matchers.any(Notification.class));
}
Also used : TableId(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId) GetAllFlowStatisticsFromFlowTableInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsFromFlowTableInputBuilder) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) GetAllFlowStatisticsFromFlowTableOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsFromFlowTableOutput) Notification(org.opendaylight.yangtools.yang.binding.Notification) AbstractSingleStatsServiceTest(org.opendaylight.openflowplugin.impl.statistics.services.AbstractSingleStatsServiceTest) Test(org.junit.Test)

Aggregations

BigInteger (java.math.BigInteger)38 Test (org.junit.Test)32 ArrayList (java.util.ArrayList)26 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)17 ByteBuf (io.netty.buffer.ByteBuf)16 FlowBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder)16 FlowId (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId)15 FlowKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey)15 TableId (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId)14 TableId (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId)14 Instruction (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction)13 FlowCookie (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie)12 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)12 InstructionGotoTable (org.opendaylight.genius.mdsalutil.instructions.InstructionGotoTable)9 FlowModFlags (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags)7 Optional (com.google.common.base.Optional)6 ExecutionException (java.util.concurrent.ExecutionException)5 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)5 ActionInfo (org.opendaylight.genius.mdsalutil.ActionInfo)5 MatchInfo (org.opendaylight.genius.mdsalutil.MatchInfo)5