# Get default values of leaf

**URL:** <https://dmap-community.ductus.global/t/get-default-values-of-leaf/3283>\
**Category:** NETCONF\
**Created:** [September 17, 2020, 5:38am UTC](https://dmap-community.ductus.global/t/get-default-values-of-leaf/3283 "2020-09-17T05:38:27Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Harshitha.Harish](https://avatars.discourse-cdn.com/v4/letter/h/838e76/32.png) [@Harshitha.Harish](https://dmap-community.ductus.global/u/Harshitha.Harish)\
**Post date:** [September 17, 2020, 5:38am UTC](https://dmap-community.ductus.global/t/get-default-values-of-leaf/3283/1 "2020-09-17T05:38:27Z")

</div>

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?

Thanks,  
Harshitha

---

<div class="post-metadata">

**Author:** ![mnovak](https://yyz2.discourse-cdn.com/flex010/user_avatar/dmap-community.ductus.global/mnovak/32/183_2.png) [@mnovak](https://dmap-community.ductus.global/u/mnovak)\
**Post date:** [September 17, 2020, 8:12am UTC](https://dmap-community.ductus.global/t/get-default-values-of-leaf/3283/2 "2020-09-17T08:12:37Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Harshitha.Harish](https://avatars.discourse-cdn.com/v4/letter/h/838e76/32.png) [@Harshitha.Harish](https://dmap-community.ductus.global/u/Harshitha.Harish)\
**Post date:** [September 17, 2020, 8:56am UTC](https://dmap-community.ductus.global/t/get-default-values-of-leaf/3283/3 "2020-09-17T08:56:40Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![mnovak](https://yyz2.discourse-cdn.com/flex010/user_avatar/dmap-community.ductus.global/mnovak/32/183_2.png) [@mnovak](https://dmap-community.ductus.global/u/mnovak)\
**Post date:** [September 17, 2020, 9:15am UTC](https://dmap-community.ductus.global/t/get-default-values-of-leaf/3283/4 "2020-09-17T09:15:08Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![mnovak](https://yyz2.discourse-cdn.com/flex010/user_avatar/dmap-community.ductus.global/mnovak/32/183_2.png) [@mnovak](https://dmap-community.ductus.global/u/mnovak)\
**Post date:** [September 17, 2020, 11:11am UTC](https://dmap-community.ductus.global/t/get-default-values-of-leaf/3283/5 "2020-09-17T11:11:38Z")

</div>

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).

---

<div class="post-metadata">

**Author:** ![Harshitha.Harish](https://avatars.discourse-cdn.com/v4/letter/h/838e76/32.png) [@Harshitha.Harish](https://dmap-community.ductus.global/u/Harshitha.Harish)\
**Post date:** [September 18, 2020, 11:15am UTC](https://dmap-community.ductus.global/t/get-default-values-of-leaf/3283/6 "2020-09-18T11:15:35Z")

</div>

I did try with C\_DEFAULT and CONFD\_DAEMON\_FLAG\_NO\_DEFAULTS  
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.

---

<div class="post-metadata">

**Author:** ![Harshitha.Harish](https://avatars.discourse-cdn.com/v4/letter/h/838e76/32.png) [@Harshitha.Harish](https://dmap-community.ductus.global/u/Harshitha.Harish)\
**Post date:** [September 21, 2020, 9:08am UTC](https://dmap-community.ductus.global/t/get-default-values-of-leaf/3283/7 "2020-09-21T09:08:04Z")

</div>

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

Thanks.

---

<div class="post-metadata">

**Author:** ![josephm](https://avatars.discourse-cdn.com/v4/letter/j/a88e57/32.png) [@josephm](https://dmap-community.ductus.global/u/josephm)\
**Post date:** [September 21, 2020, 9:23am UTC](https://dmap-community.ductus.global/t/get-default-values-of-leaf/3283/8 "2020-09-21T09:23:50Z")

</div>

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).

---

<div class="post-metadata">

**Author:** ![Harshitha.Harish](https://avatars.discourse-cdn.com/v4/letter/h/838e76/32.png) [@Harshitha.Harish](https://dmap-community.ductus.global/u/Harshitha.Harish)\
**Post date:** [September 22, 2020, 3:05am UTC](https://dmap-community.ductus.global/t/get-default-values-of-leaf/3283/9 "2020-09-22T03:05:46Z")

</div>

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