Restrict one leaf depending on other leaf

Hi,

I have a situation as explained below:
leaf-1 is boolean type.
leaf-2 is string type.
I must be allowed to modify leaf-1 all the time. But leaf-2 must be allowed to modify only when leaf-1 set to ‘false’.

more details:
case 1: leaf-1 set to true first. Must not allow any operations on leaf-2.
case 2: leaf-2 created, later leaf-1 set to ‘true’ (It should be allowed if i use must condition it fails) then i should not be able to modify leaf-2. leaf-2 operations should be allowed only after leaf-1 set to ‘false’ again.

Please help me how i can achieve this.

Thanks
Anil

Hello,

this sounds like a job for validation point…

  • user does some set of changes to transaction (cli/netconf/whatever northbound api)
  • validation point is triggered:
    • you check if “leaf-1” is set to false in pending transaction
    • you iterate any pending changes (e.g. maapi_diff_iter()),
      and if any other change exists, you “fail” - close validation with appropriate error message…

you can either see chapter on validation logic etc. in ConfD user guide (for confd 7.4, should be
chapters 11.5, 11.6, 11.7), or you can check example(s) in examples.confd/validate/c

Hello!
I have exactly the same use case…

Is there really no way to enforce this in the YANG using a construct similar to a ‘must’ or some tail-f extention?

Best regards,
Filip

Oh, I suppose “when” statement could be used as long as one accepts “when”'s “not being known” semantics as opposed to “non-modifiable”. Any other options?