Issue with 'must' constraint

Hello,

I have a tailf:action with input block that takes 3 leaf nodes: vpn-id, source-ip and interface. I have a constraint that vpn-id must be configured if the interface is configured. Both vpn-id and interface are of type leafref, pointing to a valid config tree.

    input {
      leaf vpn-id {
        type leafref {
          path "<valid-path-here>";
          tailf:cli-expose-key-name;
        }
      }
      leaf interface {
        must "(../vpn-id)" {
          error-message "vpn-id must be configured";
         }
         type leafref {
           path "<valid path here>";
         }
       }
       leaf source-ip { };
     }
  1. When I configure only interface and give a ‘?’, it shows cr even though vpn-id is not configured. The command shouldn’t show cr unless vpn-id is configured when the interface is also configured. How can I fix it?

  2. If I hit enter after configuring only the interface, instead of throwing the error-message under must, it throws the Error: illegal reference which I believe is coming from the leafref of interface. How can I print the error-message under must instead of the illegal reference error?

Please suggest.

  1. You may try to wrap the leafs in a container annotated with cli-drop-node-name, cli-sequence-commands, cli-compact-syntax - this would force the user to provide the leafs in the order as they are modeled. Note though that actions are not particularly good tool for modeling CLI commands, if your primary interface is CLI, maybe you should use clispec-modeled commands instead.

  2. ConfD does not report all constraint violations, it reports just the first one that it detects. If you provide correct interface leafref but do not provide vpn-id, ConfD reports the must error message.

Can we use cli-compact-syntax in actions? The compilation throws error if I do so.
Also, I tried to model the yang as per your suggestion(except the cli-compact-syntax because it didn’t compile) but I still see the cr in the possible completions.

container debug {
   tailf:action filter {
     tailf:actionpoint ap;
     tailf:cli-operational-mode;
     input {
      container interface {
        tailf:cli-drop-node-name;
        tailf:cli-sequence-commands;
        tailf-cli-compact-syntax;
        leaf ingress-if { };
        leaf vpn-id { };
      }
      leaf source-ip { };
    }
  }
}

For that you can use tailf:cli-incomplete-command.