Ask is moving to Stack Overflow and Serverfault.com! Please use the "opendaylight" tag on either of these sites. This site is now in Read-Only mode

Revision history [back]

click to hide/show revision 1
initial version

Flows dont get removed from Config datastore

I have written a code which add some flows when a switch (node) comes up. I write it to the config datastore and I can see it in the operational datastore too.

Now, the switch goes down, the flows get removed from the operational datastore only and not from the config datastore. So next time, when the node comes up again and my code tries to write the same flows, it doesn't work. The flows are already there in the config datastore and no extra flow is written to the switch.

Can someone help me what I am doing wrong here. For example one of the those static flows is this:

public void addFlow(NodeId nodeId , NodeUpdated notification, DataBroker dataBroker){


    InstructionsBuilder isb = new InstructionsBuilder();
    InstructionBuilder ib = new InstructionBuilder();
    List<Instruction> instructions = new ArrayList<Instruction>();



    ApplyActionsBuilder applyActionsBuilder= new ApplyActionsBuilder();
    List<Action> actionList = new ArrayList<Action>();

    // Action 1 -> send to Controller
    ActionBuilder ab= new ActionBuilder();
    OutputActionBuilder outputActionBuilderContoller = new OutputActionBuilder();
    Uri controller = new Uri(OutputPortValues.CONTROLLER.toString());
    outputActionBuilderContoller.setOutputNodeConnector(controller);
    ab.setAction(new OutputActionCaseBuilder().setOutputAction(outputActionBuilderContoller.build()).build());
    ab.setOrder(0);
    ab.setKey(new ActionKey(0));

    actionList.add(ab.build());


    applyActionsBuilder.setAction(actionList);


    ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(applyActionsBuilder.build()).build());
    ib.setOrder(1);
    instructions.add(ib.build());
    instructions.add(ib.build());
    isb.setInstruction(instructions);


    FlowBuilder flow = new FlowBuilder();
    FlowId flowId = new FlowId("100");


    flow.setFlowName("ToController");
    flow.setIdleTimeout(0);
    flow.setHardTimeout(0);
    flow.setStrict(false);
    flow.setTableId((short) 1);
    flow.setPriority(0);
    flow.setInstructions(isb.build());
    flow.setKey(new FlowKey(flowId));



       @SuppressWarnings("deprecation")
       InstanceIdentifier<Flow> flowIID = InstanceIdentifier.builder(Nodes.class)
            .child(Node.class, new NodeKey(nodeId))
            .augmentation(FlowCapableNode.class)
            .child(Table.class, new TableKey(flow.getTableId()))
            .child(Flow.class, flow.getKey())
            .build();


       //now the actual writing
       try{
       GenericTransactionUtils.writeData(dataBroker, LogicalDatastoreType.CONFIGURATION, flowIID, flow.build(), true);
       }
       catch (Exception e){
        System.out.println("error in wriing flow" + e);
       }
       System.out.println("ToController Flow written on Table 1");
       return;  }

}