diff --git a/apps/cli/cli_auto.c b/apps/cli/cli_auto.c index 7b0cce6b..79fea435 100644 --- a/apps/cli/cli_auto.c +++ b/apps/cli/cli_auto.c @@ -353,7 +353,7 @@ cli_xml2cli(cxobj *xn, yang_keyword_get(ys) == Y_LEAF_LIST){ if (prepend) (*fn)(stdout, "%s", prepend); - if (gt == GT_ALL || gt == GT_VARS || gt == GT_HIDE) + if (gt == GT_ALL || gt == GT_VARS || gt == GT_HIDE || gt == GT_OC_COMPRESS) (*fn)(stdout, "%s ", xml_name(xn)); if ((body = xml_body(xn)) != NULL){ if (index(body, ' ')) diff --git a/apps/cli/cli_generate.c b/apps/cli/cli_generate.c index a2cd6cfb..bf0827a9 100644 --- a/apps/cli/cli_generate.c +++ b/apps/cli/cli_generate.c @@ -763,7 +763,7 @@ yang2cli_leaf(clicon_handle h, /* Look for autocli-op defined in clixon-lib.yang */ if (yang_extension_value(ys, "autocli-op", CLIXON_LIB_NS, &opext) < 0) goto done; - if (gt == GT_VARS|| gt == GT_ALL || gt == GT_HIDE){ + if (gt == GT_VARS || gt == GT_ALL || gt == GT_HIDE || gt == GT_OC_COMPRESS){ cprintf(cb, "%s", yang_argument_get(ys)); yang2cli_helptext(cb, helptext); cprintf(cb, " "); @@ -832,13 +832,24 @@ yang2cli_container(clicon_handle h, char *helptext = NULL; char *s; int hide = 0; + int hide_oc = 0; char *opext = NULL; + yang_stmt *ymod = NULL; + char **name; + + if (ys_real_module(ys, &ymod) < 0) + goto done; + if (yang_extension_value(ymod, "openconfig-extensions", "http://openconfig.net/yang/openconfig-ext", &opext) == 0) { + if (strcmp(yang_argument_get(ys), "config") == 0){ + hide_oc = 1; + } + } /* If non-presence container && HIDE mode && only child is * a list, then skip container keyword * See also xml2cli */ - if ((hide = yang_container_cli_hide(ys, gt)) == 0){ + if ((hide = yang_container_cli_hide(ys, gt)) == 0 && hide_oc == 0){ cprintf(cb, "%*s%s", level*3, "", yang_argument_get(ys)); if ((yd = yang_find(ys, Y_DESCRIPTION, NULL)) != NULL){ if ((helptext = strdup(yang_argument_get(yd))) == NULL){ @@ -868,7 +879,7 @@ yang2cli_container(clicon_handle h, while ((yc = yn_each(ys, yc)) != NULL) if (yang2cli_stmt(h, yc, gt, level+1, state, show_tree, cb) < 0) goto done; - if (hide == 0) + if (hide == 0 && hide_oc == 0) cprintf(cb, "%*s}\n", level*3, ""); retval = 0; done: @@ -955,7 +966,7 @@ yang2cli_list(clicon_handle h, cprintf(cb, "{\n"); } if (yang2cli_leaf(h, yleaf, - (gt==GT_VARS||gt==GT_HIDE)?GT_NONE:gt, level+1, + (gt==GT_VARS||gt==GT_HIDE||gt==GT_OC_COMPRESS)?GT_NONE:gt, level+1, last_key, show_tree, 1, cb) < 0) goto done; diff --git a/lib/clixon/clixon_options.h b/lib/clixon/clixon_options.h index 72073f09..ddec1eb8 100644 --- a/lib/clixon/clixon_options.h +++ b/lib/clixon/clixon_options.h @@ -77,6 +77,7 @@ enum genmodel_type{ GT_VARS, /* Keywords on non-key variables */ GT_ALL, /* Keywords on all variables */ GT_HIDE, /* Keywords on all variables and hide container around lists */ + GT_OC_COMPRESS, /* OpenConfig */ }; typedef enum genmodel_type genmodel_type; diff --git a/lib/src/clixon_options.c b/lib/src/clixon_options.c index aa2bcc3b..886781a8 100644 --- a/lib/src/clixon_options.c +++ b/lib/src/clixon_options.c @@ -89,6 +89,7 @@ static const map_str2int cli_genmodel_map[] = { {"VARS", GT_VARS}, {"ALL", GT_ALL}, {"HIDE", GT_HIDE}, + {"OC_COMPRESS", GT_OC_COMPRESS}, {NULL, -1} }; diff --git a/lib/src/clixon_xml_map.c b/lib/src/clixon_xml_map.c index aaf2c233..9abbf774 100644 --- a/lib/src/clixon_xml_map.c +++ b/lib/src/clixon_xml_map.c @@ -286,7 +286,7 @@ xml2cli_recurse(FILE *f, /* If presence container, then print as leaf (but continue to children) */ if (prepend) (*fn)(f, "%s", prepend); - if (gt == GT_ALL || gt == GT_VARS || gt == GT_HIDE) + if (gt == GT_ALL || gt == GT_VARS || gt == GT_HIDE || gt == GT_OC_COMPRESS) (*fn)(f, "%s ", xml_name(x)); if ((body = xml_body(x)) != NULL){ if (index(body, ' ')) diff --git a/lib/src/clixon_yang.c b/lib/src/clixon_yang.c index 7a588f26..72dfdc1b 100644 --- a/lib/src/clixon_yang.c +++ b/lib/src/clixon_yang.c @@ -3255,7 +3255,7 @@ yang_container_cli_hide(yang_stmt *ys, keyw = yang_keyword_get(ys); /* HIDE mode */ - if (gt != GT_HIDE) + if (gt != GT_HIDE && gt != GT_OC_COMPRESS) return 0; /* A container */ if (yang_keyword_get(ys) != Y_CONTAINER)