Added new DOMAIN level in YANG spec structure

This commit is contained in:
Olof hagsand 2024-10-06 09:18:24 +02:00
parent 0c8aef0291
commit f0bd103e79
17 changed files with 201 additions and 68 deletions

View file

@ -1419,20 +1419,22 @@ from_client_stats(clixon_handle h,
{
int retval = -1;
uint64_t nr;
yang_stmt *ym;
char *str;
int modules = 0;
yang_stmt *yspec;
yang_stmt *yspec0;
yang_stmt *ymounts;
yang_stmt *ydomain;
yang_stmt *yspec;
yang_stmt *ymodule;
cxobj *xt = NULL;
char *name;
char *domain;
int inext;
int inext2;
int inext3;
if ((str = xml_find_body(xe, "modules")) != NULL)
modules = strcmp(str, "true") == 0;
yspec = clicon_dbspec_yang(h);
yspec0 = clicon_dbspec_yang(h);
cprintf(cbret, "<rpc-reply xmlns=\"%s\">", NETCONF_BASE_NAMESPACE);
cprintf(cbret, "<global xmlns=\"%s\">", CLIXON_LIB_NS);
nr=0;
@ -1447,7 +1449,7 @@ from_client_stats(clixon_handle h,
goto done;
if (clixon_stats_datastore_get(h, "candidate", cbret) < 0)
goto done;
if (if_feature(yspec, "ietf-netconf", "startup"))
if (if_feature(yspec0, "ietf-netconf", "startup"))
if (clixon_stats_datastore_get(h, "startup", cbret) < 0)
goto done;
cprintf(cbret, "</datastores>");
@ -1458,19 +1460,22 @@ from_client_stats(clixon_handle h,
cprintf(cbret, "<module-sets xmlns=\"%s\">", CLIXON_LIB_NS);
inext = 0;
while ((ydomain = yn_iter(ymounts, &inext)) != NULL) {
name = yang_argument_get(ydomain);
domain = yang_argument_get(ydomain);
/* per module-set, first configuration, then main dbspec, then mountpoints */
cprintf(cbret, "<module-set>");
cprintf(cbret, "<name>%s</name>", name);
cprintf(cbret, "<name>%s</name>", domain);
if (clixon_stats_module_get(h, ydomain, cbret) < 0)
goto done;
if (modules){
inext2 = 0;
while ((ym = yn_iter(ydomain, &inext2)) != NULL) {
cprintf(cbret, "<module><name>%s</name>", yang_argument_get(ym));
if (clixon_stats_module_get(h, ym, cbret) < 0)
goto done;
cprintf(cbret, "</module>");
while ((yspec = yn_iter(ydomain, &inext2)) != NULL) {
inext3 = 0;
while ((ymodule = yn_iter(yspec, &inext3)) != NULL) {
cprintf(cbret, "<module><name>%s</name>", yang_argument_get(ymodule));
if (clixon_stats_module_get(h, ymodule, cbret) < 0)
goto done;
cprintf(cbret, "</module>");
}
}
}
cprintf(cbret, "</module-set>");

View file

@ -221,7 +221,7 @@ nacm_load_external(clixon_handle h)
clixon_err(OE_UNIX, errno, "configure file: %s", filename);
return -1;
}
if ((yspec = yspec_new(h, YANG_NACM_TOP)) == NULL)
if ((yspec = yspec_new1(h, YANG_DOMAIN_TOP, YANG_NACM_TOP)) == NULL)
goto done;
if (yang_spec_parse_module(h, "ietf-netconf-acm", NULL, yspec) < 0)
goto done;
@ -831,7 +831,7 @@ main(int argc,
}
yang_start(h);
/* Create top-level data yangs */
if ((yspec = yspec_new(h, YANG_DATA_TOP)) == NULL)
if ((yspec = yspec_new1(h, YANG_DOMAIN_TOP, YANG_DATA_TOP)) == NULL)
goto done;
/* Load backend plugins before yangs are loaded (eg extension callbacks) */