ConfD User Community

Get default values of leaf

I have a requirement where in I have multiple leaf under a container with default values given. When i do a ‘get’ on the container i want the default values to be displayed of the leaf.

I tried report-all but this does a ‘set’ on all the leaf with default value.

Since i am using a external database i do not want it to set all the leaf. But instead only when i do a get i want it to display the default values in the xml format.

So how do I achieve the above scenario?


For external database, you should return C_DEFAULT (use CONFD_SET_DEFAULT(&v);) in get_... callback (e.g. get_elem).

Also check in confd.conf how /confdConfig/defaultHandlingMode s set.

What interface do you use to GET values? NETCONF, CLI?

I have tried /confdConfig/defaultHandlingMode
It considers either report-all or trim or explicit as the valid values. But in all cases a ‘set’ is also done.
I want set to be done only for the specific leaf mentioned. The other attributes/leaf with default values must be seen only in case of ‘get’.

I use NETCONF interface to do a GET most of the time. But I can use CLI too.

As you said, you have implemented “external database”. Do you handle default values (returning C_DEFAULT) in your external database callbacks?

You may also try confd_set_daemon_flags and set CONFD_DAEMON_FLAG_NO_DEFAULTS, so the set_elem is not issued for default values (see confd_lib_dp in User Guide or man pages).

i am facing some other issue now where i see ‘application protocol error’.

Is there a api or flag to check if a leaf has a default value or not?

If there is then i can check if it has default value and then do a CONFD_SET_DEFAULT(&v) else return it without the default value.

Can someone please assist regarding the above mentioned issue.
How to check if a leaf has a default value?


looking into confd_lib.h, the structure confd_cs_node_info has a field confd_value_t *defval;.

So if you use some of the CS node procedures to get information about YANG model schema (see man page for confd_lib_lib), like confd_find_cs_node(), i assume check for node->defval != NULL will work (resp. if it’s not null, maybe extra check for node->defval.ctype != C_NOEXISTS, but i’m not sure if it’s needed, you can test it during implementation).

Thanks a lot for the suggestion. This method works fine. I did not have to check with C_NOEXISTS

1 Like