ConfD User Community

I entered a default value in my YANG module, but it doesn’t show

With the default ConfD configuration confd.conf, the default value will not show. The main purpose here is that whenever a leaf has a default value it implies that the leaf can be left out from the XML document, i.e. mandatory = false. An example when default values are used is when a new instance is created. If all leafs within the instance have default values, these need not be specified in, for example, a NETCONF create operation.
Even though they don’t show from NETCONF or in the CLI, the subscribers for configuration changes will be able to read out the values from CDB.

You can however change that behaviour in the confd.conf ConfD configuration. Under
/confdConfig/defaultHandlingMode
If we in confd.conf enter

<defaultHandlingMode>report-all</defaultHandlingMode>

Now all values will be logically stored in the data store, and displayed over all northbound interfaces, e.g. NETCONF, CLI, MAAPI etc.

Defaults handling for can be set per context to for example only NETCONF in confd.conf:
/confdConfig/netconf/capabilities/ietf-with-defaults/enabled
If “true”, the with-defaults capability, defined in RFC 6243, is enabled.

Quick demo:

$ pwd
confd-5.4/examples.confd/intro/1-2-3-start-query-model
$ make all start

In another terminal window:

$ pwd
confd-5.4/examples.confd/intro/1-2-3-start-query-model
$ more dhcpd.yang
    ...
    container dhcp {
        must "boolean(ifnames)" {
                error-message
                  "Command list must not be empty once initialized";
              }
        leaf-list ifnames {
          type string;
        }
        leaf defaultLeaseTime {
          type xs:duration;
          default PT600S;
        }
        leaf maxLeaseTime {
          type xs:duration;
          default PT7200S;
        }
        leaf logFacility {
          type loglevel;
          default local7;
        }
        container SubNets {
          uses subNet;
        }
        container SharedNetworks {
          list sharedNetwork {
            key name;
            max-elements 1024;
            leaf name {
              type string;
            }
            container SubNets {
              use  s subNet   ;
            }
          }
        }
      }
    ...

We issue a NETCONF <get> request. The <rpc-reply> show that no configuration values have been stored and defaults from our YANG data model do not show:

$ netconf-console -i 
* Enter a NETCONF operation, end with an empty line
<get>
  <filter xmlns="http://tail-f.com/ns/example/dhcpd">
    <dhcp/>
  </filter>
</get>

<?xml version="1.0" encoding="UTF-8"?>
<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="2">
  <data/>
</rpc-reply>

Somewhere in confd.conf we enter:

<defaultHandlingMode>report-all<defaultHandlingModex>

After restarting ConfD to read the new confd.conf setting, the same NETCONF request now return the default values that we set in our YANG model:

$ netconf-console -i
* Enter a NETCONF operation, end with an empty line
<get>
  <filter xmlns="http://tail-f.com/ns/example/dhcpd">
    <dhcp/>
  </filter>
</get>

<?xml version="1.0" encoding="UTF-8"?>
<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="2">
  <data>
    <dhcp xmlns="http://tail-f.com/ns/example/dhcpd">
      <defaultLeaseTime>PT600S</defaultLeaseTime>
      <maxLeaseTime>PT7200S</maxLeaseTime>
      <logFacility>local7</logFacility>
    </dhcp>
  </data>
</rpc-reply>

Thanks for the info. :slight_smile:

A question on the “explicit” option: Under what circumstances will the default be return for <get> or <get-config>? Or is it always empty unless the leaf is explicitly set to the default value in the config?

ConfD UG says:

‘explicit’ If a value is set over a northbound interface, it is not considered default.
Default values are not displayed in northbound interfaces, unless asked for by the user.

What does “asked for by the user” mean? How can they ask for such values?

Thanks!

For NETCONF See the RFC on default values and “with-defaults”. https://datatracker.ietf.org/doc/html/rfc6243#appendix-A.3

Thx.

What about CLI (with ‘explicit’ option)? I know there’s the “show-defaults” toggle, but my observation is even when it’s set to true, the leaf’s default value is displayed with and only with its already set value. i.e., default value is only visible when the leaf is set to some value, otherwise the CLI would say “No entries found”.

  1. With the ‘explicit’ option, is there a way to get the default regardless of the leaf being set or not?
  2. How would ‘report-all’ behave differently?

Thanks again!

Try the “details” pipe command.

I assume you are still referring to the CLI. The default value will be shown even without the “details” pipe command