When running “load replace”, a leaf not saved in the same container is also replaced

when running “load replace”, a leaf not saved in the same container is also replaced .

Suppose there is a configuration:
luser1@CMYP-test(config)#show full-configuration container-a
container-a leaf-a “container-a leaf”
container-a container-a2 leaf-a xxx
And its modeling is as below:

container container-a {
    leaf leaf-a {
        type string;
    }
    container container-a2 {
       leaf leaf-a {
            type string;
        }
    }
}

My question is: if only leaf-a is saved by the following command, will “container-a2 leaf-a” be removed after running “load replace leaf.xml” and “commit”?
show full-configuration container-a leaf-a | display xml | save leaf.xml

Currently the behavior of ConfD is that “container-a2 leaf-a” will be deleted. But according to the explanation from Confd User Guide 7.3, I think it should not be removed.
I copied the sentences as below:
load (merge | replace | override) ( | terminal)
Load configuration from file or terminal.

replace Replace the content of file/terminal for the corresponding parts of the current configuration. This is different from override in the that only the parts that occur
in the file/terminal are replace, the rest of the configuration is left as is. In the case of override the entire configuration is deleted (with the exception of hidden data)
before loading the new configuration from the file/terminal.
override The current configuration is deleted and a new configuration is loaded from file/terminal. Hidden data is not affected.

Thank you very much.

Actually this is working as it should. The problem is that in the configuration you saved, ConfD has no way to distinguish between replacing just the leaf, which is what you want, with replacing the container. ConfD sees this as replacing the container a with the contents of the container as specified in leaf.xml, and so it will remove container a-2.

But if you change the value of leaf-a, and then do a load merge, you will get the behavior I think you want, where just the value of container-a leaf-a is restored and container-a container a2 leaf a is maintained.

Note that with NETCONF, you do have more control with annotations to pinpoint just what needs to change by using XML attribute operation=replace

Best regards,
Greg

1 Like