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))
.addAugmentation(AddressCapableNodeConnector.class,
new AddressCapableNodeConnectorBuilder()
.setAddresses(Arrays.asList(new AddressesBuilder()
.setIp(ip).build())).build()).build();
Whereas I wanted to get hostNode objects, which is what l2switch uses to store its addresses:
org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.
network.topology.topology.NodeBuilder nb =
new org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.
network.topology.topology.NodeBuilder();
nb.setNodeId(MDSalAccessUtils.makeNewNodeId("garbl"))
.addAugmentation(HostNode.class,
new HostNodeBuilder().setAddresses(Arrays.asList(
new AddressesBuilder().setIp(ip)
.build())).build());
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) {
removedLink(oldLink);
newLink(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.