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 access Topology/node details from MD-SAL in App

asked 2015-03-28 12:41:52 -0800

gyanesh gravatar image

Need any pointer about how to access the Topology details from MD-SAL inside a user developed ODL application. -> which service needs to be registered -> is there any api available for this -> Which code base in ODL can give us a better pointer for this.

edit retag flag offensive close merge delete

3 answers

Sort by ยป oldest newest most voted

answered 2015-03-29 22:35:11 -0800

Ashwini_Mhatre gravatar image

Hi, You need to install odl-l2switch-switch feature and for accessing network topology use following URL: http://<controller ip="">:8181/restconf/operational/network-topology:network-topology/topology/flow:1/</controller>

Regards, Ashwini

edit flag offensive delete publish link more

answered 2015-03-31 05:52:21 -0800

gyanesh gravatar image

Thanks @Ashwini_Mhatre
I am aware of the RestAPIs. I am more interested in programming level. Inside a user developed module, how to access the Nodes/topology/links. It is better to use the DataBroker or DataProviderService? Or is it good to use ITopologyManager ? Any example or existing module which has similar functionality to understand it better?

edit flag offensive delete publish link more


If you are using ad-sal approach then you can go with Itopologymanager ,if you are using MD-SAL then go with DataBroker its up to you. in both the case you can able to access Nodes/topology/link for MD-SAL you can refer following link:

Ashwini_Mhatre ( 2015-03-31 20:28:24 -0800 )edit

thanks.. Can i take a look in any existing ODL project for reference? That will give me a better overview including various error checking also.

gyanesh ( 2015-04-01 05:13:32 -0800 )edit

Then you can go with l2switch code. the above is devloper guide for l2switch.

Ashwini_Mhatre ( 2015-04-01 22:49:28 -0800 )edit

answered 2017-06-13 07:10:33 -0800

karthik330 gravatar image

updated 2017-06-13 07:12:08 -0800

private List<Link> getLinksFromTopology() {
        InstanceIdentifier<Topology> topologyInstanceIdentifier = InstanceIdentifier.builder(NetworkTopology.class)
            .child(Topology.class, new TopologyKey(new TopologyId(topologyId)))
            .build();  //openFlow topologyId : "flow:1"
        Topology topology = null;
        ReadOnlyTransaction readOnlyTransaction = dataBroker.newReadOnlyTransaction();
        try {
            Optional<Topology> topologyOptional = readOnlyTransaction
                    .read(LogicalDatastoreType.OPERATIONAL, topologyInstanceIdentifier).get();
            if (topologyOptional.isPresent()) {
                topology = topologyOptional.get();
        } catch (Exception e) {
            LOG.error("Error reading topology {}", topologyInstanceIdentifier);
            throw new RuntimeException(
                    "Error reading from operational store, topology : " + topologyInstanceIdentifier, e);
        if (topology == null) {
            return null;
        List<Link> links = topology.getLink();   // Similarly you can get Node Details
        if (links == null || links.isEmpty()) {
            return null;
        List<Link> internalLinks = new ArrayList<>();
        for (Link link : links) {
            // link.getLinkId().getValue()  : You will get Link details,   
        return internalLinks;

You need DataBroker service to get Topology details from Data Store. Refer the above code . There is no direct API , You have to implement to get details from Data Store. Let me know if you have any doubts

edit flag offensive delete publish link more
Login/Signup to Answer

Question Tools



Asked: 2015-03-28 12:41:52 -0800

Seen: 796 times

Last updated: Jun 13 '17