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

Revision history [back]

click to hide/show revision 1
initial version

Answering my own question.

My problem stemmed from using the wrong "side" of the yang model. Here is code from my reverse-engineering test, showing what I was trying to "get" from the dataBroker:

NodeConnector nc =  new NodeConnectorBuilder().setId(new NodeConnectorId(ncIdStr))
                            new AddressCapableNodeConnectorBuilder()
                            .setAddresses(Arrays.asList(new AddressesBuilder()

Whereas I wanted to get hostNode objects, which is what l2switch uses to store its addresses:
network.topology.topology.NodeBuilder nb = 

              new HostNodeBuilder().setAddresses(Arrays.asList(
                      new AddressesBuilder().setIp(ip)

Here's what I do to get the addresses (the process begins on 'link' notification events, which are themselves generated by DataTreeModification events):

public void newLink(Link link) {
    // openflow switch nodes have ids that begin with "openflow:".
    // Host nodes (aka service nodes) have ids that begin with the mac address of the node.
    Optional<HostNode> host = Optional.absent();
    NodeConnectorId altNc = null;
    if (!link.getSource().getSourceTp().getValue().contains("openflow:")) {
        host = MDSalAccessUtils.sourceHostNode(link, dataBroker);
        altNc = new NodeConnectorId(link.getDestination().getDestTp().getValue());
    } else if (!link.getDestination().getDestTp().getValue().contains("openflow:")) {
        host = MDSalAccessUtils.destHostNode(link, dataBroker);
        altNc = new NodeConnectorId(link.getSource().getSourceTp().getValue());
    if (host.isPresent()) {
        for (Addresses addresses : host.get().getAddresses()) {
            realNodeAddresses.put(altNc, addresses.getIp());

public void updatedLink(Link oldLink, Link newLink) {

public void removedLink(Link link) {
    realNodeAddresses.remove(new NodeConnectorId( link.getDestination().getDestTp().getValue() ) );
    realNodeAddresses.remove(new NodeConnectorId( link.getSource().getSourceTp().getValue() ) );

MDSalAccessUtils is a custom utility class. The method used here is a simple read from databroker using a NetworkTopology --- Topology "flow:1" --- Node "nodeId" path.