Skip to content

Commit

Permalink
cli_auto_up: Partly fix handling of mountpoints
Browse files Browse the repository at this point in the history
The cli_auto_up command right now does not properly handle
mountpoints.

Fix the case when going up one level inside of a mounted
module.

Note that this does not yet fix the case where the current level
is the top-level of the mounted module. In that case the up command
should switch to the presence container that holds the mounted
module. Instead it switches all the way up to the topmost level, so
it has the same effect as the top command.
  • Loading branch information
colinhusu authored and olofhagsand committed May 16, 2024
1 parent c353c6d commit 4b33841
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions apps/cli/cli_auto.c
Original file line number Diff line number Diff line change
Expand Up @@ -248,12 +248,14 @@ cli_auto_up(clixon_handle h,
cvec *cvv1 = NULL; /* copy */
char *api_path_fmt0; /* from */
char *api_path_fmt1; /* to */
char *api_path_fmt2 = NULL; /* 'to' with mountpoint prepended */
char *api_path = NULL;
int i;
int j;
size_t len;
cvec *cvv_filter = NULL;
yang_stmt *yspec0;
char *mtpoint = "";

if (cvec_len(argv) != 1){
clixon_err(OE_PLUGIN, EINVAL, "Usage: %s(<treename>)", __FUNCTION__);
Expand Down Expand Up @@ -313,15 +315,26 @@ cli_auto_up(clixon_handle h,
cv = cvec_i(cvv0, i);
cvec_append_var(cvv1, cv);
}
/* get api-path and xpath */
if (api_path_fmt2api_path(api_path_fmt1, cvv1, yspec0, &api_path, NULL) < 0)
goto done;
clicon_data_get(h, "cli-edit-mtpoint", &mtpoint);
if (strlen(mtpoint)) {
if (mtpoint_paths(yspec0, mtpoint, api_path_fmt1, &api_path_fmt2) < 0)
goto done;
if (api_path_fmt2api_path(api_path_fmt2, cvv1, yspec0, &api_path, NULL) < 0)
goto done;
}
else{
/* get api-path and xpath */
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);
clicon_data_cvec_set(h, "cli-edit-cvv", cvv1);
ok:
retval = 0;
done:
if (api_path_fmt2)
free(api_path_fmt2);
if (api_path)
free(api_path);
return retval;
Expand Down

0 comments on commit 4b33841

Please sign in to comment.