The <with-defaults> capability indicates that a device has the capability to process default values of the model. The <get>, <get-config>, and <copy-config> operations can carry the <with-defaults> parameter.
The <with-defaults> parameter values are as follows:
report-all: Query all nodes and do not perform any operation on the nodes.
RPC request:
<?xml version="1.0" encoding="utf-8"?> <rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="4"> <get xmlns:wsss="urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults"> <filter type="subtree"> <system xmlns="urn:huawei:yang:huawei-system"/> </filter> <with-defaults xmlns="urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults">report-all</with-defaults> </get> </rpc>
RPC reply:
<?xml version="1.0" encoding="utf-8"?> <rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="4"> <data> <system xmlns="urn:huawei:yang:huawei-system"> <systemInfo> <lsRole>admin</lsRole> <authenFlag>false</authenFlag> </systemInfo> </system> </data> </rpc-reply>
trim: The nodes whose values equal to default ones are not displayed in the query result.
RPC request:
<?xml version="1.0" encoding="utf-8"?> <rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="3"> <get xmlns:wsss="urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults"> <filter type="subtree"> <system xmlns="urn:huawei:yang:huawei-system"/> </filter> <with-defaults xmlns="urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults">trim</with-defaults> </get> </rpc>
RPC reply:
<?xml version="1.0" encoding="utf-8"?> <rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="3"> <data> <system xmlns="urn:huawei:yang:huawei-system"> <systemInfo> <lsRole>admin</lsRole> </systemInfo> </system> </data> </rpc-reply>
report-all-tagged: Query all nodes and use namespace:default="true" to identify the nodes whose values equal to default ones.
RPC request:
<?xml version="1.0" encoding="utf-8"?> <rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="2"> <get xmlns:wsss="urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults"> <filter type="subtree"> <system xmlns="urn:huawei:yang:huawei-system"/> </filter> <with-defaults xmlns="urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults">report-all-tagged</with-defaults> </get> </rpc>
RPC reply:
<?xml version="1.0" encoding="utf-8"?> <rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:wd="urn:ietf:params:xml:ns:netconf:default:1.0" message-id="2"> <data> <system xmlns="urn:huawei:yang:huawei-system"> <systemInfo> <lsRole>admin</lsRole> <authenFlag wd:default="true">false</authenFlag> </systemInfo> </system> </data> </rpc-reply>
If a node is identified using namespace:default="true", the <edit-config> operation can identify the <default> attribute on the node and determine whether the node value equals to the default one.
The <operation> attribute of the <edit-config> operation can only be create, merge, or replace. If the <operation> value is remove or delete, <rpc-error> is returned
The <default> attribute value of the leaf node ifDf is true, and the node value is false, which is the same as the default value defined in the YANG file. After the <edit-config> operation is performed, <ok> is returned.
RPC request:
<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="2"> <edit-config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:wd="urn:ietf:params:xml:ns:netconf:default:1.0"> <target> <running/> </target> <config> <ifm xmlns="urn:huawei:yang:huawei-ifm"> <interfaces> <interface xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="merge"> <ifName>GigabitEthernet1/0/0</ifName> <ifDf wd:default="true">false</ifDf> </interface> </interfaces> </ifm> </config> </edit-config> </rpc>
RPC reply:
<rpc-reply message-id="2" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"> <ok/> </rpc-reply>
The <default> attribute value of the leaf node ifDf is true, and the node value is true, which is different from the default value defined in the YANG file. After the <edit-config> operation is performed, <rpc-error> is returned. <error-para> contains the name and value of the error node.
RPC request:
<?xml version="1.0" encoding="utf-8"?> <rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="2"> <edit-config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:wd="urn:ietf:params:xml:ns:netconf:default:1.0"> <target> <running/> </target> <config> <ifm xmlns="urn:huawei:yang:huawei-ifm"> <interfaces> <interface xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="merge"> <ifName>GigabitEthernet1/0/0</ifName> <ifDf wd:default="true">true</ifDf> </interface> </interfaces> </ifm> </config> </edit-config> </rpc>
RPC reply:
<?xml version="1.0" encoding="utf-8"?> <rpc-reply xmlns:nc-ext="urn:huawei:yang:huawei-ietf-netconf-ext" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="2" nc-ext:flow-id="27"> <rpc-error> <error-type>application</error-type> <error-tag>bad-element</error-tag> <error-severity>error</error-severity> <error-path xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:ifm="urn:huawei:yang:huawei-ifm">/nc:rpc/nc:edit-config/nc:config/ifm:ifm/ifm:interfaces/ifm:interface[ifm:ifName='Ethernet0/1/0']/ifm:ifDf</error-path> <error-message xml:lang="en">ifDf has invalid value true.</error-message> <error-info xmlns:nc-ext="urn:huawei:yang:huawei-ietf-netconf-ext"> <bad-element>ifDf</bad-element> <nc-ext:error-info-code>317</nc-ext:error-info-code> <nc-ext:error-paras> <nc-ext:error-para>ifDf</nc-ext:error-para> <nc-ext:error-para>true</nc-ext:error-para> </nc-ext:error-paras> </error-info> </rpc-error> </rpc-reply>