ConfD User Community

Configuration validation via CLI


#1

We have a situation where some obsolete lines can appear in configuration files.
We wrote a script which needs to be automatically invoked when load is initiated. The invocation is realized via clispec:

<clispec xmlns=“http://tail-f.com/ns/clispec/1.0” style=“c”>
<configureMode>
<modifications>
<move src=“load” dest=“xload” inclSubCmds=“true”/>
<hide src=“xload”/>
</modifications>
<cmd name=“load”>
<help/>
<info>Load configuration from an ASCII file</info>
<callback>
<exec>
<osCommand>/etc/confd/cliscripts/config_filter.sh</osCommand>
.
.

Inside the script this is called to load the file:

{ confd_cli -n -g admin -u admin << EOF
config
$(echo “xload $loadType $configFile”)
EOF
}

So far so good, but the issue arises after the script finishes we try to commit changes and we get a message that there is nothing to commit. We do not want to commit inside confd_cli because this changes the current flow of operation.

Is it possible to somehow preserve the loaded configuration when confd_cli finishes?
Is there a better way to implement this automatic script invocation?
Another question is will this change affect all northbound interfaces or CLI only?

BR Jaka


#2

As for other nothbound interfaces - any command definitions or modifications done in the clispec file affect only CLI, nothing else.

There are several other options how you can feed CLI-formatted configuration to ConfD: maapi --clicmd xload ... is probaby a better alternative to what you are doing, or you may want to try confd_load - see corresponding manpages. Both commands would attach to the existing CLI session using $CONFD_MAAPI_* environment variables, so the changes should be still there when your custom command completes.


#3

Solved with ‘maapi --clicmd “xload merge my.conf”’ call!

Thank your for your help