Added yspec parameter to api_path_fmt2api_path()
Added "%k" as extra flag character to api-path-fmt
This commit is contained in:
parent
96f94114e2
commit
9f73014500
9 changed files with 98 additions and 21 deletions
|
|
@ -128,11 +128,16 @@ cli_auto_edit(clixon_handle h,
|
|||
int argc = 0;
|
||||
char *str;
|
||||
char *mtpoint = NULL;
|
||||
yang_stmt *yspec0;
|
||||
|
||||
if (cvec_len(argv) != 2 && cvec_len(argv) != 3){
|
||||
clixon_err(OE_PLUGIN, EINVAL, "Usage: %s(api_path_fmt>*, <treename>)", __FUNCTION__);
|
||||
goto done;
|
||||
}
|
||||
if ((yspec0 = clicon_dbspec_yang(h)) == NULL){
|
||||
clixon_err(OE_FATAL, 0, "No DB_SPEC");
|
||||
goto done;
|
||||
}
|
||||
api_path_fmt = cv_string_get(cvec_i(argv, argc++));
|
||||
str = cv_string_get(cvec_i(argv, argc++));
|
||||
if (str && strncmp(str, "mtpoint:", strlen("mtpoint:")) == 0){
|
||||
|
|
@ -172,7 +177,7 @@ cli_auto_edit(clixon_handle h,
|
|||
goto done;
|
||||
}
|
||||
/* get api-path and xpath */
|
||||
if (api_path_fmt2api_path(api_path_fmt, cvv2, &api_path, NULL) < 0)
|
||||
if (api_path_fmt2api_path(api_path_fmt, cvv2, yspec0, &api_path, NULL) < 0)
|
||||
goto done;
|
||||
/* Store this as edit-mode */
|
||||
if (clicon_data_set(h, "cli-edit-mode", api_path) < 0)
|
||||
|
|
@ -234,11 +239,16 @@ cli_auto_up(clixon_handle h,
|
|||
int j;
|
||||
size_t len;
|
||||
cvec *cvv_filter = NULL;
|
||||
yang_stmt *yspec0;
|
||||
|
||||
if (cvec_len(argv) != 1){
|
||||
clixon_err(OE_PLUGIN, EINVAL, "Usage: %s(<treename>)", __FUNCTION__);
|
||||
goto done;
|
||||
}
|
||||
if ((yspec0 = clicon_dbspec_yang(h)) == NULL){
|
||||
clixon_err(OE_FATAL, 0, "No DB_SPEC");
|
||||
goto done;
|
||||
}
|
||||
cv = cvec_i(argv, 0);
|
||||
treename = cv_string_get(cv);
|
||||
if ((ph = cligen_ph_find(cli_cligen(h), treename)) == NULL){
|
||||
|
|
@ -289,7 +299,7 @@ cli_auto_up(clixon_handle h,
|
|||
cvec_append_var(cvv1, cv);
|
||||
}
|
||||
/* get api-path and xpath */
|
||||
if (api_path_fmt2api_path(api_path_fmt1, cvv1, &api_path, NULL) < 0)
|
||||
if (api_path_fmt2api_path(api_path_fmt1, cvv1, yspec0, &api_path, NULL) < 0)
|
||||
goto done;
|
||||
/* Store this as edit-mode */
|
||||
clicon_data_set(h, "cli-edit-mode", api_path);
|
||||
|
|
@ -506,11 +516,16 @@ cli_auto_sub_enter(clixon_handle h,
|
|||
cg_var *cv = NULL;
|
||||
pt_head *ph;
|
||||
struct findpt_arg fa = {0,};
|
||||
yang_stmt *yspec0;
|
||||
|
||||
if (cvec_len(argv) < 2){
|
||||
clixon_err(OE_PLUGIN, EINVAL, "Usage: %s(<tree> <api_path_fmt> (,vars)*)", __FUNCTION__);
|
||||
goto done;
|
||||
}
|
||||
if ((yspec0 = clicon_dbspec_yang(h)) == NULL){
|
||||
clixon_err(OE_FATAL, 0, "No DB_SPEC");
|
||||
goto done;
|
||||
}
|
||||
/* First argv argument: treename */
|
||||
cv = cvec_i(argv, 0);
|
||||
treename = cv_string_get(cv);
|
||||
|
|
@ -540,7 +555,7 @@ cli_auto_sub_enter(clixon_handle h,
|
|||
if (cvec_append_var(cvv1, cvec_i(cvv, i)) < 0)
|
||||
goto done;
|
||||
}
|
||||
if (api_path_fmt2api_path(api_path_fmt, cvv1, &api_path, NULL) < 0)
|
||||
if (api_path_fmt2api_path(api_path_fmt, cvv1, yspec0, &api_path, NULL) < 0)
|
||||
goto done;
|
||||
/* Assign the variables */
|
||||
if ((cvv2 = cvec_append(clicon_data_cvec_get(h, "cli-edit-cvv"), cvv1)) == NULL)
|
||||
|
|
|
|||
|
|
@ -443,7 +443,7 @@ cli_dbxml(clixon_handle h,
|
|||
/* Transform template format string + cvv to actual api-path
|
||||
* cvvi indicates if all cvv entries were used
|
||||
*/
|
||||
if (api_path_fmt2api_path(api_path_fmt01, cvv, &api_path, &cvvi) < 0)
|
||||
if (api_path_fmt2api_path(api_path_fmt01, cvv, yspec0, &api_path, &cvvi) < 0)
|
||||
goto done;
|
||||
}
|
||||
else {
|
||||
|
|
@ -451,7 +451,7 @@ cli_dbxml(clixon_handle h,
|
|||
/* Transform template format string + cvv to actual api-path
|
||||
* cvvi indicates if all cvv entries were used
|
||||
*/
|
||||
if (api_path_fmt2api_path(api_path_fmt, cvv, &api_path, &cvvi) < 0)
|
||||
if (api_path_fmt2api_path(api_path_fmt, cvv, yspec0, &api_path, &cvvi) < 0)
|
||||
goto done;
|
||||
}
|
||||
/* Create config top-of-tree */
|
||||
|
|
|
|||
|
|
@ -204,7 +204,8 @@ xpath_append(cbuf *cb0,
|
|||
* @retval -1 Error
|
||||
* @see cli_expand_var_generate where api_path_fmt + mt-point are generated
|
||||
* The syntax of <api_path_fmt> is of RFC8040 api-path with the following extension:
|
||||
* "%s" represents the values of cvv in order starting from element 1
|
||||
* %s Represents the values of cvv in order starting from element 1
|
||||
* %k Represents the (first) key of the (previous) list
|
||||
*/
|
||||
int
|
||||
expand_dbvar(void *h,
|
||||
|
|
@ -297,11 +298,11 @@ expand_dbvar(void *h,
|
|||
/* Get and combined api-path01 */
|
||||
if (mtpoint_paths(yspec0, mtpoint, api_path_fmt, &api_path_fmt01) < 0)
|
||||
goto done;
|
||||
if (api_path_fmt2api_path(api_path_fmt01, cvv, &api_path, &cvvi) < 0)
|
||||
if (api_path_fmt2api_path(api_path_fmt01, cvv, yspec0, &api_path, &cvvi) < 0)
|
||||
goto done;
|
||||
}
|
||||
else{
|
||||
if (api_path_fmt2api_path(api_path_fmt, cvv, &api_path, &cvvi) < 0)
|
||||
if (api_path_fmt2api_path(api_path_fmt, cvv, yspec0, &api_path, &cvvi) < 0)
|
||||
goto done;
|
||||
}
|
||||
if (api_path == NULL)
|
||||
|
|
@ -1092,11 +1093,11 @@ cli_show_auto(clixon_handle h,
|
|||
/* Get and combined api-path01 */
|
||||
if (mtpoint_paths(yspec0, mtpoint, api_path_fmt, &api_path_fmt01) < 0)
|
||||
goto done;
|
||||
if (api_path_fmt2api_path(api_path_fmt01, cvv, &api_path, &cvvi) < 0)
|
||||
if (api_path_fmt2api_path(api_path_fmt01, cvv, yspec0, &api_path, &cvvi) < 0)
|
||||
goto done;
|
||||
}
|
||||
else{
|
||||
if (api_path_fmt2api_path(api_path_fmt, cvv, &api_path, &cvvi) < 0)
|
||||
if (api_path_fmt2api_path(api_path_fmt, cvv, yspec0, &api_path, &cvvi) < 0)
|
||||
goto done;
|
||||
}
|
||||
if (api_path2xpath(api_path, yspec0, &xpath, &nsc, NULL) < 0)
|
||||
|
|
|
|||
|
|
@ -358,7 +358,7 @@ snmp_yang2xml(cxobj *xtop,
|
|||
}
|
||||
for (i=0; i<cvec_len(cvk); i++)
|
||||
cvec_append_var(cvk1, cvec_i(cvk,i));
|
||||
if (api_path_fmt2api_path(api_path_fmt, cvk1, &api_path, NULL) < 0)
|
||||
if (api_path_fmt2api_path(api_path_fmt, cvk1, yspec, &api_path, NULL) < 0)
|
||||
goto done;
|
||||
if ((ret = api_path2xml(api_path, yspec, xtop, YC_DATANODE, 1, xbot, NULL, NULL)) < 0)
|
||||
goto done;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue