Very large commit for upcoming 4.4 release
Major New features
* New and updated search functions using xpath, api-path and instance-id
* New search functions using api-path and instance_id:
* C search functions: `clixon_find_instance_id()` and `clixon_find_api_path()`
* Binary search optimization in lists for indexed leafs in all three formats.
* This improves search performance to O(logN) which is drastical improvements for large lists.
* You can also register explicit indexes for making binary search (not only list keys)
* For more info, see docs at [paths](https://clixon-docs.readthedocs.io/en/latest/paths.html) and
[search](https://clixon-docs.readthedocs.io/en/latest/xml.html#searching-in-xml)
API changes on existing features (you may need to change your code)
* On failed validation of leafrefs, error message changed from: `No such leaf` to `No leaf <name> matching path <path>`.
* CLI Error message (clicon_rpc_generate_error()) changed when backend returns netconf error to be more descriptive:
* Original: `Config error: Validate failed. Edit and try again or discard changes: Invalid argument`
* New (example): `Netconf error: application operation-failed Identityref validation failed, undefined not derived from acl-base . Validate failed. Edit and try again or discard changes"
Minor changes
* Test framework
* Added `-- -S <file>` command-line to main example to be able to return any state to main example.
* Added `test/cicd` test scripts for running on a set of other hosts
* C-code restructuring
* clixon_yang.c partitioned and moved code into clixon_yang_parse_lib.c and clixon_yang_module.c and move back some code from clixon_yang_type.c.
* partly to reduce size, but most important to limit code that accesses internal yang structures, only clixon_yang.c does this now.
This commit is contained in:
parent
e8ae628d06
commit
19e21be0bc
132 changed files with 6241 additions and 2332 deletions
|
|
@ -2,7 +2,8 @@
|
|||
*
|
||||
***** BEGIN LICENSE BLOCK *****
|
||||
|
||||
Copyright (C) 2009-2019 Olof Hagsand and Benny Holmgren
|
||||
Copyright (C) 2009-2016 Olof Hagsand and Benny Holmgren
|
||||
Copyright (C) 2017-2020 Olof Hagsand
|
||||
|
||||
This file is part of CLIXON.
|
||||
|
||||
|
|
@ -111,7 +112,6 @@ clixon_plugin_statedata(clicon_handle h,
|
|||
{
|
||||
int retval = -1;
|
||||
int ret;
|
||||
cxobj *xerr = NULL;
|
||||
cxobj *x = NULL;
|
||||
clixon_plugin *cp = NULL;
|
||||
plgstatedata_t *fn; /* Plugin statedata fn */
|
||||
|
|
@ -124,46 +124,17 @@ clixon_plugin_statedata(clicon_handle h,
|
|||
goto done;
|
||||
if (fn(h, nsc, xpath, x) < 0)
|
||||
goto fail; /* Dont quit here on user callbacks */
|
||||
if (xml_apply(x, CX_ELMNT, xml_spec_populate, yspec) < 0)
|
||||
goto done;
|
||||
/* Check XML from state callback by validating it. return internal
|
||||
* error with error cause
|
||||
*/
|
||||
if ((ret = xml_yang_validate_all_top(h, x, &xerr)) < 0)
|
||||
goto done;
|
||||
if (ret > 0 && (ret = xml_yang_validate_add(h, x, &xerr)) < 0)
|
||||
goto done;
|
||||
if (ret == 0){
|
||||
cxobj *xe;
|
||||
cxobj *xb;
|
||||
|
||||
if ((xe = xpath_first(xerr, NULL, "//error-tag")) != NULL &&
|
||||
(xb = xml_body_get(xe))){
|
||||
if (xml_value_set(xb, "operation-failed") < 0)
|
||||
goto done;
|
||||
}
|
||||
if ((xe = xpath_first(xerr, NULL, "//error-message")) != NULL &&
|
||||
(xb = xml_body_get(xe))){
|
||||
if (xml_value_append(xb, " Internal error, state callback returned invalid XML") < 0)
|
||||
goto done;
|
||||
}
|
||||
if (*xret){
|
||||
xml_free(*xret);
|
||||
*xret = NULL;
|
||||
}
|
||||
*xret = xerr;
|
||||
xerr = NULL;
|
||||
goto fail;
|
||||
}
|
||||
#if 1
|
||||
if (debug){
|
||||
cbuf *ccc=cbuf_new();
|
||||
if (clicon_xml2cbuf(ccc, x, 0, 0, -1) < 0)
|
||||
goto done;
|
||||
clicon_debug(1, "%s MERGE: %s", __FUNCTION__, cbuf_get(ccc));
|
||||
clicon_debug(1, "%s STATE: %s", __FUNCTION__, cbuf_get(ccc));
|
||||
cbuf_free(ccc);
|
||||
}
|
||||
#endif
|
||||
if (xml_apply(x, CX_ELMNT, xml_spec_populate, yspec) < 0)
|
||||
goto done;
|
||||
if ((ret = netconf_trymerge(x, yspec, xret)) < 0)
|
||||
goto done;
|
||||
if (ret == 0)
|
||||
|
|
@ -172,15 +143,13 @@ clixon_plugin_statedata(clicon_handle h,
|
|||
xml_free(x);
|
||||
x = NULL;
|
||||
}
|
||||
}
|
||||
} /* while plugin */
|
||||
retval = 1;
|
||||
done:
|
||||
if (cberr)
|
||||
cbuf_free(cberr);
|
||||
if (x)
|
||||
xml_free(x);
|
||||
if (xerr)
|
||||
xml_free(xerr);
|
||||
return retval;
|
||||
fail:
|
||||
retval = 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue