* New "general-purpose" datastore upgrade callback added which i called once on startup, intended for lo

w-level general upgrades and as a complement to module-specific upgrade.
  * Called on startup after initial XML parsing, but before module-specific upgrades
  * Enabled by definign the `.ca_datastore_upgrade`
  * [General-purpose upgrade documentation](https://clixon-docs.readthedocs.io/en/latest/backend.html#ge
neral-purpose)
* JSON parse error messages change from ` on line x: syntax error,..` to `json_parse: line x: syntax err
or`
* Unknown-element error message is more descriptive, eg from `namespace is: urn:example:clixon` to: `Fai
led to find YANG spec of XML node: x with parent: xp in namespace urn:example:clixon`.
* C-API parse and validation API more capable
  * `xml_spec_populate` family of functions extended with three-value return values
    * -1: error, 0: parse OK, 1: parse and YANG binding OK.
  * `xml_parse` and `json_parse` API changes
    * Three value returns: -1: error, 0: parse OK, 1: parse and YANG binding OK.
    * Extended `xml_parse_file2` and `xml_parse_string2` extended API functions with all options available.
      * New concept called `yang_bind` that defines how XML symbols are bound to YANG after parsing
    * Existing API same except `xml_parse_file` `endtag` argument moved to `xml_parse_file2`
* C-API: Added instrumentation: `xml_size` and `xml_stats_get`.
* Fixed: Enabling modstate (CLICON_XMLDB_MODSTATE), changing a revision on a yang, and restarting made the backend daemon exit at start (thanks Matt)
  * Also: ensure to load `ietf-yang-library.yang ` if CLICON_XMLDB_MODSTATE is set
This commit is contained in:
Olof hagsand 2020-02-20 14:00:01 +01:00
parent d665992f7c
commit 9fa5e216c4
80 changed files with 2204 additions and 755 deletions

View file

@ -2,7 +2,8 @@
*
***** BEGIN LICENSE BLOCK *****
Copyright (C) 2009-2020 Olof Hagsand
Copyright (C) 2009-2019 Olof Hagsand
Copyright (C) 2020 Olof Hagsand and Rubicon Communications, LLC
This file is part of CLIXON.
@ -99,7 +100,7 @@ object.
/* Here starts user C-code */
/* typecast macro */
#define _JY ((struct clicon_json_yacc_arg *)_jy)
#define _JY ((clixon_json_yacc *)_jy)
#define _YYERROR(msg) {clicon_err(OE_XML, 0, "YYERROR %s '%s' %d", (msg), clixon_json_parsetext, _JY->jy_linenum); YYERROR;}
@ -142,8 +143,7 @@ void
clixon_json_parseerror(void *_jy,
char *s)
{
clicon_err(OE_XML, 0, "%s on line %d: %s at or before: '%s'",
_JY->jy_name,
clicon_err(OE_XML, XMLPARSE_ERRNO, "json_parse: line %d: %s at or before: '%s'",
_JY->jy_linenum ,
s,
clixon_json_parsetext);
@ -151,14 +151,14 @@ clixon_json_parseerror(void *_jy,
}
int
json_parse_init(struct clicon_json_yacc_arg *jy)
json_parse_init(clixon_json_yacc *jy)
{
// clicon_debug_init(2, NULL);
return 0;
}
int
json_parse_exit(struct clicon_json_yacc_arg *jy)
json_parse_exit(clixon_json_yacc *jy)
{
return 0;
}
@ -167,8 +167,8 @@ json_parse_exit(struct clicon_json_yacc_arg *jy)
* Split name into prefix:name (extended JSON RFC7951)
*/
static int
json_current_new(struct clicon_json_yacc_arg *jy,
char *name)
json_current_new(clixon_json_yacc *jy,
char *name)
{
int retval = -1;
cxobj *x;
@ -183,6 +183,11 @@ json_current_new(struct clicon_json_yacc_arg *jy,
goto done;
if (prefix && xml_prefix_set(x, prefix) < 0)
goto done;
/* If topmost, add to top-list created list */
if (jy->jy_current == jy->jy_xtop){
if (cxvec_append(x, &jy->jy_xvec, &jy->jy_xlen) < 0)
goto done;
}
jy->jy_current = x;
retval = 0;
done:
@ -194,7 +199,7 @@ json_current_new(struct clicon_json_yacc_arg *jy,
}
static int
json_current_pop(struct clicon_json_yacc_arg *jy)
json_current_pop(clixon_json_yacc *jy)
{
if (jy->jy_current)
jy->jy_current = xml_parent(jy->jy_current);
@ -202,7 +207,7 @@ json_current_pop(struct clicon_json_yacc_arg *jy)
}
static int
json_current_clone(struct clicon_json_yacc_arg *jy)
json_current_clone(clixon_json_yacc *jy)
{
cxobj *xn;
@ -217,8 +222,8 @@ json_current_clone(struct clicon_json_yacc_arg *jy)
}
static int
json_current_body(struct clicon_json_yacc_arg *jy,
char *value)
json_current_body(clixon_json_yacc *jy,
char *value)
{
int retval = -1;
cxobj *xn;