ConfD User Community

Maapi_get_elem(/path/to/list[index]/element) gives error, but cdb_get(/path/to/list[index]/element) works fine in case of list


Consider this yang model :

container servers { list server { key name; max-elements 64; leaf name { type string; } leaf ip { type inet:ip-address; } } }

When I try to get a list element in maapi side using keypath with index, using maapi_get_ipv4(/servers/server[index]/ip, &ip_addr), it gives the following error :

DEBUG badly formatted or nonexistent path - Expected a key, not “[0]” after: /servers/server

But in case of cdb_get_ipv4 for the same path(cdb_get_ipv4(/servers/server[index]/ip, &ip_addr)), it gives proper output as expected. I don’t understand why this is happening. Do explain if I am doing something wrong.

Smruti Ranjan


When using maapi, you need to use the maapi cursor to iterate over the entries in a list in the data tree. Refer to the API documentation for maapi_init_cursor( ) in the ConfD User Guide for more information.