Re-added shared yang mounts
YANG: de-dperecated CLICON_YANG_SCHEMA_MOUNT_SHARE
This commit is contained in:
parent
f0bd103e79
commit
5ebc5a2219
5 changed files with 101 additions and 28 deletions
|
|
@ -19,7 +19,6 @@ Expected: October 2024
|
||||||
* Added yang domains for mount-point isolation
|
* Added yang domains for mount-point isolation
|
||||||
* This replaces the computation of shared yang-specs
|
* 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
|
||||||
|
|
@ -39,7 +38,6 @@ Expected: October 2024
|
||||||
* 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`
|
||||||
* Added: `CLICON_YANG_USE_ORIGINAL`
|
* Added: `CLICON_YANG_USE_ORIGINAL`
|
||||||
* 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
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1889,19 +1889,21 @@ cli_show_statistics(clixon_handle h,
|
||||||
size_t tsz;
|
size_t tsz;
|
||||||
yang_stmt *ymounts;
|
yang_stmt *ymounts;
|
||||||
yang_stmt *ydomain;
|
yang_stmt *ydomain;
|
||||||
|
yang_stmt *yspec;
|
||||||
cg_var *cv;
|
cg_var *cv;
|
||||||
cxobj *xp;
|
cxobj *xp;
|
||||||
|
char *domain;
|
||||||
char *name;
|
char *name;
|
||||||
cxobj *x;
|
cxobj *x;
|
||||||
uint64_t u64;
|
uint64_t u64;
|
||||||
char *unit;
|
char *unit;
|
||||||
int inext;
|
int inext;
|
||||||
|
int inext2;
|
||||||
|
|
||||||
if (argv == NULL || (cvec_len(argv) < 1 || cvec_len(argv) > 2)){
|
if (argv == NULL || (cvec_len(argv) < 1 || cvec_len(argv) > 2)){
|
||||||
clixon_err(OE_PLUGIN, EINVAL, "Expected arguments: [(cli|backend|all) [detail]]");
|
clixon_err(OE_PLUGIN, EINVAL, "Expected arguments: [(cli|backend|all) [detail]]");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
ydomain = clicon_dbspec_yang(h);
|
|
||||||
cv = cvec_i(argv, 0);
|
cv = cvec_i(argv, 0);
|
||||||
what = cv_string_get(cv);
|
what = cv_string_get(cv);
|
||||||
if (strcmp(what, "cli") == 0)
|
if (strcmp(what, "cli") == 0)
|
||||||
|
|
@ -1939,19 +1941,25 @@ cli_show_statistics(clixon_handle h,
|
||||||
}
|
}
|
||||||
inext = 0;
|
inext = 0;
|
||||||
while ((ydomain = yn_iter(ymounts, &inext)) != NULL) {
|
while ((ydomain = yn_iter(ymounts, &inext)) != NULL) {
|
||||||
name = yang_argument_get(ydomain);
|
domain = yang_argument_get(ydomain);
|
||||||
nr = 0; sz = 0;
|
inext2 = 0;
|
||||||
if (yang_stats(ydomain, 0, &nr, &sz) < 0)
|
while ((yspec = yn_iter(ydomain, &inext2)) != NULL) {
|
||||||
goto done;
|
name = yang_argument_get(yspec);
|
||||||
tnr = nr;
|
nr = 0; sz = 0;
|
||||||
tsz = sz;
|
if (yang_stats(ydomain, 0, &nr, &sz) < 0)
|
||||||
if (detail) {
|
goto done;
|
||||||
cligen_output(stdout, "YANG-%s-size: %" PRIu64 "\n", name, sz);
|
tnr = nr;
|
||||||
cligen_output(stdout, "YANG-%s-nr: %" PRIu64 "\n", name, nr);
|
tsz = sz;
|
||||||
}
|
if (detail) {
|
||||||
else{
|
cligen_output(stdout, "YANG-%s-%s-size: %" PRIu64 "\n", domain, name, sz);
|
||||||
translatenumber(sz, &u64, &unit);
|
cligen_output(stdout, "YANG-%s-%s-nr: %" PRIu64 "\n", domain, name, nr);
|
||||||
cligen_output(stdout, "%-25s %" PRIu64 "%-10s\n", yang_argument_get(ydomain), u64, unit);
|
}
|
||||||
|
else{
|
||||||
|
translatenumber(sz, &u64, &unit);
|
||||||
|
cprintf(cb, "%s/%s", domain, name);
|
||||||
|
cligen_output(stdout, "%-25s %" PRIu64 "%-10s\n", cbuf_get(cb), u64, unit);
|
||||||
|
cbuf_reset(cb);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (detail){
|
if (detail){
|
||||||
|
|
@ -1994,7 +2002,6 @@ cli_show_statistics(clixon_handle h,
|
||||||
translatenumber(tsz0+tsz, &u64, &unit);
|
translatenumber(tsz0+tsz, &u64, &unit);
|
||||||
cligen_output(stdout, "%-25s %" PRIu64 "%-10s\n", "Mem Total", u64, unit);
|
cligen_output(stdout, "%-25s %" PRIu64 "%-10s\n", "Mem Total", u64, unit);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if (backend) {
|
if (backend) {
|
||||||
cprintf(cb, "<rpc xmlns=\"%s\"", NETCONF_BASE_NAMESPACE);
|
cprintf(cb, "<rpc xmlns=\"%s\"", NETCONF_BASE_NAMESPACE);
|
||||||
|
|
|
||||||
|
|
@ -887,10 +887,11 @@ yspec_new1(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] tag Typically an xpath
|
* @param[in] tag Typically an xpath, saved in cvec
|
||||||
* @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
|
||||||
|
* @note yspec name used by concatenating domain and a unique number.
|
||||||
*/
|
*/
|
||||||
yang_stmt *
|
yang_stmt *
|
||||||
yspec_new_shared(clixon_handle h,
|
yspec_new_shared(clixon_handle h,
|
||||||
|
|
@ -899,13 +900,19 @@ yspec_new_shared(clixon_handle h,
|
||||||
yang_stmt *yspec0)
|
yang_stmt *yspec0)
|
||||||
{
|
{
|
||||||
yang_stmt *yspec1 = NULL;
|
yang_stmt *yspec1 = NULL;
|
||||||
|
cbuf *cb = NULL;
|
||||||
|
static int nr = 0;
|
||||||
|
|
||||||
if (yspec0 != NULL){ /* shared */
|
if (yspec0 != NULL){ /* shared */
|
||||||
yspec1 = yspec0;
|
yspec1 = yspec0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// XXX domain used as name
|
if ((cb = cbuf_new()) == NULL){
|
||||||
if ((yspec1 = yspec_new1(h, domain, domain)) == NULL)
|
clixon_err(OE_YANG, errno, "cbuf_new");
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
cprintf(cb, "%s%d", domain, nr++);
|
||||||
|
if ((yspec1 = yspec_new1(h, domain, cbuf_get(cb))) == NULL)
|
||||||
goto done;
|
goto done;
|
||||||
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);
|
||||||
|
|
@ -915,6 +922,8 @@ yspec_new_shared(clixon_handle h,
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
done:
|
done:
|
||||||
|
if (cb)
|
||||||
|
cbuf_free(cb);
|
||||||
return yspec1;
|
return yspec1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2313,10 +2322,10 @@ yang_print_cb(FILE *f,
|
||||||
if (yang_print_cbuf(cb, yn, 0, 1) < 0)
|
if (yang_print_cbuf(cb, yn, 0, 1) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
(*fn)(f, "%s", cbuf_get(cb));
|
(*fn)(f, "%s", cbuf_get(cb));
|
||||||
if (cb)
|
|
||||||
cbuf_free(cb);
|
|
||||||
retval = 0;
|
retval = 0;
|
||||||
done:
|
done:
|
||||||
|
if (cb)
|
||||||
|
cbuf_free(cb);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -703,6 +703,65 @@ yang_schema_mount_statedata(clixon_handle h,
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! 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
|
||||||
|
|
@ -755,7 +814,11 @@ yang_schema_yanglib_parse_mount(clixon_handle h,
|
||||||
if ((ydomain = ydomain_new(h, domain)) == NULL)
|
if ((ydomain = ydomain_new(h, domain)) == NULL)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
yspec0 = yang_find(ydomain, Y_SPEC, domain); // XXX name?
|
/* Optimization: find equal yspec from other mount-point */
|
||||||
|
if (clicon_option_bool(h, "CLICON_YANG_SCHEMA_MOUNT_SHARE")) {
|
||||||
|
if (yang_schema_find_share(h, xt, xyanglib, &yspec0) < 0)
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
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) */
|
||||||
|
|
|
||||||
|
|
@ -54,8 +54,6 @@ module clixon-config {
|
||||||
"Added options:
|
"Added options:
|
||||||
CLICON_YANG_DOMAIN_DIR
|
CLICON_YANG_DOMAIN_DIR
|
||||||
CLICON_YANG_USE_ORIGINAL
|
CLICON_YANG_USE_ORIGINAL
|
||||||
Deprecated:
|
|
||||||
CLICON_YANG_SCHEMA_MOUNT_SHARE
|
|
||||||
Released in Clixon 7.2";
|
Released in Clixon 7.2";
|
||||||
}
|
}
|
||||||
revision 2024-04-01 {
|
revision 2024-04-01 {
|
||||||
|
|
@ -612,9 +610,7 @@ 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