openflowopendaylightgenius-api

opendaylight: Genius install flow in switch


I am using opendaylight / Carbon and am trying to work with the Genius wrapper. I want to install a flow in a switch based on a MAC address match for an incoming packet. The instruction I want to install is a "GOTO" instruction. I proceed as follows:

     FlowEntityBuilder flowEntityBuilder = new FlowEntityBuilder();
    flowEntityBuilder.setTableId(tableId)
        .setDpnId(dpnId)
        .setFlowId(FlowUtils.createFlowId().toString())
        .setFlowName("gotoTable1");

    MatchInfo matchInfo = new MatchEthernetSource(macAddress);


    InstructionInfo instructionInfo = new InstructionGotoTable(tableId);
    FlowEntity flowEntity = flowEntityBuilder.addInstructionInfoList(instructionInfo).addMatchInfoList(matchInfo).build();
    mdsalApiManager.installFlow(dpnId,flowEntity);

Mu intention was to create a flow entity and install it using the IMDSalApiManager.installFlow method.

Here is the exception that I see:

java.lang.IllegalArgumentException: Node (urn:opendaylight:flow:inventory?revision=2013-08-19)ethernet-source is missing mandatory descendant /(urn:opendaylight:flow:inventory?revision=2013-08-19)address

Any help debugging this would be appreciated.


Solution

  • This is how you build a GOTO instruction with OpenDaylight :

    GoToTableBuilder gttb = new GoToTableBuilder();
    gttb.setTableId(tableGoto);
    
    Instruction gotoInstruction = new InstructionBuilder()
        .setOrder(1).setInstruction(new GoToTableCaseBuilder()
            .setGoToTable(gttb.build())
            .build())
        .build();
    

    You can use this to adjust your code.