Ask is moving to Stack Overflow and Serverfault.com! 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

dataBroker how to get specified node of list from data tree

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

YANG:

  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 */

Impl.java

@Override
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();
    listNode.add(node1);
    listNode.add(node2);

    DeviceInfo operationalData = new DeviceInfoBuilder()
    .setName("Test Name")
    .setDescription("Test Desc")
    .setNode(listNode)
    .build();

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

    tx.put(LogicalDatastoreType.OPERATIONAL, DEVICE_IID, operationalData);
    tx.submit();

    LOG.info("HelloProvider Session Initiated");
}

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

dataBroker how to get specified node of list from data tree

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

YANG:

  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 */

Impl.java

@Override
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();
    listNode.add(node1);
    listNode.add(node2);

    DeviceInfo operationalData = new DeviceInfoBuilder()
    .setName("Test Name")
    .setDescription("Test Desc")
    .setNode(listNode)
    .build();

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

    tx.put(LogicalDatastoreType.OPERATIONAL, DEVICE_IID, operationalData);
    tx.submit();

    LOG.info("HelloProvider Session Initiated");
}

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