get a container of commands as input

I want to use a huge container as input. This container includes all commands which i want to use on a multi app environment.

here is a small example:

grouping bla-action-listener-type { leaf app-id { type application-id; tailf:info “The ID”; }

        tailf:action "request-status"
        {
            tailf:info "Request to write...";
            input;
            output
            {
                leaf console-out
                {
                    type string;
                }
            }
        }

        tailf:action "request-keep-alive"
        {

            tailf:actionpoint "bla-action-point";
            input;
            output
            {
                leaf console-out
                {
                    type string;
                }
            }
        }

        tailf:action "show-version"
        {
            tailf:actionpoint "bla-action-point";
            input;
            output

… and so on

I want to write a command which will get any possible leaf from this container, therefore I need something like this:

      tailf:action "multi-command"
    {
        tailf:actionpoint "i-action-point";

        input
        {
            uses bla-action-listener-type
            leaf command
             {
                type bla-action-listener-type;
                mandatory true;
            }
        }
        output
        {
            leaf console-out
            {
                type string;
            }
        }
        tailf:info "Runs a specified command from this list on a multi app environment";

    }

the current structure doesn’t work out. Does anyone has any idea?

You can’t have a grouping as a type., i.e. “type bla-action-listener-type;”

groupings are not types. It might be misunderstood as a C language data structure AND used as a type, which is wrong in YANG.
For the “type” statement, you can only use built-in types or derived types (Per the RFC).

A grouping in YANG can only be “used”, like you did in the input of “multi-command”, but not in the leaf command type.

I can help you further if I know what the structure of your commands you are trying to achieve.
Based on what I understood, you can have an enumeration defined for all of the actions, and just keep the “app-id” directly modeled in your “multi-command” action.

Something simple like this:

> tailf:action "multi-command"
>     {
>         ...
>         input
>         {
>             leaf application-id {
>                  type <sometype>;
>             }
>             leaf command
>              {
>                 type <enumeration_for_possible_commands>;
>                 mandatory true;
>             }
>         }
>         output
>         {
>             leaf console-out
>             {
>                 type string;
>             }
>         }
> }

Simple and cute! :slight_smile:

But this requires you create the enumeration for all of the actions, and potentially handle different inputs/outputs based on what the user specifies as action. Doable!
Otherwise why not add an application-id input field to each of the sub-actions like: “request-status”, “request-keep-alive”, “show-version”, etc… ?

Your requirement might be more complex than this but this is a start, and you can expand from a simple suggestion.

Hi Nabil,

Thanks for your reply.
bla-action-listener-type container is in another *.yang file.
The issue is that I want to avoid creating an enum per each command. I want to have just one callback which handles all these commands.
Your solution still makes me maintain any change in bla-action-listener-type container. I want this command to be generic, regardless if any command is added/removed to bla-action-listener-type container. Is there an option not to define an enumeration per each leaf in bla-action-listener-type container?