Hi,
I don’t know what or how your validation code/application determine that there is a validation error.
Your validation application should preferably not be written to validate changes/operations (seems like it does and then determines that the validation failed), rather it should validate the resulting changes.
You can point your application validation developer to ConfD UG Chapter 9.5. Validation Logic.
The difference between your two examples is that there is a maapi_delete_all() call before the configuration file is loaded. Use the “-d -d” option with the confd_load tool to get the libconfd trace output.
Using the validate/c example
$ pwd
/Users/tailf/confd-6.4.1/examples.confd/validate/c
$ confd_load -d -d -r -F p -p /mtest
TRACE Connected (maapi) to ConfD
starting user session ctxt=system user=system groups=[system]
TRACE MAAPI_START_USER_SESSION --> CONFD_OK
TRACE MAAPI_START_TRANS --> CONFD_OK
TRACE MAAPI_SAVE_CONFIG --> CONFD_OK
TRACE Connected (stream) to ConfD
<config xmlns="http://tail-f.com/ns/config/1.0">
<mtest xmlns="http://tail-f.com/ns/example/mtest">
<a_number>34</a_number>
<b_number>4</b_number>
</mtest>
TRACE MAAPI_SAVE_CONFIG_RESULT --> CONFD_OK
</config>
TRACE MAAPI_END_USER_SESSION --> CONFD_OK
$ cat test.xml
<config xmlns="http://tail-f.com/ns/config/1.0">
<mtest xmlns="http://tail-f.com/ns/example/mtest">
<a_number>3</a_number>
<b_number>4</b_number>
</mtest>
$ confd_load -d -d -l -F p test.xml
TRACE Connected (maapi) to ConfD
starting user session ctxt=system user=system groups=[system]
TRACE MAAPI_START_USER_SESSION --> CONFD_OK
TRACE MAAPI_START_TRANS --> CONFD_OK
TRACE MAAPI_LOAD_CONFIG_FILE --> CONFD_OK
TRACE MAAPI_APPLY_TRANS DEBUG external error - /mtest:mtest/a_number: a_number is <= b_number
--> CONFD_ERR
confd_load: 682: maapi_apply_trans_flags(sock, tid, 0, aflags) failed: external error (19): /mtest:mtest/a_number: a_number is <= b_number
$ confd_load -d -d -D -l -F p test.xml
TRACE Connected (maapi) to ConfD
starting user session ctxt=system user=system groups=[system]
TRACE MAAPI_START_USER_SESSION --> CONFD_OK
TRACE MAAPI_START_TRANS --> CONFD_OK
TRACE MAAPI_DELETE_ALL --> CONFD_OK
TRACE MAAPI_LOAD_CONFIG_FILE --> CONFD_OK
TRACE MAAPI_APPLY_TRANS DEBUG external error - /mtest:mtest/a_number: a_number is <= b_number
--> CONFD_ERR
confd_load: 682: maapi_apply_trans_flags(sock, tid, 0, aflags) failed: external error (19): /mtest:mtest/a_number: a_number is <= b_number
You can see the difference of the confd_load tool -r and -D flags compared to default behaviour just by typing confd_load -h, or in the confd_load man page, or in the confd_load source code that comes with ConfD:
$ confd_load -h
...
Valid options are (for further details, see the manpage):
-d debug flag
...
-m when loading config, merge [default is delete and replace]
-r when loading config, replace [default is delete and replace]
...
-D do maapi_delete_all(MAAPI_DEL_ALL) before loading