Here's some code from my project that does it. Unfortunately it's quite complicated.
some helper methods: protected FlowBuilder base() { return new FlowBuilder() .setTableId(getTableId()) .setBarrier(false) .setHardTimeout(0) .setIdleTimeout(0); } public static Instructions gotoTableInstructions(short tableId) { return new InstructionsBuilder() .setInstruction(ImmutableList.of(new InstructionBuilder() .setOrder(Integer.valueOf(0)) .setInstruction(gotoTableIns(tableId)) .build())) .build(); } public static final InstanceIdentifier<Node> createNodePath(final NodeId nodeId) { return InstanceIdentifier.builder(Nodes.class) .child(Node.class, new NodeKey(nodeId)) .build(); } /** * Creates a table path from a node ID and table ID * * @param nodePath * @param tableKey * @return */ public static final InstanceIdentifier<Table> createTablePath(final NodeId nodeId, final short tableId) { return createNodePath(nodeId).builder() .augmentation(FlowCapableNode.class) .child(Table.class, new TableKey(tableId)) .build(); } /** * Creates a path for particular flow, by appending flow-specific information * to table path. * * @param table * @param flowKey * @return */ public static InstanceIdentifier<Flow> createFlowPath(final InstanceIdentifier<Table> table, final FlowKey flowKey) { return table.child(Flow.class, flowKey); } /** * Creates a path for particular flow, by appending flow-specific information * to table path. * * @param table * @param flowId * @return */ public static InstanceIdentifier<Flow> createFlowPath(final InstanceIdentifier<Table> table, final FlowId flowId) { return createFlowPath(table, new FlowKey(flowId)); } The actual code cobbled together from a few other helpers: ReadWriteTransaction t = ctx.dataBroker.newReadWriteTransaction(); InstanceIdentifier<Table> tiid = FlowUtils.createTablePath(nodeId, getTableId()); Optional<Table> r = t.read(LogicalDatastoreType.CONFIGURATION, tiid).get(); FlowBuilder flowb = base() .setId(flowid) .setPriority(Integer.valueOf(200)) .setMatch(new MatchBuilder() .setInPort(port) .build()) .setInstructions(FlowUtils.gotoTableInstructions((short)(getTableId()+1))); writeFlow(t, tiid, flowb.build()); t.put(LogicalDatastoreType.CONFIGURATION, FlowUtils.createFlowPath(tiid, flow.getId()), flow); On Wed, Jul 23, 2014 at 9:56 AM, Anhn Nguyen <nna4...@gmail.com> wrote: > Dear all, > > Can anyone tell me how to add a flow with action "go to table" from > OpenDayLight controller to Open vSwitch, instead of doing this command from > mininet: > *sudo ovs-ofctl -O OpenFlow13 add-flow s1 > table=0,in_port=2,actions=goto_table:1* > > I followed this instruction > https://wiki.opendaylight.org/view/OpenDaylight_OpenFlow_Plugin:End_to_End_Flows#Push_your_flow > but > there is no action as I want. > > Thank you so much. > > Best regards, > Anhn Nguyen. > > _______________________________________________ > controller-dev mailing list > controller-...@lists.opendaylight.org > https://lists.opendaylight.org/mailman/listinfo/controller-dev > >
_______________________________________________ discuss mailing list discuss@openvswitch.org http://openvswitch.org/mailman/listinfo/discuss