* Add multiple yang support also for obsolete versions
* This means that files and datastores supporting modstate also looks for deleted or updated yang modules. * A stricter binding which gives error if loading outdated YANG file does not exist. * Stricter yang checks: you cannot do get-config on datastores that have obsolete YANG * Added xerr output parameter to `xmldb_get0()`
This commit is contained in:
parent
d542cd5530
commit
8469a0962e
20 changed files with 328 additions and 118 deletions
|
|
@ -419,17 +419,24 @@ client_get_config_only(clicon_handle h,
|
|||
cxobj *xret = NULL;
|
||||
cxobj *xnacm = NULL;
|
||||
cxobj **xvec = NULL;
|
||||
cxobj *xerr = NULL;
|
||||
size_t xlen;
|
||||
int ret;
|
||||
|
||||
/* Note xret can be pruned by nacm below (and change name),
|
||||
* so zero-copy cant be used
|
||||
* Also, must use external namespace context here due to <filter stmt
|
||||
*/
|
||||
if (xmldb_get0(h, db, YB_MODULE, nsc, xpath, 1, &xret, NULL) < 0) {
|
||||
if ((ret = xmldb_get0(h, db, YB_MODULE, nsc, xpath, 1, &xret, NULL, &xerr)) < 0) {
|
||||
if (netconf_operation_failed(cbret, "application", "read registry")< 0)
|
||||
goto done;
|
||||
goto ok;
|
||||
}
|
||||
if (ret == 0){
|
||||
if (clicon_xml2cbuf(cbret, xerr, 0, 0, -1) < 0)
|
||||
goto done;
|
||||
goto ok;
|
||||
}
|
||||
/* Pre-NACM access step */
|
||||
xnacm = clicon_nacm_cache(h);
|
||||
if (xnacm != NULL){ /* Do NACM validation */
|
||||
|
|
@ -452,6 +459,8 @@ client_get_config_only(clicon_handle h,
|
|||
ok:
|
||||
retval = 0;
|
||||
done:
|
||||
if (xerr)
|
||||
xml_free(xerr);
|
||||
if (xvec)
|
||||
free(xvec);
|
||||
if (xret)
|
||||
|
|
@ -1120,14 +1129,14 @@ from_client_get(clicon_handle h,
|
|||
* Also, must use external namespace context here due to <filter> stmt
|
||||
*/
|
||||
if (clicon_option_bool(h, "CLICON_VALIDATE_STATE_XML")){
|
||||
if (xmldb_get0(h, "running", YB_MODULE, nsc, NULL, 1, &xret, NULL) < 0) {
|
||||
if (xmldb_get0(h, "running", YB_MODULE, nsc, NULL, 1, &xret, NULL, NULL) < 0) {
|
||||
if (netconf_operation_failed(cbret, "application", "read registry")< 0)
|
||||
goto done;
|
||||
goto ok;
|
||||
}
|
||||
}
|
||||
else{
|
||||
if (xmldb_get0(h, "running", YB_MODULE, nsc, xpath, 1, &xret, NULL) < 0) {
|
||||
if (xmldb_get0(h, "running", YB_MODULE, nsc, xpath, 1, &xret, NULL, NULL) < 0) {
|
||||
if (netconf_operation_failed(cbret, "application", "read registry")< 0)
|
||||
goto done;
|
||||
goto ok;
|
||||
|
|
|
|||
|
|
@ -203,8 +203,9 @@ startup_common(clicon_handle h,
|
|||
/* Get the startup datastore WITHOUT binding to YANG, sorting and default setting.
|
||||
* It is done below, later in this function
|
||||
*/
|
||||
if (xmldb_get0(h, db, YB_NONE, NULL, "/", 0, &xt, msdiff) < 0)
|
||||
if ((ret = xmldb_get0(h, db, YB_NONE, NULL, "/", 0, &xt, msdiff, NULL)) < 0)
|
||||
goto done;
|
||||
/* ret should not be 0 */
|
||||
if ((yspec = clicon_dbspec_yang(h)) == NULL){
|
||||
clicon_err(OE_YANG, 0, "Yang spec not set");
|
||||
goto done;
|
||||
|
|
@ -484,7 +485,7 @@ from_validate_common(clicon_handle h,
|
|||
goto done;
|
||||
}
|
||||
/* This is the state we are going to */
|
||||
if (xmldb_get0(h, candidate, YB_MODULE, NULL, "/", 0, &td->td_target, NULL) < 0)
|
||||
if (xmldb_get0(h, candidate, YB_MODULE, NULL, "/", 0, &td->td_target, NULL, NULL) < 0)
|
||||
goto done;
|
||||
|
||||
/* Clear flags xpath for get */
|
||||
|
|
@ -492,7 +493,7 @@ from_validate_common(clicon_handle h,
|
|||
(void*)(XML_FLAG_MARK|XML_FLAG_CHANGE));
|
||||
/* 2. Parse xml trees
|
||||
* This is the state we are going from */
|
||||
if (xmldb_get0(h, "running", YB_MODULE, NULL, "/", 0, &td->td_src, NULL) < 0)
|
||||
if (xmldb_get0(h, "running", YB_MODULE, NULL, "/", 0, &td->td_src, NULL, NULL) < 0)
|
||||
goto done;
|
||||
/* Clear flags xpath for get */
|
||||
xml_apply0(td->td_src, CX_ELMNT, (xml_applyfn_t*)xml_flag_reset,
|
||||
|
|
@ -884,7 +885,7 @@ from_client_restart_one(clicon_handle h,
|
|||
if ((td = transaction_new()) == NULL)
|
||||
goto done;
|
||||
/* This is the state we are going to */
|
||||
if (xmldb_get0(h, "running", YB_MODULE, NULL, "/", 0, &td->td_target, NULL) < 0)
|
||||
if (xmldb_get0(h, "running", YB_MODULE, NULL, "/", 0, &td->td_target, NULL, NULL) < 0)
|
||||
goto done;
|
||||
if ((ret = xml_yang_validate_all_top(h, td->td_target, &xerr)) < 0)
|
||||
goto done;
|
||||
|
|
@ -894,7 +895,7 @@ from_client_restart_one(clicon_handle h,
|
|||
goto fail;
|
||||
}
|
||||
/* This is the state we are going from */
|
||||
if (xmldb_get0(h, db, YB_MODULE, NULL, "/", 0, &td->td_src, NULL) < 0)
|
||||
if (xmldb_get0(h, db, YB_MODULE, NULL, "/", 0, &td->td_src, NULL, NULL) < 0)
|
||||
goto done;
|
||||
|
||||
/* 3. Compute differences */
|
||||
|
|
|
|||
|
|
@ -946,6 +946,8 @@ main(int argc,
|
|||
if (startup_failsafe(h) < 0){
|
||||
goto done;
|
||||
}
|
||||
status = STARTUP_OK;
|
||||
cbuf_reset(cbret); /* cbret contains error info */
|
||||
}
|
||||
|
||||
/* Initiate the shared candidate. */
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ db_merge(clicon_handle h,
|
|||
cxobj *xt = NULL;
|
||||
|
||||
/* Get data as xml from db1 */
|
||||
if (xmldb_get0(h, (char*)db1, YB_MODULE, NULL, NULL, 0, &xt, NULL) < 0)
|
||||
if (xmldb_get0(h, (char*)db1, YB_MODULE, NULL, NULL, 0, &xt, NULL, NULL) < 0)
|
||||
goto done;
|
||||
xml_name_set(xt, NETCONF_INPUT_CONFIG);
|
||||
/* Merge xml into db2. Without commit */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue