This article gives a quick overview for the callbacks invocation order.
Callbacks on Candidate datastore
Assume we register all the possible callbacks and the edit is complex as possible. The possible invocation order may look as follows, processing on the candidate datastore (before the <commit>):
- Transaction Start
- Set Order Hook
- Set Hook and then Set Order Hook for the added edit, if any
- SIL Callbacks (only during Validate Phase)
- Transaction Complete
Callbacks on Running datastore
The possible invocation order during the <commit> operation may look as follows, processing on the running datastore (after the <commit>):
- Transaction Start
- Set Order Hook
- SIL Callback (Validate Phase)
- Validate Complete
- SIL Callback (Apply Phase)
- Apply Complete
- SIL Callback (Commit Phase)
- Transaction Hook
- Commit/Rollback Complete
- Transaction Complete
Callbacks when target=running
The <commit> operation is not available if the default target is set to running. Thus, the possible invocation order during the edit operation may look as follows, processing on the running datastore only (the same invocation order will be during Load, Reload and Restart operations):
- Transaction Start
- Set Order Hook
- Set Hook and then Set Order Hook for the added edit, if any
- SIL Callback (Validate Phase)
- SIL Callback (Apply Phase)
- SIL Callback (Commit Phase)
- Transaction Hook
- Transaction Complete
Callbacks during <validate>
The possible invocation order during the <validate> operation may look as follows, processing on the running datastore only:
- Transaction Start
- Set Order Hook
- SIL Callbacks (only during Validate Phase)
- Transaction Complete
Set Hook and Transaction Hook callbacks will not be invoke during explicit <validate> operation and in case of the following netconfd-pro parameters are set to TRUE:
--sil-validate-candidate (only relevant to Set Hook)
--sil-skip-load
Callbacks during <restore>
The possible invocation order during the <restore> operation may look as follows, processing on the running datastore only:
- Transaction Start
- Set Order Hook
- Set Hook and then Set Order Hook for the added edit, if any
- SIL Callback (Validate Phase)
- SIL Callback (Apply Phase)
- SIL Callback (Commit Phase)
- Transaction Hook
- Transaction Complete
Hooks callback interaction with EDIT2 callbacks (target=candidate)
In case there are multiple Set-Hook callbacks registered and the callbacks add several extra edits to the transaction with help of add_edit() API the server will have the following interaction with added edits and normal edits that are coming from PDU. Assume we register Set-Hook callback, Set-Order-Hook, Transaction-Hook and EDIT2 callback for the same list object, for example "ietf-interface" module and "/if:interfaces/if:interface" list object. So any time the "interface" list is getting edited the server invokes Set-Hook callback and adds up an extra "interface" in addition to the regular edit. The following callback invocation order is expected in this case:
Edit on candidate datastore:
- Transaction Start
- Set Order Hook for "/if:interface[name=vlan1]"
- Set-Hook for "/if:interface[name=vlan1]" to add "/if:interface[name=vlan2]"
- Set Order Hook for "/if:interface[name=vlan2]"
- SIL Callback (Validate Phase) for "/if:interface[name=vlan1]"
- SIL Callback (Validate Phase) for "/if:interface[name=vlan2]"
- Transaction Complete
Edit on running datastore (after <commit>):
- Transaction Start
- SIL Callback (Validate Phase) for "/if:interface[name=vlan1]"
- SIL Callback (Validate Phase) for "/if:interface[name=vlan2]"
- Validate Complete
- SIL Callback (Apply Phase) for "/if:interface[name=vlan1]"
- SIL Callback (Apply Phase) for "/if:interface[name=vlan2]"
- Apply Complete
- SIL Callback (Commit Phase) for "/if:interface[name=vlan1]"
- SIL Callback (Commit Phase) for "/if:interface[name=vlan2]"
- Transaction Hook for "/if:interface[name=vlan1]"
- Transaction Hook for "/if:interface[name=vlan2]"
- Commit/Rollback Complete
- Transaction Complete
Hooks callback interaction with EDIT2 callbacks (target=running)
Assume the same scenario but the default target in this case is set to running. The callbacks invocation order is expected to be:
- Transaction Start
- Set Order Hook for "/if:interface[name=vlan1]"
- Set-Hook for "/if:interface[name=vlan1]" to add "/if:interface[name=vlan2]"
- Set Order Hook for "/if:interface[name=vlan2]"
- SIL Callback (Validate Phase) for "/if:interface[name=vlan1]"
- SIL Callback (Validate Phase) for "/if:interface[name=vlan2]"
- SIL Callback (Apply Phase) for "/if:interface[name=vlan1]"
- SIL Callback (Apply Phase) for "/if:interface[name=vlan2]"
- SIL Callback (Commit Phase) for "/if:interface[name=vlan1]"
- SIL Callback (Commit Phase) for "/if:interface[name=vlan2]"
- Transaction Hook for "/if:interface[name=vlan1]"
- Transaction Hook for "/if:interface[name=vlan2]"
- Transaction Complete