ConfD User Community



“cli-show-template” is used to display an output.

How to do arithmetic operations using the “cli-template-string” ??

For Example

“\n Value \n”
+"($(val1) + $(val2))\n";

val1 and val2 are two leaf nodes and need a sum of their values to be displayed.

Kindly give your suggestions.


The type “cli-template-string” refers to a string that can be expendable based on the data model, but it doesn’t support arithmetic operations based on the man page: tailf_yang_cli_extensions

For your desired output, I would suggest modeling the result as an operational data that can be hidden from other NB interfaces and that would represent the addition of val1 and val2.

You can also model this as configuration but you will have to deal with updating it each time you update either val1 or val2, it will add an overhead to the commit transaction in this case.


cli-template-string supports the following template filter construct:


in which the value of ‘parameter’ processed by ‘filter’ is substituted. The template filter can be your own customized filter defined in a callback in which the arithmetic calculations can be performed. A template filter takes ‘parameter’ in string format as input in ‘argv[1]’ and returns a modified version of it by invoking the ‘confd_action_reply_command’. It can also take extra arguments. For example, the template filter can be defined as follows:


in which val1 is the name of your first leaf node to be added and will be passed into your callback as argv[1], and argv[2]=“val3”. You can then perform the addition in your callback function. However, “val2” will be passed into your callback function as a string literal and not the value of the val2 leaf node. You will need to use a MAAPI call to fetch the value of the val2 leaf node in your callback.


This property is applicable to ncs cli ?