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

Just make a List<node> and put it in DeviceInfo and don't forget to submit. Since submit is actually putting your data to the Data Store.

@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");
}

for complete reference refer to https://github.com/justin-labry/listsample

You can check the result with apidoc as below. :-D image description

Have fun!

-Justin