From a49cf41d1ed74204a4ae301a4a50b2492a035645 Mon Sep 17 00:00:00 2001 From: Olof hagsand Date: Tue, 10 May 2022 10:06:43 +0200 Subject: [PATCH] * CLI expansion of leafrefs default behavior changed * In the autocli and handcrafted CLI:s using `expand_dbvar()` the CLI expansion followed the leafrefs to the sources, ie the origin of the leafrefs * Instead leafref expansion now only looks at the leafrefs --- CHANGELOG.md | 11 +++++++++++ apps/cli/cli_show.c | 3 ++- test/test_cli_leafref.sh | 11 +++++++---- yang/clixon/clixon-config@2022-03-21.yang | 16 ++++++++++++++++ 4 files changed, 36 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index de207001..fb48647d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -64,6 +64,16 @@ Expected: May 2022 Users may have to change how they access the system +* CLI expansion of leafrefs default behavior changed + * In the autocli and handcrafted CLI:s using `expand_dbvar()` the CLI expansion followed the leafrefs to the sources, ie the origin of the leafrefs + * Instead leafref expansion now only looks at the leafrefs + * Example: + * Assume ifref with leafref pointing to source if values: + * `abc` + * `b` + * Existing behavior: propose: `a, b, c` + * New default behavior: propose: `b` + * To keep existing behavior, set `true` * Restconf * Added 404 return without body if neither restconf, data or streams prefix match * Netconf: Usage of chunked framing" @@ -77,6 +87,7 @@ Users may have to change how they access the system * `CLICON_NETCONF_BASE_CAPABILITY` * `CLICON_HTTP_DATA_PATH` * `CLICON_HTTP_DATA_ROOT` + * `CLICON_CLI_EXPAND_LEAFREF` * New `clixon-restconf@2022-03-21.yang` revision * Added option: * `enable-http-data` diff --git a/apps/cli/cli_show.c b/apps/cli/cli_show.c index 4799c7ac..50db956b 100644 --- a/apps/cli/cli_show.c +++ b/apps/cli/cli_show.c @@ -277,7 +277,8 @@ expand_dbvar(void *h, goto done; } cprintf(cbxpath, "%s", xpath); - if ((ytype = yang_find(y, Y_TYPE, NULL)) != NULL && + if (clicon_option_bool(h, "CLICON_CLI_EXPAND_LEAFREF") && + (ytype = yang_find(y, Y_TYPE, NULL)) != NULL && strcmp(yang_argument_get(ytype), "leafref") == 0){ /* Special case for leafref. Detect leafref via Yang-type, * Get Yang path element, tentatively add the new syntax to the whole diff --git a/test/test_cli_leafref.sh b/test/test_cli_leafref.sh index a54e811b..d0230ef1 100755 --- a/test/test_cli_leafref.sh +++ b/test/test_cli_leafref.sh @@ -178,13 +178,16 @@ new "expand identityref 1st level" expectpart "$(echo "set identityrefs identityref ?" | $clixon_cli -f $cfg 2> /dev/null)" 0 "ex:des" "ex:des2" "ex:des3" new "expand leafref 1st level" -expectpart "$(echo "set leafrefs leafref ?" | $clixon_cli -f $cfg 2> /dev/null)" 0 "91" "92" "93" +expectpart "$(echo "set leafrefs leafref ?" | $clixon_cli -f $cfg -o CLICON_CLI_EXPAND_LEAFREF=false 2> /dev/null)" 0 "" --not-- "91" "92" "93" + +new "expand leafref 1st level with leafref expand" +expectpart "$(echo "set leafrefs leafref ?" | $clixon_cli -f $cfg -o CLICON_CLI_EXPAND_LEAFREF=true 2> /dev/null)" 0 "91" "92" "93" new "expand leafref top" -expectpart "$(echo "set leafrefsabs leafref ?" | $clixon_cli -f $cfg 2> /dev/null)" 0 "91" "92" "93" +expectpart "$(echo "set leafrefsabs leafref ?" | $clixon_cli -f $cfg -o CLICON_CLI_EXPAND_LEAFREF=true 2> /dev/null)" 0 "91" "92" "93" new "expand leafref require-instance" -expectpart "$(echo "set leafrefsreqinst leafref ?" | $clixon_cli -f $cfg 2> /dev/null)" 0 "91" "92" "93" +expectpart "$(echo "set leafrefsreqinst leafref ?" | $clixon_cli -f $cfg -o CLICON_CLI_EXPAND_LEAFREF=true 2> /dev/null)" 0 "91" "92" "93" # First level id/leaf refs new "set identityref des" @@ -237,7 +240,7 @@ expectpart "$(echo "set identityrefs2 identityref ?" | $clixon_cli -f $cfg 2> /d # Note CI may have random number as host which may match "92" new "expand leafref 2nd level" -expectpart "$(echo "set leafrefs2 leafref ?" | $clixon_cli -f $cfg 2> /dev/null)" 0 " 91" " 93" --not-- " 92" +expectpart "$(echo "set leafrefs2 leafref ?" | $clixon_cli -f $cfg -o CLICON_CLI_EXPAND_LEAFREF=true 2> /dev/null)" 0 " 91" " 93" --not-- " 92" new "set identityref2 des" expectpart "$($clixon_cli -1 -f $cfg set identityrefs2 identityref ex:des)" 0 "^$" diff --git a/yang/clixon/clixon-config@2022-03-21.yang b/yang/clixon/clixon-config@2022-03-21.yang index 1903de31..ac07045d 100644 --- a/yang/clixon/clixon-config@2022-03-21.yang +++ b/yang/clixon/clixon-config@2022-03-21.yang @@ -53,6 +53,7 @@ module clixon-config { CLICON_NETCONF_BASE_CAPABILITY CLICON_HTTP_DATA_PATH CLICON_HTTP_DATA_ROOT + CLICON_CLI_EXPAND_LEAFREF Released in Clixon 5.7"; } revision 2022-02-11 { @@ -762,6 +763,21 @@ module clixon-config { This only applies if you have multi-line help strings, such as when generating from a spec, such as in the autocli."; } + leaf CLICON_CLI_EXPAND_LEAFREF { + type boolean; + default false; + description + "If true, then CLI expansion of leafrefs (in expand_dbvar) are done using the + source values, not the references. + This applies to the autocli but also in a handcrafted CLI if expand_dbvar is used. + Example, assume ifref with leafref pointing to source if values: + abc + b + If true, expansion will suggest a, b, c (source if values) + If false, expansion will suggest b (destination ifref values) + While setting this value makes sense for adding new values, it makes less sense for + deleting."; + } leaf CLICON_SOCK_FAMILY { type socket_address_family; default UNIX;