I want to access each leaf-list element individually for setting and getting as we do for list elements with a path like path/to/list{key}/. I tried to access each leaf-list element with path/to/leaf-list[index], but its saying invalid path. So I want to know whether there is any way to access each leaf-list element individually rather than getting the whole leaf-list as an array.
Also, is there a way to add a single leaf-list element to an existing leaf-list? And delete a single leaf-list element according to value, something like maapi_delete(path/to/leaf-list{element_value}) ?
Starting with ConfD 6.5, individual leaf-list elements can be created and deleted instead of setting/deleting the entire leaf-list as a single entity for prior releases.
I was trying with ConfD 6.4. But I have the ConfD 6.5 bin. I will try with that once. I went through the Confd 6.5 User Guide and examples(mostly), but I didn’t find any new information on leaf-list handling. So I would like to ask these questions for clarification(Considering Conf6.5 build).
(1) Will the path to the each leaf-list element be this: path/to/leaf-list[index]?
(2) How to add a single leaf-list element to an existing leaf-list? Will ‘maapi_set_elem(path/to/leaf-list, value)’ insert a leaf-list element to the existing leaf-list or will it update the existing leaf-list with the new leaf-list element(i.e., remove previous leaf-list and add a new leaf-list)?
(3) How does the deletion of single leaf-list element work in Confd 6.5? If I do a ‘maapi_delete(path/to/leaf-list[index])’, then will the confd automatically rearrange the remaining leaf-list or will the removed index be empty?
(4) Is there any way to delete a single leaf-list element according to value, something like ‘maapi_delete(path/to/leaf-list{element_value})’ which we do for a list?
Is there any example in the confd 6.5 examples set in which the individual leaf-list elements are set/delete?
The leaf-list related changes are described in the CHANGES file. A snippet of the description is as follows:
- confd: The internal representation of leaf-lists has changed.
Leaf-lists now behave similar to lists in terms of operations, i.e.,
individual elements can now be created and deleted instead of
setting/deleting the entire leaf-list as a single entity. Attributes
can be set on individual leaf-list elements.
...
You will use the {key_value} keypath notation to specify what leaf-list element to be added or which leaf-list element to be deleted.
You will use maapi_create(sock, thandle, path-of-leaf-list{value}) to add an element with value to the end of the leaf-list.
You will use maapi_delete(sock, thandle, path-of-leaf-list{value}) to delete an element with value from the leaf-list.
Read the description of the CHANGES file in ConfD 6.5 for more information on the leaf-list related changes.