Validating operation

I have an action point that i’d like to verify against my configuration by specifying a must statement. Is it even possible to do?

As specified in section 8.1 of the YANG RFC 6020, constraints can be defined for the following types of data in your YANG data model:

8.1 Constraints on Data

   Several YANG statements define constraints on valid data.  These
   constraints are enforced in different ways, depending on what type of
   data the statement defines.

   o  If the constraint is defined on configuration data, it MUST be
  true in a valid configuration data tree.

   o  If the constraint is defined on state data, it MUST be true in a
  reply to a <get> operation without a filter.

   o  If the constraint is defined on notification content, it MUST be
  true in any notification instance.

   o  If the constraint is defined on RPC input parameters, it MUST be
  true in an invocation of the RPC operation.

   o  If the constraint is defined on RPC output parameters, it MUST be
  true in the RPC reply.

NETCONF RPC is like an actionpoint. You can certainly define must statements for the input and output parameters of your actionpoints.

For some reason the ‘must’ condition I place in the action point does not validate my input correctly according to the stored data. Is there a way, via confd_cli, to view the xpath evaluation of the confd_cli process so I can clearly see where my xpath expression fails?

To debug XPath expressions, you can enable XPath tracing in confd.conf using the following:

/confdConfig/logs/xpathTraceLog - container element
xpathTraceLog is a log for understanding and troubleshooting XPath evaluations. When this log is enabled, the execution of all XPath queries evaluated by ConfD is logged to a file.

This will slow down ConfD, so be careful when enabling this log. This log is not rotated, i.e. use logrotate(8).

/confdConfig/logs/xpathTraceLog/enabled (xs:boolean) [false] enabled is either "true" or "false". If "true", all XPath execution is logged.

/confdConfig/logs/xpathTraceLog/filename (xs:string) The name of the file where the XPath trace log is written.

An example setting in confd.conf for this section is as follows:

<xpathTraceLog>
  <enabled>true</enabled>
  <filename>./xpath.trace.log</filename>
</xpathTraceLog>

Another mechanism is to use the ‘must’ and ‘xpath’ CLI commands as shown in the examples.confd/validate/xpath_must example.

Thank you very much! This is extremely helpful.
Where can I download examples.confd from?

Thanks,

Michal

The examples are included in the zip file that ConfD come in when you download from DevNet
https://developer.cisco.com/site/confD/downloads/
The example tarball in the zip file is called confd-basic-version.examples.tar.gz

Also, see examples.confd/validate/xpath_must. In addition to showing the XPath trace log, this example shows a simple way via clispec to add interactive ‘must’ and ‘xpath’ test commands to the CLI to help with debugging.