1 package org.opendaylight.controller.md.frm.compatibility;
3 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerContext;
4 import org.opendaylight.controller.sal.binding.api.data.DataBrokerService;
5 import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction;
6 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.Flows;
7 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows.Flow;
8 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows.FlowBuilder;
9 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows.FlowKey;
10 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
11 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
13 public class SampleConsumer {
15 ConsumerContext context;
17 void addFlowExample() {
19 DataBrokerService dataService = context.getSALService(DataBrokerService.class);
21 DataModificationTransaction transaction = dataService.beginTransaction();
22 Flow flow = createSampleFlow("foo", null);
23 InstanceIdentifier<Flow> path = InstanceIdentifier.builder().node(Flows.class).node(Flow.class, flow.getKey())
25 transaction.putConfigurationData(path, flow);
29 dataService.readConfigurationData(path);
32 Flow createSampleFlow(String name, NodeRef node) {
33 FlowBuilder ret = new FlowBuilder();
34 FlowKey key = new FlowKey(Long.parseLong(name), node);