diff --git a/CHANGELOG.md b/CHANGELOG.md index fb1cb767..bec84b54 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Clixon Changelog +* [5.8.0](#580) Planned: July 2022 * [5.7.0](#570) 17 May 2022 * [5.6.0](#560) 8 March 2022 * [5.5.0](#550) 20 January 2022 diff --git a/apps/cli/cli_show.c b/apps/cli/cli_show.c index 50db956b..186f1222 100644 --- a/apps/cli/cli_show.c +++ b/apps/cli/cli_show.c @@ -309,7 +309,6 @@ expand_dbvar(void *h, clicon_err(OE_DB, 0, "Leafref %s requires path statement", yang_argument_get(ytype)); goto done; } - /* */ /* Extend xpath with leafref path: Append yang_argument_get(ypath) to xpath */ if (xpath_append(cbxpath, yang_argument_get(ypath), y, nsc) < 0) diff --git a/test/test_cli_expand.sh b/test/test_cli_expand.sh new file mode 100755 index 00000000..e108d3c7 --- /dev/null +++ b/test/test_cli_expand.sh @@ -0,0 +1,123 @@ +#!/usr/bin/env bash +# CLIgen expand +# Especially multi-level expansion, see https://github.com/clicon/clixon/issues/332 +# Have not been able to replicate it in cligen test_expand.sh + +# Magic line must be first in script (see README.md) +s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi + +APPNAME=example + +# include err() and new() functions and creates $dir + +cfg=$dir/conf_yang.xml +fyang=$dir/clixon-example.yang +clidir=$dir/clidir + +if [ ! -d $clidir ]; then + mkdir $clidir +fi + +cat < $cfg + + $cfg + ${YANG_INSTALLDIR} + $fyang + /usr/local/lib/$APPNAME/backend + $clidir + /usr/local/lib/$APPNAME/cli + $APPNAME + /usr/local/var/$APPNAME/$APPNAME.sock + /usr/local/var/$APPNAME/$APPNAME.pidfile + /usr/local/var/$APPNAME + +EOF + +cat < $fyang +module clixon-example{ + yang-version 1.1; + namespace "urn:example:clixon"; + prefix ex; + list list1{ + key "key1"; + leaf key1{ + type string; + } + list list2{ + key "key2"; + leaf key2{ + type string; + } + } + } +} +EOF + +# clispec files 1..6 for submodes AAA and BBB as described in top comment + +cat < $clidir/cli1.cli +CLICON_MODE="example"; +CLICON_PROMPT="%U@%H %W> "; + +# Autocli syntax tree operations +edit @datamodel, cli_auto_edit("datamodel"); +up, cli_auto_up("datamodel"); +top, cli_auto_top("datamodel"); +set @datamodel, cli_auto_set(); +merge @datamodel, cli_auto_merge(); +create @datamodel, cli_auto_create(); +delete("Delete a configuration item") { + @datamodel, cli_auto_del(); + all("Delete whole candidate configuration"), delete_all("candidate"); +} +show("Show a particular state of the system"){ + configuration("Show configuration"), cli_auto_show("datamodel", "candidate", "text", true, false);{ + xml("Show configuration as XML"), cli_auto_show("datamodel", "candidate", "xml", false, false); +} +} +EOF + +new "test params: -f $cfg" +if [ $BE -ne 0 ]; then + new "kill old backend" + sudo clixon_backend -z -f $cfg + if [ $? -ne 0 ]; then + err + fi + new "start backend -s init -f $cfg" + start_backend -s init -f $cfg +fi + +new "wait backend" +wait_backend + +new "Add entry 1 on level2" +expectpart "$($clixon_cli -1 -f $cfg set list1 xyz list2 123)" 0 "^$" + +new "Add entry 2 on level2" +expectpart "$($clixon_cli -1 -f $cfg set list1 xyz list2 abc)" 0 "^$" + +new "verify" +expectpart "$($clixon_cli -1 -f $cfg show config xml)" 0 'xyz123abc' + +new "Expand ?" +expectpart "$(echo "set list1 xyz list2 ?" | $clixon_cli -f $cfg 2>&1)" 0 123 abc "" + +new "Expand " +expectpart "$(echo "set list1 xyz list2 " | $clixon_cli -f $cfg 2>&1)" 0 123 abc "" + +if [ $BE -ne 0 ]; then + new "Kill backend" + # Check if premature kill + pid=$(pgrep -u root -f clixon_backend) + if [ -z "$pid" ]; then + err "backend already dead" + fi + # kill backend + stop_backend -f $cfg +fi + +rm -rf $dir + +new "endtest" +endtest diff --git a/yang/clixon/clixon-autocli@2021-12-05.yang b/yang/clixon/clixon-autocli@2022-05-30.yang similarity index 94% rename from yang/clixon/clixon-autocli@2021-12-05.yang rename to yang/clixon/clixon-autocli@2022-05-30.yang index 69fa9dea..4bfb9f34 100644 --- a/yang/clixon/clixon-autocli@2021-12-05.yang +++ b/yang/clixon/clixon-autocli@2022-05-30.yang @@ -41,9 +41,20 @@ module clixon-autocli{ ***** END LICENSE BLOCK *****"; + revision 2022-05-30 { + description + " + Released in Clixon 5.8"; + } + revision 2022-02-11 { + description + "Initial version + Released in Clixon 5.6"; + } revision 2021-12-05 { description - "Initial version"; + "Initial version + Released in Clixon 5.5"; } extension hide { description @@ -57,6 +68,11 @@ module clixon-autocli{ "Modify the autocli by hiding the command associated with a YANG node and its sub-commands in CLI show commands."; } + extension strict-expand { + description + "Modify the autocli by only showing exactly the expanded values of a variable. + It should not be possible to add a new value that is not in the expanded list."; + } typedef autocli-op { description "Autocli rule-type operation, each rule use different fields as