ConfD User Community

Building a command hierarchy from RPCs in CLI



What is the best way to create a command hierarchy in the CLI?
I want to use RPC-s defined in my YANG modules. By default they are populated into the request command in a flat structure. I would like to create a tree like structure:
request group-1 RPC-1
request group-1 RPC-3
request group-2 RPC-2




An RPCs statement must, according to the YANG RFCs (e.g. RFC7950), be placed at the top level in the module.

You may be looking for the YANG 1.1 action statement (or for YANG 1.0 the tailf:action extension)?



I want to create a standard NETCONF interface (with YANG 1.0), so I can’t use tailf specific extensions that changes how the NETCONF interface works.
It is not a problem on the NETCONF interface that the RPCs are not grouped. I just want to group them on the CLI interface. I found the cli-mount-point extension, but it is not well documented.




In that case I suggest you use the clispec to display the commands in the CLI.

An example similar to as if you were using an actionpoint in a RPC:

<cmd name="RPC-1" mount="request group-1">
    <info>Do something</info>
    <help>Do something using an rpc action</help>

See clispec(5) man page and the ConfD examples e.g under examples.confd/cli/c_cli

You can hide your YANG rpc from showing up in the CLI/JSON-RPC:

rpc RPC-1 {
      tailf:hidden dont-show-in-cli;
      tailf:actionpoint my-action-point;

You can use the same actionpoint for the YANG RPC and the clispec command. Example:

/* register the action handler callback */
struct confd_action_cbs acb;
memset(&acb, 0, sizeof(acb));
strcpy(acb.actionpoint, "my-action-point");
acb.init = init_action;
acb.action = do_action;
acb.abort = abort_action;
acb.command = do_action; // <-- Your CLI command variant