2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.controller.md.frm.compatibility;
10 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerContext;
11 import org.opendaylight.controller.sal.binding.api.data.DataBrokerService;
12 import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.Flows;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows.Flow;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows.FlowBuilder;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows.FlowKey;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
18 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
20 public class SampleConsumer {
22 ConsumerContext context;
24 void addFlowExample() {
26 DataBrokerService dataService = context.getSALService(DataBrokerService.class);
28 DataModificationTransaction transaction = dataService.beginTransaction();
29 Flow flow = createSampleFlow("foo", null);
30 InstanceIdentifier<Flow> path = InstanceIdentifier.builder(Flows.class).child(Flow.class, flow.getKey())
32 transaction.putConfigurationData(path, flow);
36 dataService.readConfigurationData(path);
39 Flow createSampleFlow(String name, NodeRef node) {
40 FlowBuilder ret = new FlowBuilder();
41 FlowKey key = new FlowKey(Long.parseLong(name), node);