Need Yang help for the following:-
want to set value of one YANG-leaf based on other YANG-leaf
YANG eqpt; leaf e-type; value alpha or beta
YANG facility; leaf entity; value forget or regret; default regret
set value facility/entity as forget if eqpt/e-type is beta
set value facility/entity as regret
can we do it in YANG?
we can do it through hooks but does YANG help here.?
Thank you in advance.
As i understand it, YANG itself does not conceptually verify the specific changes, only the “end state” of configuration.
Thus, you could validate value of leaf in YANG directly using “must” statement, but not do automatic flip to other value. This will help you prevent committing config with unwanted combination of leaf values, but still require northbound user to do correction to values.
Set-hook or transaction-hook is probably the way to go.
Other option, though this introduces a bit unnecessary complexity is transformation hook. (create new transformed leaf “myleaf”; in transformation callback when myleaf is set to “beta”, set “facility:entity” to forget, else…)
Also beware that any “automatic” changes to configuration can lead to potential synchronization problems with upper layer of network management if there’s any.
(user invokes change to leaf A in config, observable changes are - A is changed, B is changed as well)