Configuration transactions and how to massage data prior to commit

Changing configuration in ConfD is done in a transactional way: setting data goes through multiple phases before it gets committed to the running datastore.
ConfD is flexible in a way that allows applications to participate in multiple phases of the life of a transaction.

It is very important to understand the different phases of a transaction in order to understand what can be done and when it can be done.

For example:

  • The validation phase: Here ConfD validates data based on the constraints present in YANG. There is also an API that allows applications to run their special validation cases that can’t be formulated in YANG. This is a way for applications to be part of the transaction for validation purposes only.

  • If an application needs to write more data in CDB in the same transaction, there is a mechanism implemented in the form of YANG extensions called hooks (set-hook and transaction-hook). Hooks allow applications to write or delete data in the same transaction that triggered the hook call.

This is a very fundamental feature that puts users as well as systems/applications on the same side of ConfD and allow them to modify data in a single transaction.
A use case of this feature would be the need for an application to persist some data in CDB that has to be generated from the user’s set elements (Example: an SNMP index needs to be stored in CDB but can only be system generated, Or a bit mask that needs to be stored in CDB and updated each time a leaf is modified).

More information can be found in the user guide, chapter 10.