Replace shared yang with yang domains
This commit is contained in:
parent
fba587bdf6
commit
212be7ad57
4 changed files with 16 additions and 68 deletions
|
|
@ -17,7 +17,9 @@ Expected: October 2024
|
||||||
### Features
|
### Features
|
||||||
|
|
||||||
* Added yang domains for mount-point isolation
|
* Added yang domains for mount-point isolation
|
||||||
|
* This replaces the computation of shared yang-specs
|
||||||
* New option: `CLICON_YANG_DOMAIN_DIR`
|
* New option: `CLICON_YANG_DOMAIN_DIR`
|
||||||
|
* Deprecated: `CLICON_YANG_SCHEMA_MOUNT_SHARE`
|
||||||
* Restconf: Support for list of media in Accept header
|
* Restconf: Support for list of media in Accept header
|
||||||
* Refactoring of schema mount-points
|
* Refactoring of schema mount-points
|
||||||
* Add new top-level `Y_MOUNTS` and add top-level yangs and mountpoints in yspecs
|
* Add new top-level `Y_MOUNTS` and add top-level yangs and mountpoints in yspecs
|
||||||
|
|
@ -32,6 +34,7 @@ Expected: October 2024
|
||||||
* List pagination: Added where, sort-by and direction parameter for configured data
|
* List pagination: Added where, sort-by and direction parameter for configured data
|
||||||
* New `clixon-config@2024-08-01.yang` revision
|
* New `clixon-config@2024-08-01.yang` revision
|
||||||
- Added: CLICON_YANG_DOMAIN_DIR
|
- Added: CLICON_YANG_DOMAIN_DIR
|
||||||
|
- Deprecated: `CLICON_YANG_SCHEMA_MOUNT_SHARE`
|
||||||
* New `clixon-lib@2024-08-01.yang` revision
|
* New `clixon-lib@2024-08-01.yang` revision
|
||||||
- Added: list-pagination-partial-state extension
|
- Added: list-pagination-partial-state extension
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -856,21 +856,20 @@ yspec_new(clixon_handle h,
|
||||||
/*! Create or add a shared yspec
|
/*! Create or add a shared yspec
|
||||||
*
|
*
|
||||||
* @param[in] h Clixon handle
|
* @param[in] h Clixon handle
|
||||||
* @param[in] name Typically an xpath
|
* @param[in] tag Typically an xpath
|
||||||
* @param[in] yspec0 Input NULL if no previous shared exist, otherwise a shared yspec but new name
|
* @param[in] yspec0 Input NULL if no previous shared exist, otherwise a shared yspec but new name
|
||||||
* @retval yspec1 New or (previously shared)
|
* @retval yspec1 New or (previously shared)
|
||||||
* @retval NULL Error
|
* @retval NULL Error
|
||||||
*/
|
*/
|
||||||
yang_stmt *
|
yang_stmt *
|
||||||
yspec_new_shared(clixon_handle h,
|
yspec_new_shared(clixon_handle h,
|
||||||
char *name,
|
char *tag,
|
||||||
char *domain,
|
char *domain,
|
||||||
yang_stmt *yspec0)
|
yang_stmt *yspec0)
|
||||||
{
|
{
|
||||||
yang_stmt *yspec1 = NULL;
|
yang_stmt *yspec1 = NULL;
|
||||||
|
|
||||||
if (yspec0 != NULL){ /* shared */
|
if (yspec0 != NULL){ /* shared */
|
||||||
assert(clicon_option_bool(h, "CLICON_YANG_SCHEMA_MOUNT_SHARE") != 0);
|
|
||||||
yspec1 = yspec0;
|
yspec1 = yspec0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
@ -879,7 +878,7 @@ yspec_new_shared(clixon_handle h,
|
||||||
yang_flag_set(yspec1, YANG_FLAG_SPEC_MOUNT);
|
yang_flag_set(yspec1, YANG_FLAG_SPEC_MOUNT);
|
||||||
clixon_debug(CLIXON_DBG_YANG, "new yang-spec: %p", yspec1);
|
clixon_debug(CLIXON_DBG_YANG, "new yang-spec: %p", yspec1);
|
||||||
}
|
}
|
||||||
if (yang_cvec_add(yspec1, CGV_STRING, name) < 0){
|
if (yang_cvec_add(yspec1, CGV_STRING, tag) < 0){
|
||||||
yspec1 = NULL;
|
yspec1 = NULL;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -789,65 +789,6 @@ yang_schema_mount_statistics(clixon_handle h,
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Given xml mount-point and yanglib, find existing yspec
|
|
||||||
*
|
|
||||||
* Get and loop through all XML from xt mount-points.
|
|
||||||
* Get xyanglib and if equal to xt, find and return yspec
|
|
||||||
* @param[in] h Clixon handle
|
|
||||||
* @param[in] xt XML tree node
|
|
||||||
* @param[in] xyanglib yanglib in XML
|
|
||||||
* @param[out] yspecp Yang spec
|
|
||||||
* @retval 0 OK
|
|
||||||
* @retval -1 Error
|
|
||||||
*/
|
|
||||||
static int
|
|
||||||
yang_schema_find_share(clixon_handle h,
|
|
||||||
cxobj *xt,
|
|
||||||
cxobj *xyanglib,
|
|
||||||
yang_stmt **yspecp)
|
|
||||||
{
|
|
||||||
int retval = -1;
|
|
||||||
cvec *cvv = NULL;
|
|
||||||
cg_var *cv;
|
|
||||||
cxobj *xroot;
|
|
||||||
cxobj *xmnt;
|
|
||||||
cxobj *xylib;
|
|
||||||
int config = 1;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
xroot = xml_root(xt);
|
|
||||||
/* Get all XML mtpoints */
|
|
||||||
if (yang_mount_xtop2xmnt(xroot, &cvv) < 0)
|
|
||||||
goto done;
|
|
||||||
/* Loop through XML mount-points */
|
|
||||||
cv = NULL;
|
|
||||||
while ((cv = cvec_each(cvv, cv)) != NULL) {
|
|
||||||
xmnt = cv_void_get(cv);
|
|
||||||
if (xmnt == xt)
|
|
||||||
continue;
|
|
||||||
xylib = NULL;
|
|
||||||
/* Get xyanglib */
|
|
||||||
if (clixon_plugin_yang_mount_all(h, xmnt, &config, NULL, &xylib) < 0)
|
|
||||||
goto done;
|
|
||||||
if (xylib == NULL)
|
|
||||||
continue;
|
|
||||||
/* Check if equal */
|
|
||||||
if (xml_tree_equal(xyanglib, xylib) == 1)
|
|
||||||
continue;
|
|
||||||
/* Find and return yspec */
|
|
||||||
*yspecp = NULL;
|
|
||||||
if ((ret = xml_yang_mount_get(h, xmnt, NULL, NULL, yspecp)) < 0)
|
|
||||||
goto done;
|
|
||||||
if (ret == 1 && *yspecp != NULL)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
retval = 0;
|
|
||||||
done:
|
|
||||||
if (cvv)
|
|
||||||
cvec_free(cvv);
|
|
||||||
return retval;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*! Get yanglib from user plugin callback, parse it and mount it
|
/*! Get yanglib from user plugin callback, parse it and mount it
|
||||||
*
|
*
|
||||||
* Optionally check for shared yspec
|
* Optionally check for shared yspec
|
||||||
|
|
@ -864,6 +805,7 @@ yang_schema_yanglib_parse_mount(clixon_handle h,
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
cxobj *xyanglib = NULL;
|
cxobj *xyanglib = NULL;
|
||||||
cxobj *xb;
|
cxobj *xb;
|
||||||
|
yang_stmt *ymounts;
|
||||||
yang_stmt *yspec0 = NULL;
|
yang_stmt *yspec0 = NULL;
|
||||||
yang_stmt *yspec1 = NULL;
|
yang_stmt *yspec1 = NULL;
|
||||||
char *xpath = NULL;
|
char *xpath = NULL;
|
||||||
|
|
@ -890,11 +832,11 @@ yang_schema_yanglib_parse_mount(clixon_handle h,
|
||||||
clixon_err(OE_YANG, 0, "Mapping xmnt to ymnt and xpath");
|
clixon_err(OE_YANG, 0, "Mapping xmnt to ymnt and xpath");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
/* Optimization: find equal yspec from other mount-point */
|
if ((ymounts = clixon_yang_mounts_get(h)) == NULL){
|
||||||
if (clicon_option_bool(h, "CLICON_YANG_SCHEMA_MOUNT_SHARE")) {
|
clixon_err(OE_YANG, ENOENT, "Top-level yang mounts not found");
|
||||||
if (yang_schema_find_share(h, xt, xyanglib, &yspec0) < 0)
|
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
yspec0 = yang_find(ymounts, Y_SPEC, domain);
|
||||||
if ((yspec1 = yspec_new_shared(h, xpath, domain, yspec0)) < 0)
|
if ((yspec1 = yspec_new_shared(h, xpath, domain, yspec0)) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
/* Either yspec0 = NULL and yspec1 is new, or yspec0 == yspec1 != NULL (shared) */
|
/* Either yspec0 = NULL and yspec1 is new, or yspec0 == yspec1 != NULL (shared) */
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,8 @@ module clixon-config {
|
||||||
description
|
description
|
||||||
"Added options:
|
"Added options:
|
||||||
CLICON_YANG_DOMAIN_DIR
|
CLICON_YANG_DOMAIN_DIR
|
||||||
|
Deprecated:
|
||||||
|
CLICON_YANG_SCHEMA_MOUNT_SHARE
|
||||||
Released in Clixon 7.2";
|
Released in Clixon 7.2";
|
||||||
}
|
}
|
||||||
revision 2024-04-01 {
|
revision 2024-04-01 {
|
||||||
|
|
@ -609,7 +611,9 @@ module clixon-config {
|
||||||
(yangmnt:mount-point is on same node).
|
(yangmnt:mount-point is on same node).
|
||||||
A comparison is made between yang modules and revision and must match exactly.
|
A comparison is made between yang modules and revision and must match exactly.
|
||||||
If so, a new yang-spec is not created, instead the other is used.
|
If so, a new yang-spec is not created, instead the other is used.
|
||||||
Only if CLICON_YANG_SCHEMA_MOUNT is enabled";
|
Only if CLICON_YANG_SCHEMA_MOUNT is enabled
|
||||||
|
Deprecated, replaced by yang domain";
|
||||||
|
status deprecated;
|
||||||
default false;
|
default false;
|
||||||
}
|
}
|
||||||
leaf CLICON_YANG_AUGMENT_ACCEPT_BROKEN {
|
leaf CLICON_YANG_AUGMENT_ACCEPT_BROKEN {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue