* Fixed: [State XML validation error when CLICON_MODULE_LIBRARY_RFC7895=true and ietf-yang-libra$

* Removed obsolete option: `CLICON_MODULE_LIBRARY_RFC7895'
  * Obsolete config options given in the confi file are considered an error
* Added section in CONTRIBUTING relating to optimzation
* Changed reset merge to implicit default values.
  * This avoids a potential overwriting of explicitly set default values in the existing config
* Adapted some code to [Make cligen_* functions const ](https://github.com/clicon/cligen/pull/83)
* Test: fixed test for * Fixed: [datamodel tree generated from basemodel tree is not proper when a list has more than one key and key is of enum type](https://github.com/clicon/clixon/issues/417)
This commit is contained in:
Olof hagsand 2023-02-12 16:01:08 +01:00
parent 7868cf0a0d
commit d358387d39
13 changed files with 77 additions and 59 deletions

View file

@ -276,6 +276,7 @@ parse_configfile(clicon_handle h,
cxobj *xt = NULL;
cxobj *xc = NULL;
cxobj *x = NULL;
yang_stmt *y;
char *name;
char *body;
clicon_hash_t *copt = clicon_options(h);
@ -357,6 +358,17 @@ parse_configfile(clicon_handle h,
xe = NULL;
}
}
/* Check obsolete options before default expansion */
x = NULL;
while ((x = xml_child_each(xt, x, CX_ELMNT)) != NULL) {
if ((y = xml_spec(x)) != NULL){
if ((yang_find(y, Y_STATUS, "obsolete")) != NULL){
clicon_err(OE_CFG, 0, "Clixon option %s is obsolete but given in the config file which is considered an error",
xml_name(x));
goto done;
}
}
}
if (xml_default_recurse(xt, 0) < 0)
goto done;
if ((ret = xml_yang_validate_add(h, xt, &xerr)) < 0)

View file

@ -194,7 +194,6 @@ yang_modules_revision(clicon_handle h)
* @retval 0 OK
* @retval -1 Error
* This assumes CLICON_YANG_LIBRARY is enabled
* If also CLICON_MODULE_LIBRARY_RFC7895 is set, module-state is built according to RFC7895 instead
* @see RFC8525
*/
int
@ -226,15 +225,10 @@ yang_modules_state_build(clicon_handle h,
clicon_err(OE_YANG, 0, "%s yang namespace not found", module);
goto done;
}
if (clicon_option_bool(h, "CLICON_MODULE_LIBRARY_RFC7895")){
cprintf(cb,"<modules-state xmlns=\"%s\">", yang_argument_get(yns));
cprintf(cb,"<module-set-id>%s</module-set-id>", msid);
}
else { /* RFC 8525 */
cprintf(cb,"<yang-library xmlns=\"%s\">", yang_argument_get(yns));
cprintf(cb,"<content-id>%s</content-id>", msid);
cprintf(cb,"<module-set><name>default</name>");
}
/* RFC 8525 */
cprintf(cb,"<yang-library xmlns=\"%s\">", yang_argument_get(yns));
cprintf(cb,"<content-id>%s</content-id>", msid);
cprintf(cb,"<module-set><name>default</name>");
ymod = NULL;
while ((ymod = yn_each(yspec, ymod)) != NULL) {
if (yang_keyword_get(ymod) != Y_MODULE)
@ -270,8 +264,6 @@ yang_modules_state_build(clicon_handle h,
break;
}
}
if (clicon_option_bool(h, "CLICON_MODULE_LIBRARY_RFC7895"))
cprintf(cb, "<conformance-type>implement</conformance-type>");
}
yinc = NULL;
while ((yinc = yn_each(ymod, yinc)) != NULL) {
@ -288,12 +280,7 @@ yang_modules_state_build(clicon_handle h,
}
cprintf(cb,"</module>");
}
if (clicon_option_bool(h, "CLICON_MODULE_LIBRARY_RFC7895")){
cprintf(cb,"</modules-state>");
}
else{
cprintf(cb,"</module-set></yang-library>");
}
cprintf(cb,"</module-set></yang-library>");
retval = 0;
done:
return retval;