If the client deletes a container of list entries, then the server will normally only invoke the SIL callback for deletion for the container.
It may be easier to allow the server to use the SIL callbacks for the child list nodes, to delete a data structure “bottom-up”. Use the sil-delete-children-first extension to force the server to delete all the child nodes before deleting the parent container.
The sil-delete-children-first extension can be used in any parent node (container or list) and can be used to force the server to invoke the SIL callback for any child node (container, list, leaf, leaf-list, anyxml).
The sil-delete-children-first extension is used within a container or list definition to indicate that the SIL callbacks for descendant nodes should be invoked first, when a data node instance of the object containing this extension is deleted. Normally, the parent node is expected to delete all its own sub-structures when the SIL edit callback is invoked.
If this extension is present, then any SIL callbacks for any of the child nodes will be invoked first instead. If a child node is a list or a container, and it also contains an sil-delete-children-first extension, then its children will be checked first. The SIL edit callback will not be invoked for leaf, leaf-list, or anyxml descendant nodes in this mode. They will only be called if their parent node is not getting deleted.
Example
YANG File: netconf/modules/netconfcentral/yuma-ncx.yang
container foo { ncx:sil-delete-children-first; listfoos { ncx:sil-delete-children-first; keya; leafa { type string; } containerb { listc { ... } } leafd { type empty; } } }
In this example, assume node /foo gets deleted. Then the SIL edit callbacks would be done as follows:
1) /foo/foos[a='n']/b (called for row 'n' of /foo/foos)
2) /foo/foos[a='n'] (called for row 'n' of /foo/foos)
3) repeat (1,2) until all rows in /foo/foos are deleted
4) /foo
Note that the SIL edit callback is not done for list /foo/foos[a='n']/b/c because this extension is not present in container '/foo/foos/b'. Note that the SIL edit callback is not done for nodes /foo/foos[a='n']/a or /foo/foos[a='n']/d because they are leafs.
In the scenario where the data model utilizes the "sil-priority" extension the server may change the order of the callbacks based on the priority.
For example, assume the following simplified but functional data model:
container interfaces { ywx:sil-priority 200; list interface { ncx:sil-delete-children-first; container vrrp { ... } container vrrp-ipv4 { ywx:sil-priority 245; list vrrp-instance { ... } } container vrf { ywx:sil-priority 255; ... } } ... }
1) Now, assume we run CREATE on "/interfaces" with a list entry and all the children.
This operation will produce the following SIL callback invocation order:
SIL Callback Target | SIL Callback Priority |
silcall for interfaces | 200 |
silcall for interface | 200.200 |
silcall for vrrp | 200.200.200 |
silcall for vrrp-ipv4 | 200.200.245 |
silcall for vrrp-instance | 200.200.245.245 |
silcall for preempt | 200.200.245.245.245 |
silcall for advertise-interval | 200.200.245.245.245 |
silcall for vrf | 200.200.255 |
2) Now assume we run DELETE operation on "/interfaces/interface" list entry with:
--sil-prio-reverse-for-deletes=true
--sil-delete-children-first=true
This operation will produce the following SIL callback invocation order:
SIL Callback Target | SIL Callback Priority |
silcall for vrf | 200.200.255 |
silcall for advertise-interval | 200.200.245.245.245 |
silcall for preempt | 200.200.245.245.245 |
silcall for vrrp-instance | 200.200.245.245 |
silcall for vrrp-ipv4 | 200.200.245 |
silcall for vrrp | 200.200.200 |
silcall for interface | 200.200 |
silcall for interfaces | 200 |
3) Now, assume we run DELETE operation on "/interfaces/interface" list entry with:
--sil-delete-children-first=true
And NO any reversion
This operation will produce the following SIL callback invocation order:
SIL Callback Target | SIL Callback Priority |
silcall for vrrp | 200.200.200 |
silcall for advertise-interval | 200.200.245.245.245 |
silcall for preempt | 200.200.245.245.245 |
silcall for vrrp-instance | 200.200.245.245 |
silcall for vrrp-ipv4 | 200.200.245 |
silcall for vrf | 200.200.255 |
silcall for interface | 200.200 |
silcall for interfaces | 200 |