* Yang Support of submodule, include and belongs-to.

* Improved unknown handling
* Configure option `CLICON_YANG_DIR` is changed from a single directory to a path of directories
    * Note CLIXON_DATADIR (=/usr/local/share/clixon) need to be in the list
This commit is contained in:
Olof hagsand 2018-12-01 18:17:42 +01:00
parent 56da97cb5b
commit 39a5086218
47 changed files with 977 additions and 469 deletions

View file

@ -77,7 +77,6 @@
*
* Load RFC7895 yang spec, module-set-id, etc.
* @param[in] h Clicon handle
* @note CLIXON_DATADIR is hardcoded
*/
int
yang_modules_init(clicon_handle h)
@ -94,7 +93,7 @@ yang_modules_init(clicon_handle h)
goto done;
}
/* Ensure revision exists is set */
if (yang_spec_parse_module(h, "ietf-yang-library", CLIXON_DATADIR, NULL, yspec, NULL)< 0)
if (yang_spec_parse_module(h, "ietf-yang-library", NULL, yspec, NULL)< 0)
goto done;
/* Find revision */
if (yang_modules_revision(h) == NULL){
@ -121,7 +120,8 @@ yang_modules_revision(clicon_handle h)
char *revision = NULL;
yspec = clicon_dbspec_yang(h);
if ((ymod = yang_find((yang_node*)yspec, Y_MODULE, "ietf-yang-library")) != NULL){
if ((ymod = yang_find((yang_node*)yspec, Y_MODULE, "ietf-yang-library")) != NULL ||
(ymod = yang_find((yang_node*)yspec, Y_SUBMODULE, "ietf-yang-library")) != NULL){
if ((yrev = yang_find((yang_node*)ymod, Y_REVISION, NULL)) != NULL){
revision = yrev->ys_argument;
}
@ -172,7 +172,8 @@ yang_modules_state_get(clicon_handle h,
char *module = "ietf-yang-library";
module_set_id = clicon_option_str(h, "CLICON_MODULE_SET_ID");
if ((ylib = yang_find((yang_node*)yspec, Y_MODULE, module)) == NULL){
if ((ylib = yang_find((yang_node*)yspec, Y_MODULE, module)) == NULL &&
(ylib = yang_find((yang_node*)yspec, Y_SUBMODULE, module)) == NULL){
clicon_err(OE_YANG, 0, "%s not found", module);
goto done;
}
@ -189,7 +190,8 @@ yang_modules_state_get(clicon_handle h,
ymod = NULL;
while ((ymod = yn_each((yang_node*)yspec, ymod)) != NULL) {
if (ymod->ys_keyword != Y_MODULE)
if (ymod->ys_keyword != Y_MODULE &&
ymod->ys_keyword != Y_SUBMODULE)
continue;
cprintf(cb,"<module>");
cprintf(cb,"<name>%s</name>", ymod->ys_argument);