Ask Your Question
0

Given the ip address of a host as a string input to the ODL module how to get the node Id and ethernet address

asked 2016-07-07 03:56:40 -0700

knv gravatar image

I am trying to develop a shortestpath module and it works and is able to find the shortest path and insert flows in the switches if the node Id of the source and sink node are given as (host:00:00:00:00:00:01) etc. but what I actually want to do is give the ip address of the hosts as input and map them to NodeId and also ethernet address because the shortestpath finder module requires the node Id as the input, so if there is any rpc or module that could do the mapping and if anyone could throw some light on it that would be helpful.

Thank you, Nithin

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2016-07-07 04:38:14 -0700

karthik330 gravatar image

Hi Knv , I think there is no direct API for this . We have to implement . So basically you will give IP as input and you have to fetch other values right? have a look into this

try {
        nodes = tx.read(LogicalDatastoreType.OPERATIONAL, TOPO_IID)
                .checkedGet()
                .get().getNode();

    } catch (ReadFailedException e) {
        throw new IllegalStateException(e);
    }

    for (Node node : nodes) {

        if (node.getNodeId().getValue().startsWith("h")) {
            ipSwitch.put(node.getAugmentation(HostNode.class).getAddresses().get(0).getIp().getIpv4Address().getValue(),node.getAugmentation(HostNode.class).getAttachmentPoints().get(0).getTpId().getValue());
        }
    }

When application launch collect this details ; here looking into data store , and fetching all the nodeID, if it is host then fetch required data and storing into HashMap . So we have data what we looking for; Now when you give ip address as input , take the relevant details from map ! Also aware of updating map if new host added. Thanks !

edit flag offensive delete publish link more

Comments

Hi Karthik, the module says HostNode class unavailabe even after adding import org.opendaylight.yang.gen.v1.urn.opendaylight.host.tracker.rev140624.HostNode; should there be any changes made to the pom.xml and the dependencies because HostNode is a cleass from the host trackeer project.

knv ( 2016-07-07 06:26:42 -0700 )edit

<dependency> <groupid>org.opendaylight.l2switch.hosttracker</groupid> <artifactid>hosttracker-model</artifactid> <version>0.3.2-SNAPSHOT</version> </dependency>

karthik330 ( 2016-07-07 07:08:37 -0700 )edit

Add dependency in pom file ;change the version according to your odl-branch ;I think hostracker-impl dependency is not needed; If its not working add that also!

karthik330 ( 2016-07-07 07:10:34 -0700 )edit
Login/Signup to Answer

Question Tools

Follow
1 follower

Stats

Asked: 2016-07-07 03:56:40 -0700

Seen: 21 times

Last updated: Jul 07 '16