Summary:
I’m facing an issue during the restore process using Netconf’s <edit-config>
with the replace
operation. During testing, the restore fails due to the order of elements in the backup XML. More specifically, when there are dependencies between paths in the YANG (with leafref
), the natural ordering of the XML returned can lead to elements being sent in an invalid sequence during the <edit-config>
, triggering errors like data-missing
.
A practical example:
XML returned by <get-config>
(current order):
<data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<config xmlns="urn:example">
</config>
<router xmlns="urn:example">
</router>
<dot1q xmlns="urn:example:example-dot1q">
</dot1q>
[...]
</data>
The same XML required for successful restore (corrected order):
<data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<router xmlns="urn:example">
</router>
<config xmlns="urn:example">
</config>
<dot1q xmlns="urn:example:example-dot1q">
</dot1q>
[...]
</data>
This ordering difference is critical in the scenario mentioned above due to a leafref
configuration in the YANG model (service-vlan.yang
) defined as:
leaf vid {
type leafref {
path "/dot1q:dot1q/dot1q:vlan/dot1q:vlan-id";
}
}
If the vid
leaf is applied before the corresponding vlan-id
is configured, the restore fails with an illegal reference error, as confirmed in the ConfD logs:
<rpc-error xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<error-type>application</error-type>
<error-tag>data-missing</error-tag>
<error-severity>error</error-severity>
<error-app-tag>instance-required</error-app-tag>
<error-path xmlns:service="urn:example:service-vlan" xmlns:base="urn:example">
/rpc/edit-config/config/base:config/base:service/service:vlan[service:vid='196']/service:vid
</error-path>
<error-message xml:lang="en">
illegal reference /config/service/service:vlan[vid='196']/vid
</error-message>
<error-info xmlns:tailf="http://tail-f.com/ns/netconf/params/1.1"
xmlns:service="urn:example:service-vlan"
xmlns:base="urn:example"
xmlns:dot1q="urn:example:example-dot1q">
<tailf:bad-keyref>
<tailf:bad-element>/base:config/base:service/service:vlan[service:vid='196']/service:vid</tailf:bad-element>
<tailf:missing-element>/dot1q:dot1q/dot1q:vlan[dot1q:vlan-id='196']/dot1q:vlan-id</tailf:missing-element>
</tailf:bad-keyref>
</error-info>
</rpc-error>
My main questions are:
Given that I’ve already tested using the <test-option>
set to set (instead of the default test-then-set), and that I’m using netconf-console2 for the experiments:
- From the client side, is there any approach to retrieve and apply the configuration via Netconf without encountering these dependency errors?
- If no, is there any way to configure ConfD to generate
<get-config>
output with elements ordered in a way that respects those dependency constraints? - If no, is it possible to customize or hook into the serialization process to control the order of elements in the XML returned by
<get-config>
? - If no, are there any YANG annotations, ConfD configuration settings, or available extensions that allow the ordering of elements to be programmatically managed?