ConfD User Community

Mutual exclusive nodes

Hello!

I need to have two groups of leaf nodes within an input block that should be mutually exclusive.
Within each group, I need to have further mutually exclusive leaf nodes (using switch-case)
I tried something like this but didn’t work. Please suggest.

container platform {
  tailf:action condition {
  tailf:actionpoint process_func;
  tailf:cli-operational-mode;
  input {
    choice filter-choice {
      case group1 {
        /*grouping of 5 leaf nodes */
      }
      case group2 {
        /* grouping of 3 leaf nodes that are in a choice-case block */
      }
    }
 }

What is not working? Is group1 and group2 mutually exclusive?
Under case group2 you can have another nested choice with case sub-statements.

group1 and group2 are required to be mutually exclusive but I still see the leaf nodes of group1 in possible completions after configuring group2 leaf.

that is imho correct/expected behavior of switch statement -> other case statements can still be set (to allow user to switch :slight_smile: ), causing “switch” and automatic removal of pending case leaves/nodes…

In that case, how do we achieve the mutual exclusiveness of the outer choice-case block, that is group1 and group2?
Basically, if I configure any leaf from group2’s cases then I don’t wish to see any leaf from group1 in the possible completions.
Similarly, if I configure any leaf from group1 then I don’t wish to see any leaf from group2 in the possible completions.

How do I achieve this?

Mutual exclusivity is about what can in valid configuration (commited), and is enforced correctly imho.

If you configure:

leaf g2 (from group2)
leaf g1 (from group1)

leaf g2 will be automatically removed, as defined by switch behavior.

CLI completions on the other hand show what you can set/change at specific moment in config.
When leaf g2 is set, user still has option to switch value to leaf g1. If CLI didn’t show it, he wouldn’t know about other options/cases…

worst case, you could maybe try to add some when statements on group children
(when not(./other-group-elements);

but even if it works, it will imho lead to cumbersome behavior in CLI - you would need to explicitly delete all the current group elements, to be able to start configuring other group data…

And info about groups/cases is not part of data model (only of schema - unless you add some group specific parent containers)…

That helped my understanding!

So, my group2 has 3 case statements(that are mutually exclusive among each other).
If I set g2 (one of case leaves from group2) and I still see the group1 leaves in possible completions and I set g1 (one of the leaves from group1) then it throws error: “g2” is an invalid value.
[I can successfully set g2 individually though, i.e without any other leaf ]

Whereas, if I set g1 then I don’t see any leaf from group2 in the possible completions.

edit: :man_facepalming: sorry- now i realized that we discuss ACTION here… so, all the input parameters have to be entered at once; Your requirement sort of makes sense in this case! :slight_smile:

I haven’t used more complex cases in action myself. Maybe you could change the “big action” into separate actions without parent choice statement to simplify parameters for user?

what i wrote down below applies co choice statements when working with normal configuration, and is bit different for action invocation of course…

— original response (effective for config, not 100% for action’s case statement)

So, my group2 has 3 case statements(that are mutually exclusive among each other).
If I set g2 (one of case leaves from group2) and I still see the group1 leaves in possible completions

yes, so far as expected

and I set g1 (one of the leaves from group1)

yes, normal use-case when working with choice statement elements (switching between groups)

then it throws error: “g2” is an invalid value.

no, it will set g1 leaf, and drop/delete all the data that belongs to cases other than g1

[I can successfully set g2 individually though, i.e without any other leaf ]

yes, any elements in all the cases should be visible

Whereas, if I set g1 then I don’t see any leaf from group2 in the possible completions.

after g1 is set, all the other case leaves should be visible in completion hints…