Added new DOMAIN level in YANG spec structure
This commit is contained in:
parent
0c8aef0291
commit
f0bd103e79
17 changed files with 201 additions and 68 deletions
|
|
@ -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>");
|
||||
|
|
|
|||
|
|
@ -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) */
|
||||
|
|
|
|||
|
|
@ -270,7 +270,8 @@ yang2cli_print_alias(cbuf *cb,
|
|||
* @param[out] cb CLIgen buf
|
||||
* @param[in] delim Delimiter string that may not occur in any of the elements (except the last)
|
||||
* @param[in] tag Context-specific tag, eg "grouping"
|
||||
* @param[in] domain Domain name (= yspec name)
|
||||
* @param[in] domain Domain name
|
||||
* @param[in] spec yspec name
|
||||
* @param[in] module Name of module (in domain context)
|
||||
* @param[in] id Top-level nodeid (schema-id)
|
||||
* @retval 0 Ok
|
||||
|
|
@ -281,15 +282,17 @@ yang2cli_cmd_encode(cbuf *cb,
|
|||
const char *delim,
|
||||
char *tag,
|
||||
char *domain,
|
||||
char *spec,
|
||||
char *module,
|
||||
char *id)
|
||||
{
|
||||
if (tag == NULL || domain == NULL || module == NULL || id == NULL){
|
||||
if (tag == NULL || domain == NULL || spec == NULL || module == NULL || id == NULL){
|
||||
clixon_err(OE_YANG, EINVAL, "tag, domain, module or id is NULL");
|
||||
return -1;
|
||||
}
|
||||
cprintf(cb, "%s", tag);
|
||||
cprintf(cb, "%s%s", delim, domain);
|
||||
cprintf(cb, "%s%s", delim, spec);
|
||||
cprintf(cb, "%s%s", delim, module);
|
||||
cprintf(cb, "%s%s", delim, id);
|
||||
return 0;
|
||||
|
|
@ -300,7 +303,8 @@ yang2cli_cmd_encode(cbuf *cb,
|
|||
* @param[in] cmd CLIgen cmd string
|
||||
* @param[in] delim Delimiter string that may not occur in any of the elements (except the last)
|
||||
* @param[out] tag Context-specific tag, eg "grouping"
|
||||
* @param[out] domain Domain name (= yspec name)
|
||||
* @param[out] domain Domain name
|
||||
* @param[out] spec Yspec name
|
||||
* @param[out] module Name of module (in domain context)
|
||||
* @param[out] id Top-level nodeid (schema-id)
|
||||
* @retval 0 Ok
|
||||
|
|
@ -311,6 +315,7 @@ yang2cli_cmd_decode(char *cmd,
|
|||
const char *delim,
|
||||
char **tag,
|
||||
char **domain,
|
||||
char **spec,
|
||||
char **modname,
|
||||
char **id)
|
||||
{
|
||||
|
|
@ -339,6 +344,13 @@ yang2cli_cmd_decode(char *cmd,
|
|||
goto ok;
|
||||
*s2 = '\0';
|
||||
s2 += strlen(delim);
|
||||
if (spec)
|
||||
*spec = s2;
|
||||
s1 = s2;
|
||||
if ((s2 = strstr(s1, delim)) == NULL)
|
||||
goto ok;
|
||||
*s2 = '\0';
|
||||
s2 += strlen(delim);
|
||||
if (modname)
|
||||
*modname = s2;
|
||||
s1 = s2;
|
||||
|
|
@ -1307,6 +1319,7 @@ yang2cli_uses(clixon_handle h,
|
|||
if ((ns = yang_find_mynamespace(ygrouping)) == NULL)
|
||||
goto done;
|
||||
if (yang2cli_cmd_encode(cbtree, AUTOCLI_CMD_DELIM, "grouping",
|
||||
yang_argument_get(ys_domain(ygrouping)),
|
||||
yang_argument_get(ys_spec(ygrouping)),
|
||||
yang_argument_get(ys_module(ygrouping)),
|
||||
id) < 0)
|
||||
|
|
@ -1897,11 +1910,13 @@ yang2cli_grouping_wrap(cligen_handle ch,
|
|||
int retval = -1;
|
||||
clixon_handle h;
|
||||
yang_stmt *ymnt;
|
||||
yang_stmt *ydomain;
|
||||
yang_stmt *yspec;
|
||||
yang_stmt *ymod;
|
||||
yang_stmt *ygrouping;
|
||||
char *tag = NULL;
|
||||
char *domain = NULL;
|
||||
char *spec = NULL;
|
||||
char *modname = NULL;
|
||||
char *grouping = NULL;
|
||||
int ret;
|
||||
|
|
@ -1912,7 +1927,7 @@ yang2cli_grouping_wrap(cligen_handle ch,
|
|||
}
|
||||
h = cligen_userhandle(ch);
|
||||
yspec = clicon_dbspec_yang(h);
|
||||
if (yang2cli_cmd_decode(name, AUTOCLI_CMD_DELIM, &tag, &domain, &modname, &grouping) < 0)
|
||||
if (yang2cli_cmd_decode(name, AUTOCLI_CMD_DELIM, &tag, &domain, &spec, &modname, &grouping) < 0)
|
||||
goto done;
|
||||
if (tag == NULL || strcmp(tag, "grouping") != 0)
|
||||
goto ok;
|
||||
|
|
@ -1920,13 +1935,17 @@ yang2cli_grouping_wrap(cligen_handle ch,
|
|||
*namep = strdup(name);
|
||||
goto ok;
|
||||
}
|
||||
if (domain == NULL || modname == NULL || grouping == NULL){
|
||||
if (domain == NULL || spec == NULL || modname == NULL || grouping == NULL){
|
||||
clixon_err(OE_YANG, 0, "yang2cli cmd label invalid format");
|
||||
goto done;
|
||||
}
|
||||
ymnt = clixon_yang_mounts_get(h);
|
||||
if ((yspec = yang_find(ymnt, Y_SPEC, domain)) == NULL){
|
||||
clixon_err(OE_YANG, 0, "yang2cli cmd label no yspec %s", domain);
|
||||
if ((ydomain = yang_find(ymnt, Y_DOMAIN, domain)) == NULL){
|
||||
clixon_err(OE_YANG, 0, "yang2cli cmd label no ydomain %s", domain);
|
||||
goto done;
|
||||
}
|
||||
if ((yspec = yang_find(ydomain, Y_SPEC, spec)) == NULL){
|
||||
clixon_err(OE_YANG, 0, "yang2cli cmd label no yspec %s", spec);
|
||||
goto done;
|
||||
}
|
||||
if ((ymod = yang_find(yspec, 0, modname)) == NULL){
|
||||
|
|
|
|||
|
|
@ -63,8 +63,8 @@
|
|||
/*
|
||||
* Prototypes
|
||||
*/
|
||||
int yang2cli_cmd_encode(cbuf *cb, const char *delim, char *tag, char *domain, char *modname, char *id);
|
||||
int yang2cli_cmd_decode(char *cmd, const char *delim, char **tag, char **domain, char **modname, char **id);
|
||||
int yang2cli_cmd_encode(cbuf *cb, const char *delim, char *tag, char *domain, char *spec, char *modname, char *id);
|
||||
int yang2cli_cmd_decode(char *cmd, const char *delim, char **tag, char **domain, char **spec, char **modname, char **id);
|
||||
int yang2cli_grouping(clixon_handle h, yang_stmt *ys, char *treename);
|
||||
int yang2cli_yspec(clixon_handle h, yang_stmt *yspec, char *treename);
|
||||
int yang2cli_grouping_wrap(cligen_handle ch, char *name, cvec *cvt, void *arg, char **namep);
|
||||
|
|
|
|||
|
|
@ -847,7 +847,7 @@ main(int argc,
|
|||
xml_nsctx_namespace_netconf_default(h);
|
||||
|
||||
/* Create top-level and store as option */
|
||||
if ((yspec = yspec_new(h, YANG_DATA_TOP)) == NULL)
|
||||
if ((yspec = yspec_new1(h, YANG_DOMAIN_TOP, YANG_DATA_TOP)) == NULL)
|
||||
goto done;
|
||||
|
||||
/* Load Yang modules
|
||||
|
|
|
|||
|
|
@ -871,7 +871,7 @@ main(int argc,
|
|||
if (yang_metadata_init(h) < 0)
|
||||
goto done;
|
||||
/* Create top-level yang spec and store as option */
|
||||
if ((yspec = yspec_new(h, YANG_DATA_TOP)) == NULL)
|
||||
if ((yspec = yspec_new1(h, YANG_DOMAIN_TOP, YANG_DATA_TOP)) == NULL)
|
||||
goto done;
|
||||
|
||||
/* Load netconf plugins before yangs are loaded (eg extension callbacks) */
|
||||
|
|
|
|||
|
|
@ -498,7 +498,7 @@ main(int argc,
|
|||
goto done;
|
||||
|
||||
/* Create top-level yang spec and store as option */
|
||||
if ((yspec = yspec_new(h, YANG_DATA_TOP)) == NULL)
|
||||
if ((yspec = yspec_new1(h, YANG_DOMAIN_TOP, YANG_DATA_TOP)) == NULL)
|
||||
goto done;
|
||||
|
||||
/* Initialize plugin module by creating a handle holding plugin and callback lists */
|
||||
|
|
|
|||
|
|
@ -967,7 +967,7 @@ restconf_clixon_init(clixon_handle h,
|
|||
if (yang_metadata_init(h) < 0)
|
||||
goto done;
|
||||
/* Create top-level yang spec and store as option */
|
||||
if ((yspec = yspec_new(h, YANG_DATA_TOP)) == NULL)
|
||||
if ((yspec = yspec_new1(h, YANG_DOMAIN_TOP, YANG_DATA_TOP)) == NULL)
|
||||
goto done;
|
||||
|
||||
/* Load restconf plugins before yangs are loaded (eg extension callbacks) */
|
||||
|
|
|
|||
|
|
@ -519,7 +519,7 @@ main(int argc,
|
|||
goto done;
|
||||
|
||||
/* Create top-level yang spec and store as option */
|
||||
if ((yspec = yspec_new(h, YANG_DATA_TOP)) == NULL)
|
||||
if ((yspec = yspec_new1(h, YANG_DOMAIN_TOP, YANG_DATA_TOP)) == NULL)
|
||||
goto done;
|
||||
|
||||
/* Load Yang modules
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue