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>