From df9e4734f917c431bce624ede6c10da7ecde09c0 Mon Sep 17 00:00:00 2001 From: Olof hagsand Date: Sun, 4 Aug 2019 17:07:11 +0200 Subject: [PATCH] Bugfix: multiple key cli bug, ambiguous commands in expand_dbvar --- README.md | 2 +- apps/cli/cli_show.c | 8 +-- doc/ROADMAP.md | 27 ---------- docs/_config.yml | 1 - test/test_cli.sh | 1 - test/test_cli_multikey.sh | 107 ++++++++++++++++++++++++++++++++++++++ test/test_yang.sh | 1 - 7 files changed, 113 insertions(+), 34 deletions(-) delete mode 100644 docs/_config.yml create mode 100755 test/test_cli_multikey.sh diff --git a/README.md b/README.md index 3980efa8..c778b710 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![Build Status](https://travis-ci.org/clicon/clixon.png)](https://travis-ci.org/clicon/clixon) +[![Build Status](https://travis-ci.org/clicon/clixon.png)](https://travis-ci.org/clicon/clixon) [![Documentation Status](https://readthedocs.org/projects/clixon-docs/badge/?version=latest)](https://clixon-docs.readthedocs.io/en/latest/?badge=latest) # Clixon diff --git a/apps/cli/cli_show.c b/apps/cli/cli_show.c index ad6f96f8..811467cb 100644 --- a/apps/cli/cli_show.c +++ b/apps/cli/cli_show.c @@ -144,13 +144,14 @@ expand_dbvar(void *h, } api_path_fmt = cv_string_get(cv); /* api_path_fmt = /interface/%s/address/%s - api_path: --> /interface/eth0/address/.* - xpath: --> /interface/[name="eth0"]/address - */ + * api_path: --> /interface/eth0/address/.* + * xpath: --> /interface/[name="eth0"]/address + */ if (api_path_fmt2api_path(api_path_fmt, cvv, &api_path) < 0) goto done; if (api_path2xpath(api_path, yspec, &xpath, &namespace) < 0) goto done; + /* Get configuration */ if (clicon_rpc_get_config(h, dbstr, xpath, namespace, &xt) < 0) /* XXX */ goto done; @@ -215,6 +216,7 @@ expand_dbvar(void *h, continue; /* duplicate, assume sorted */ /* RFC3986 decode */ cvec_add_string(commands, NULL, bodystr); + bodystr0 = bodystr; } ok: retval = 0; diff --git a/doc/ROADMAP.md b/doc/ROADMAP.md index e7d2a3d2..d7f2527e 100644 --- a/doc/ROADMAP.md +++ b/doc/ROADMAP.md @@ -1,38 +1,11 @@ # Clixon roadmap -## High prio -- Special handling of the initial startup transaction to avoid exit at startup - - Possibly - draft-wu-netconf-restconf-factory-restore-03 - - See (startup.md) -- Handle revisions to data model. - - Possibly draft-wang-netmod-module-revision-management-01 - - See (startup.md) - -## Medium prio: - - [Sanity checks](https://github.com/clicon/clixon/issues/47) - -## Low prio: -- Provide a client library to access netconf APIs provided by system services. - - Netconf backend (Clixon acts as netconf controller) - Support for restconf call-home (RFC 8071) - -Not prioritized: - Support for restconf PATCH method - NETCONF - Support for additional Netconf [edit-config modes](https://github.com/clicon/clixon/issues/53) - Netconf [framing](https://github.com/clicon/clixon/issues/50) - [Child ordering](https://github.com/clicon/clixon/issues/22) -- Restconf - - Query parameters -- Streams (netconf and restconf) - - Extend native stream mode with external persistent timeseries database, eg influxdb. -- (DONE)Jenkins/Travis CI/CD and webhooks -- YANG - - RFC 6022 [NETCONF monitoring](https://github.com/clicon/clixon/issues/39) - - Deviation, min/max-elements, action, unique -- Containers - - (DONE)[Docker improvements](https://github.com/clicon/clixon/issues/44) - - Kubernetes Helm chart definition - [gRPC](https://github.com/clicon/clixon/issues/43) diff --git a/docs/_config.yml b/docs/_config.yml deleted file mode 100644 index 2f7efbea..00000000 --- a/docs/_config.yml +++ /dev/null @@ -1 +0,0 @@ -theme: jekyll-theme-minimal \ No newline at end of file diff --git a/test/test_cli.sh b/test/test_cli.sh index a65b8ffd..59156ff7 100755 --- a/test/test_cli.sh +++ b/test/test_cli.sh @@ -30,7 +30,6 @@ cat < $cfg $APPNAME /usr/local/var/$APPNAME/$APPNAME.sock /usr/local/var/$APPNAME/$APPNAME.pidfile - 1 /usr/local/var/$APPNAME EOF diff --git a/test/test_cli_multikey.sh b/test/test_cli_multikey.sh new file mode 100755 index 00000000..331ef1f4 --- /dev/null +++ b/test/test_cli_multikey.sh @@ -0,0 +1,107 @@ +#!/bin/bash +# CLI test for multi-key lists + +# 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/$APPNAME.yang + +# Use yang in example + +cat < $cfg + + $cfg + /usr/local/share/clixon + $dir + $fyang + /usr/local/lib/$APPNAME/clispec + /usr/local/lib/$APPNAME/cli + $APPNAME + + ALL + /usr/local/var/$APPNAME/$APPNAME.sock + /usr/local/var/$APPNAME/$APPNAME.pidfile + /usr/local/var/$APPNAME + +EOF + +cat < $fyang +module $APPNAME{ + yang-version 1.1; + prefix ex; + namespace "urn:example:clixon"; + container ex { + list x{ + key "a b" ; + leaf a { + type string; + } + leaf b { + type enumeration{ + enum v1; + enum v2; + enum v3; + } + } + } + } +} +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 + + new "waiting" + wait_backend +fi + +new "set 1 v1" +expectfn "$clixon_cli -1 -f $cfg set ex x a 1 b v1" 0 "" + +new "set 1 v2" +expectfn "$clixon_cli -1 -f $cfg set ex x a 1 b v2" 0 "" + +new "set 1 v3" +expectfn "$clixon_cli -1 -f $cfg set ex x a 1 b v3" 0 "" + +new "set 2 v1" +expectfn "$clixon_cli -1 -f $cfg set ex x a 2 b v1" 0 "" + +new "set 2 v2" +expectfn "$clixon_cli -1 -f $cfg set ex x a 2 b v2" 0 "" + +new "set 2 v3" +expectfn "$clixon_cli -1 -f $cfg set ex x a 2 b v3" 0 "" + +new "set 1 v2 again" +expectfn "$clixon_cli -1 -f $cfg set ex x a 1 b v2" 0 "" + +new "show conf" +expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' '^1v11v21v32v12v22v3]]>]]>$' + +if [ $BE -eq 0 ]; then + exit # BE +fi + +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 + +rm -rf $dir diff --git a/test/test_yang.sh b/test/test_yang.sh index a448db71..b962201a 100755 --- a/test/test_yang.sh +++ b/test/test_yang.sh @@ -23,7 +23,6 @@ cat < $cfg $APPNAME /usr/local/var/$APPNAME/$APPNAME.sock /usr/local/var/$APPNAME/$APPNAME.pidfile - 1 /usr/local/var/$APPNAME true