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


dataBroker how to get specified node of list from data tree

asked 2015-08-31 03:12:24 -0800

kevin5476 gravatar image

updated 2015-08-31 03:14:20 -0800

If I make a List<node> and put it in DeviceInfo</node>


  container device-info {
  leaf name {
    type string;
    config false;

  leaf description {
    type string;
    config false;

  list node {
      key "id";
      leaf id {
          type string;
      leaf description {
          type string;
} /* End container */

public void onSessionInitiated(ProviderContext session) {

    db = session.getSALService(DataBroker.class);
    notificationService = session.getSALService(NotificationProviderService.class);

    List<Node> listNode = new LinkedList<Node>();
    Node node1 = new NodeBuilder().setId("1").setDescription("this is the first node").build();
    Node node2 = new NodeBuilder().setId("2").setDescription("this is the second node").build();

    DeviceInfo operationalData = new DeviceInfoBuilder()
    .setName("Test Name")
    .setDescription("Test Desc")

    WriteTransaction tx = db.newWriteOnlyTransaction();
    InstanceIdentifier<DeviceInfo> DEVICE_IID = InstanceIdentifier.builder(DeviceInfo.class).build();

    tx.put(LogicalDatastoreType.OPERATIONAL, DEVICE_IID, operationalData);
    tx.submit();"HelloProvider Session Initiated");

How do I get the description(leaf) of the particular ID(key) ?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2015-08-31 06:27:07 -0800

Robert Varga gravatar image

updated 2015-08-31 06:28:54 -0800

Leaves are not directly addressable via InstanceIdentifier. In order to fetch them, you need to read the container in where these reside, in this case a keyed item, hence:

InstanceIdentifier<Node> id = InstanceIdentifier.create(DeviceInfo.class).child(Node.class, new NodeKey("1"));
ReadOnlyTransaction tx = db.newReadOnlyTransactio();
Node node =, id).get();
String desc = node.getDescription();
edit flag offensive delete publish link more
Login/Signup to Answer

Question Tools



Asked: 2015-08-31 03:12:24 -0800

Seen: 359 times

Last updated: Aug 31 '15