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


How to read data from Operational Data Store?

asked 2016-01-25 01:11:43 -0800

karthik330 gravatar image

updated 2016-01-25 01:12:08 -0800

I need to read the data from Operational Data Store.For example if i give mac , i should get ip of the relavant mac. I know we can get the mac, ip details from UI itself.But i wants to do experiment on reading data from Operational Data Store.How to use DataBroker service for this? Thanks in Advance

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2016-02-25 04:39:08 -0800

karthik330 gravatar image

updated 2016-02-25 21:05:01 -0800

Imports : I copied all imports here ! you may delete unwanted ..

import; import; import; import; import; import; import; import; import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext; import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration; import org.opendaylight.controller.sal.binding.api.BindingAwareProvider; import; import; import; import; import; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.ArrayList; import java.util.List; import java.util.concurrent.Future;

Inside your class .. Instance identifier :

public static final InstanceIdentifier<topology> TOPO_IID = InstanceIdentifier .create(NetworkTopology.class) .child(Topology.class, new TopologyKey(new TopologyId("flow:1")));

private RpcRegistration<pathservice> pathService; private DataBroker dataService;

public void onSessionInitiated(ProviderContext session) {"PathProvider Session Initiated");
this.dataService = session.getSALService(DataBroker.class);
    pathService = session.addRpcImplementation(PathService.class, this);


RPC method :

public Future<RpcResult<NodesOutput>> nodes() {

    List<Node> nodes=null;
    ReadTransaction tx = dataService.newReadOnlyTransaction();

    List<String> results = new ArrayList<String>();

    try {
        nodes =, TOPO_IID)
    } catch (ReadFailedException e) {
        LOG.error("Failed to read node config from datastore", e);
        throw new IllegalStateException(e);

    for (Node node : nodes) {"Node: {}", node);

    NodesOutputBuilder NodeBuilder = new NodesOutputBuilder();
    NodeBuilder.setListnode("Nodes are  "+results);
    return RpcResultBuilder.success(;

edit flag offensive delete publish link more


Could you please paste the steps

saisujithreddy ( 2016-02-25 16:49:35 -0800 )edit

Plz check my updated answer

karthik330 ( 2016-02-25 20:55:40 -0800 )edit

Thank for the code. I am trying to use it but I do not know how implement NodesOutput, pathservice, Topology.

migueldmh ( 2016-04-28 07:08:54 -0800 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2016-01-25 01:11:43 -0800

Seen: 804 times

Last updated: Feb 25 '16