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 extract the current Topology?

asked 2016-06-14 05:46:44 -0700

Gamuto gravatar image

updated 2016-06-14 05:47:23 -0700

Hey folks,

I'm currently trying to create a plugin for the ODL Controller. The plugin should be able to extract the current virtual topology as well as the hardware topology known to the controller and save it into an XMI-File.

Since I'm new to ODL Development I'm not sure where to start. Do you guys know some APIs my plugin can get the topology information from? Might there be an already existing plugin for that? Where does the ODL Controller save it's information about the current topology?

Thanks for your help,


edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted

answered 2016-06-17 00:38:12 -0700

karthik330 gravatar image

updated 2016-07-07 04:56:29 -0700

Hi , using this API you will get the current Topology details . Its saves these information in Operational DataStore. Topology GET Method .

You could directly paste this URL in Browser / Postman .

Using Data broker , reading topology.

 InstanceIdentifier<Topology> TOPO_IID =
                            new TopologyKey(new 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;
       else { // Do your Logic}
edit flag offensive delete publish link more


Hi karthik , can you tell me if there is any method by which I could get the links in the operational mdsal in ODL I am just trying to implement dijkstras algo and need the links present in the netowork for constructing the graph . and also how the dlux plugin gets the links data from the mdsal Thank you

knv ( 2016-06-19 07:02:32 -0700 )edit

Hey Karthik, thanks for your comment. Using the DataBroker is exactly the way I want to implement it.

Gamuto ( 2016-06-29 08:59:55 -0700 )edit

generateTopologyInstanceIdentifier is another function which i forgot to paste. hope you know how to find instance identifier for Topology.

karthik330 ( 2016-07-01 02:18:33 -0700 )edit

@Gamuto hi, plz mark this answer as correct if you think ! :-)

karthik330 ( 2016-07-06 00:11:41 -0700 )edit

@karthik330 Can you tell me how to correctly add dependencies so I can access "Topology.class", "InstanceIdentififerUtil" and so on? I tried adding a dependency to "l2switch" version 0.4.0-SNAPSHOT to my pom.xml. No errors in Eclipse, on build, however, it cannot find the needed packages.

Gamuto ( 2016-07-06 05:38:56 -0700 )edit

answered 2016-06-17 07:27:55 -0700

mahanare gravatar image

read from the data store, i think you need to understand the data structure /tree well and also should have appropriate yang files with you (you should be having it already).

Then use java api to read (DataBroker is the class) and read the data with apprpriate instance identifier.

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

Question Tools

1 follower


Asked: 2016-06-14 05:46:44 -0700

Seen: 222 times

Last updated: Jul 07 '16