* New clixon-lib@2021-12-05.yang revision

* Extension `autocli-op` obsoleted and no longer supported
  * You need to change to use clixon-autocli `hide`and `hide-show` instead.
  * Translate as follows:
    * `cl:autocli-op hide` -> `autocli:hide`
    * `cl:autocli-op hide-database` -> `autocli:hide-show`
    * `cl:autocli-op hide-database-auto-completion` -> `autocli:hide; autocli:hide-show`
This commit is contained in:
Olof hagsand 2022-01-12 21:58:41 +01:00
parent 081e6871b3
commit e0bcca5405
14 changed files with 410 additions and 146 deletions

View file

@ -96,6 +96,9 @@ co2apipath(cg_obj *co)
return cv_string_get(cv);;
}
/* Append to cvv1 to cvv0
* @note if cvv0 is non-null, the first element of cvv1 is skipped
*/
static cvec*
cvec_append(cvec *cvv0,
cvec *cvv1)
@ -167,17 +170,14 @@ cli_xml2file(cxobj *xn,
int haselement;
char *val;
char *encstr = NULL; /* xml encoded string */
char *opext = NULL;
int exist = 0;
if (xn == NULL)
goto ok;
/* Look for autocli-op defined in clixon-lib.yang */
if (yang_extension_value(xml_spec(xn), "autocli-op", CLIXON_LIB_NS, NULL, &opext) < 0) {
if (yang_extension_value(xml_spec(xn), "hide-show", CLIXON_AUTOCLI_NS, &exist, NULL) < 0)
goto done;
if (exist)
goto ok;
}
if ((opext != NULL) && ((strcmp(opext, "hide-database") == 0) || (strcmp(opext, "hide-database-auto-completion") == 0))){
goto ok;
}
name = xml_name(xn);
namespace = xml_prefix(xn);
switch(xml_type(xn)){
@ -268,19 +268,16 @@ cli_xml2txt(cxobj *xn,
cxobj *xc = NULL;
int children=0;
int retval = -1;
char *opext = NULL;
int exist = 0;
if (xn == NULL || fn == NULL){
clicon_err(OE_XML, EINVAL, "xn or fn is NULL");
goto done;
}
/* Look for autocli-op defined in clixon-lib.yang */
if (yang_extension_value(xml_spec(xn), "autocli-op", CLIXON_LIB_NS, NULL, &opext) < 0) {
if (yang_extension_value(xml_spec(xn), "hide-show", CLIXON_AUTOCLI_NS, &exist, NULL) < 0)
goto done;
if (exist)
goto ok;
}
if ((opext != NULL) && ((strcmp(opext, "hide-database") == 0) || (strcmp(opext, "hide-database-auto-completion") == 0))){
goto ok;
}
xc = NULL; /* count children (elements and bodies, not attributes) */
while ((xc = xml_child_each(xn, xc, -1)) != NULL)
if (xml_type(xc) == CX_ELMNT || xml_type(xc) == CX_BODY)
@ -353,7 +350,7 @@ cli_auto_edit(clicon_handle h,
goto done;
}
/* Find the matching cligen object
* Note, is complictead: either an instantiated tree (co_treeref_orig)
* Note, is complicated: either an instantiated tree (co_treeref_orig)
* or actual tree (co_ref)
*/
if ((co = cligen_co_match(cli_cligen(h))) != NULL){

View file

@ -134,11 +134,12 @@ cli_expand_var_generate(clicon_handle h,
cbuf *cb)
{
int retval = -1;
char *api_path_fmt = NULL, *opext = NULL;
char *api_path_fmt = NULL;
int exist = 0;
if (yang_extension_value(ys, "autocli-op", CLIXON_LIB_NS, NULL, &opext) < 0)
if (yang_extension_value(ys, "hide", CLIXON_AUTOCLI_NS, &exist, NULL) < 0)
goto done;
if (opext && strcmp(opext, "hide-database") == 0) {
if (exist) {
retval = 1;
goto done;
}
@ -760,9 +761,10 @@ yang2cli_leaf(clicon_handle h,
int retval = -1;
char *helptext = NULL;
char *s;
char *opext = NULL;
int extralevel = 0;
autocli_listkw_t listkw;
int exist = 0;
/* description */
if ((yd = yang_find(ys, Y_DESCRIPTION, NULL)) != NULL){
@ -774,9 +776,6 @@ yang2cli_leaf(clicon_handle h,
*s = '\0';
}
cprintf(cb, "%*s", level*3, "");
/* Look for autocli-op defined in clixon-lib.yang */
if (yang_extension_value(ys, "autocli-op", CLIXON_LIB_NS, NULL, &opext) < 0)
goto done;
if (autocli_list_keyword(h, &listkw) < 0)
goto done;
if (listkw == AUTOCLI_LISTKW_ALL ||
@ -784,14 +783,12 @@ yang2cli_leaf(clicon_handle h,
cprintf(cb, "%s", yang_argument_get(ys));
yang2cli_helptext(cb, helptext);
cprintf(cb, " ");
if (opext && strcmp(opext, "hide") == 0){
if (yang_extension_value(ys, "hide", CLIXON_AUTOCLI_NS, &exist, NULL) < 0)
goto done;
if (exist){
cprintf(cb, ", hide{");
extralevel = 1;
}
if (opext && strcmp(opext, "hide-database-auto-completion") == 0){
cprintf(cb, ", hide-database-auto-completion{");
extralevel = 1;
}
if (yang2cli_var(h, ys, ys, helptext, cb) < 0)
goto done;
}
@ -832,9 +829,9 @@ yang2cli_container(clicon_handle h,
char *s;
int compress = 0;
int hide_oc = 0;
char *opext = NULL;
yang_stmt *ymod = NULL;
int exist = 0;
if (ys_real_module(ys, &ymod) < 0)
goto done;
/* If non-presence container && HIDE mode && only child is
@ -856,16 +853,11 @@ yang2cli_container(clicon_handle h,
}
if (cli_callback_generate(h, ys, cb) < 0)
goto done;
/* Look for autocli-op defined in clixon-lib.yang */
if (yang_extension_value(ys, "autocli-op", CLIXON_LIB_NS, NULL, &opext) < 0)
if (yang_extension_value(ys, "hide", CLIXON_AUTOCLI_NS, &exist, NULL) < 0)
goto done;
if (opext != NULL && strcmp(opext, "hide") == 0){
if (exist){
cprintf(cb, ",hide");
}
if (opext != NULL && strcmp(opext, "hide-database-auto-completion") == 0){
cprintf(cb, ", hide-database-auto-completion");
}
cprintf(cb, ";{\n");
}
@ -904,7 +896,7 @@ yang2cli_list(clicon_handle h,
char *helptext = NULL;
char *s;
int last_key = 0;
char *opext = NULL;
int exist = 0;
cprintf(cb, "%*s%s", level*3, "", yang_argument_get(ys));
if ((yd = yang_find(ys, Y_DESCRIPTION, NULL)) != NULL){
@ -916,15 +908,11 @@ yang2cli_list(clicon_handle h,
*s = '\0';
yang2cli_helptext(cb, helptext);
}
/* Look for autocli-op defined in clixon-lib.yang */
if (yang_extension_value(ys, "autocli-op", CLIXON_LIB_NS, NULL, &opext) < 0)
if (yang_extension_value(ys, "hide", CLIXON_AUTOCLI_NS, &exist, NULL) < 0)
goto done;
if (opext != NULL && strcmp(opext, "hide") == 0){
if (exist){
cprintf(cb, ",hide");
}
if (opext != NULL && strcmp(opext, "hide-database-auto-completion") == 0){
cprintf(cb, ",hide-database-auto-completion");
}
/* Loop over all key variables */
cvk = yang_cvec_get(ys); /* Use Y_LIST cache, see ys_populate_list() */
cvi = NULL;

View file

@ -608,7 +608,6 @@ clicon_parse(clicon_handle h,
clicon_err_reset();
if ((ret = cligen_eval(ch, match_obj, cvv, callbacks)) < 0)
cli_handler_err(stdout);
}
else
ret = 0;

View file

@ -1038,9 +1038,9 @@ xml2cli(clicon_handle h,
yang_stmt *ys;
int match;
char *body;
char *opext = NULL;
int compress = 0;
autocli_listkw_t listkw;
int exist = 0;
if (autocli_list_keyword(h, &listkw) < 0)
goto done;
@ -1048,13 +1048,10 @@ xml2cli(clicon_handle h,
goto ok;
if ((ys = xml_spec(xn)) == NULL)
goto ok;
/* Look for autocli-op defined in clixon-lib.yang */
if (yang_extension_value(xml_spec(xn), "autocli-op", CLIXON_LIB_NS, NULL, &opext) < 0) {
if (yang_extension_value(ys, "hide-show", CLIXON_AUTOCLI_NS, &exist, NULL) < 0)
goto done;
if (exist)
goto ok;
}
if ((opext != NULL) && ((strcmp(opext, "hide-database") == 0) || (strcmp(opext, "hide-database-auto-completion") == 0))){
goto ok;
}
/* If leaf/leaf-list or presence container, then print line */
if (yang_keyword_get(ys) == Y_LEAF ||
yang_keyword_get(ys) == Y_LEAF_LIST){