Fixed: [All values in list don't appear when writing "show <list>" in cli](https://github.com/clicon/clixon/issues/359)

CLISPEC change:
* Changed signature of `cli_show_auto()`,
* remove: `cli_show_auto_state()`
This commit is contained in:
Olof hagsand 2022-09-14 15:31:45 +02:00
parent 76c1566d00
commit 9a224ea4a0
9 changed files with 408 additions and 65 deletions

View file

@ -66,8 +66,18 @@ Users may have to change how they access the system
* Check of incoming RPCs
* Check of non-presence containers
### C/CLI-API changes on existing features
Developers may need to change their code
* CLISPEC change: Changed signature of `cli_show_auto()` and `cli_show_auto_state()`
* Added parameters for pretty-print, state and with-default
* As developer, you only need to replace the old functions if you have the cli prefix parameter set:
* `cli_show_auto(<db>, <format>, <prefix>)` -> `cli_show_auto(<db>, <format>, true, false, "report-all", <prefix>)`
### Corrected Bugs
* Fixed: [All values in list don't appear when writing "show <list>" in cli](https://github.com/clicon/clixon/issues/359)
* Fixed: [yang regular char \w not include underline char](https://github.com/clicon/clixon/issues/357)
* Fixed: [Clixon backend transactions for choice/case is not logical](https://github.com/clicon/clixon/issues/361)
* Fixed: [Clixon backend transaction callback fails for empty types](https://github.com/clicon/clixon/issues/360)

View file

@ -346,7 +346,7 @@ cli_auto_top(clicon_handle h,
* <dbname> "running"|"candidate"|"startup"
* <format> "text"|"xml"|"json"|"cli"|"netconf" (see format_enum)
* <pretty> true|false: pretty-print or not
* <state> true|false: include state in output
* <state> true|false: also print state
* <default> Retrieval default mode: report-all, trim, explicit, report-all-tagged,
* report-all-tagged-default, report-all-tagged-strip
* <prefix> CLI prefix: to print before cli syntax output
@ -507,13 +507,13 @@ cli_auto_show(clicon_handle h,
goto done;
break;
case FORMAT_NETCONF:
fprintf(stdout, "<rpc xmlns=\"%s\" %s><edit-config><target><candidate/></target><config>",
cligen_output(stdout, "<rpc xmlns=\"%s\" %s><edit-config><target><candidate/></target><config>",
NETCONF_BASE_NAMESPACE, NETCONF_MESSAGE_ID_ATTR);
if (pretty)
fprintf(stdout, "\n");
cligen_output(stdout, "\n");
if (clixon_xml2file(stdout, xp, 2, pretty, cligen_output, skiproot, 1) < 0)
goto done;
fprintf(stdout, "</config></edit-config></rpc>]]>]]>\n");
cligen_output(stdout, "</config></edit-config></rpc>]]>]]>\n");
break;
} /* switch */
}

View file

@ -673,7 +673,6 @@ int cli_show_version(clicon_handle h,
*
* This callback can be used only in context of an autocli generated syntax tree, such as:
* show @datamodel, cli_show_auto();
*
* @param[in] h CLICON handle
* @param[in] state If set, show both config and state, otherwise only config
* @param[in] cvv Vector of variables from CLIgen command-line
@ -682,10 +681,15 @@ int cli_show_version(clicon_handle h,
* <api_path_fmt> Generated API PATH
* <dbname> "running"|"candidate"|"startup"
* <format> "text"|"xml"|"json"|"cli"|"netconf" (see format_enum)
* <prefix> to print before cli syntax output
* <pretty> true|false: pretty-print or not (Optional)
* <state> true|false: also print state
* <default> Retrieval default mode: report-all, trim, explicit, report-all-tagged,
* report-all-tagged-default, report-all-tagged-strip (Optional)
* <prefix> To print before cli syntax outptu
* @note if state parameter is set, then db must be running
* @note that first argument is generated by code.
* @see cli_show_config1
* XXX Merge with cli_auto_show
*/
static int
cli_show_auto1(clicon_handle h,
@ -707,9 +711,18 @@ cli_show_auto1(clicon_handle h,
char *api_path = NULL;
char *prefix = NULL;
int cvvi = 0;
cg_var *boolcv = NULL;
char *defaultstr = NULL; /* with extended tagged modes */
char *withdefaultstr = NULL; /* RFC 6243 modes */
int pretty = 1;
cxobj **vec = NULL;
size_t veclen;
int i;
yang_stmt *yp;
enum rfc_6020 ys_keyword;
if (cvec_len(argv) < 3 || cvec_len(argv) > 4){
clicon_err(OE_PLUGIN, EINVAL, "Usage: <api-path-fmt>* <database> <format> <prefix>. (*) generated.");
if (cvec_len(argv) < 3 || cvec_len(argv) > 7){
clicon_err(OE_PLUGIN, EINVAL, "Usage: <api-path-fmt>* <database> <format> [<pretty> <state> <default> <prefix>]. Number of args:%d", cvec_len(argv));
goto done;
}
/* First argv argument: API_path format */
@ -718,14 +731,50 @@ cli_show_auto1(clicon_handle h,
db = cv_string_get(cvec_i(argv, 1));
/* Third format: output format */
formatstr = cv_string_get(cvec_i(argv, 2));
if (cvec_len(argv) > 3){
/* Fourth format: prefix to print before cli syntax */
prefix = cv_string_get(cvec_i(argv, 3));
}
if ((int)(format = format_str2int(formatstr)) < 0){
clicon_err(OE_PLUGIN, 0, "Not valid format: %s", formatstr);
goto done;
}
if (cvec_len(argv) > 3){
/* Fourth: pretty-print */
if ((boolcv = cv_new(CGV_BOOL)) == NULL){
clicon_err(OE_UNIX, errno, "cv_new");
goto done;
}
if (cv_parse(cv_string_get(cvec_i(argv, 3)), boolcv) < 0){
clicon_err(OE_UNIX, errno, "Parse boolean %s", cv_string_get(cvec_i(argv, 3)));
goto done;
}
pretty = cv_bool_get(boolcv);
}
if (cvec_len(argv) > 4){
if (cv_parse(cv_string_get(cvec_i(argv, 4)), boolcv) < 0){
clicon_err(OE_UNIX, errno, "Parse boolean %s", cv_string_get(cvec_i(argv, 4)));
goto done;
}
state = cv_bool_get(boolcv);
}
if (cvec_len(argv) > 5){
defaultstr = cv_string_get(cvec_i(argv, 5));
/* From extended to RFC6243 withdefault modes */
if (strcmp(defaultstr, "report-all-tagged-strip") == 0)
withdefaultstr = "report-all-tagged";
else if (strcmp(defaultstr, "report-all-tagged-default") == 0)
withdefaultstr = "report-all-tagged";
else if (strcmp(defaultstr, "report-all") != 0 &&
strcmp(defaultstr, "trim") != 0 &&
strcmp(defaultstr, "explicit") != 0 &&
strcmp(defaultstr, "report-all-tagged") != 0){
clicon_err(OE_YANG, EINVAL, "Unexpected with-default option: %s", defaultstr);
goto done;
}
else
withdefaultstr = defaultstr;
}
if (cvec_len(argv) > 6){
/* Fourth format: prefix to print before cli syntax */
prefix = cv_string_get(cvec_i(argv, 6));
}
if ((yspec = clicon_dbspec_yang(h)) == NULL){
clicon_err(OE_FATAL, 0, "No DB_SPEC");
goto done;
@ -734,61 +783,104 @@ cli_show_auto1(clicon_handle h,
goto done;
if (api_path2xpath(api_path, yspec, &xpath, &nsc, NULL) < 0)
goto done;
if (xpath == NULL){
clicon_err(OE_FATAL, 0, "Invalid api-path-fmt: %s", api_path_fmt);
goto done;
}
/* XXX Kludge to overcome a trailing / in show, that I cannot add to
* yang2api_path_fmt_1 where it should belong.
*/
if (xpath[strlen(xpath)-1] == '/')
if (xpath && xpath[strlen(xpath)-1] == '/')
xpath[strlen(xpath)-1] = '\0';
if (state == 0){ /* Get configuration-only from database */
if (clicon_rpc_get_config(h, NULL, db, xpath, nsc, NULL, &xt) < 0)
goto done;
}
else{ /* Get configuration and state from database */
if (strcmp(db, "running") != 0){
if (state && strcmp(db, "running") != 0){
clicon_err(OE_FATAL, 0, "Show state only for running database, not %s", db);
goto done;
}
if (clicon_rpc_get(h, xpath, nsc, CONTENT_ALL, -1, NULL, &xt) < 0)
if (state == 0){ /* Get configuration-only from a database */
if (clicon_rpc_get_config(h, NULL, db, xpath, nsc, withdefaultstr, &xt) < 0)
goto done;
}
else { /* Get configuration and state from running */
if (clicon_rpc_get(h, xpath, nsc, CONTENT_ALL, -1, withdefaultstr, &xt) < 0)
goto done;
}
if ((xerr = xpath_first(xt, NULL, "/rpc-error")) != NULL){
clixon_netconf_error(xerr, "Get configuration", NULL);
goto done;
}
if ((xp = xpath_first(xt, nsc, "%s", xpath)) != NULL){
if (xpath_vec(xt, nsc, "%s", &vec, &veclen, xpath) < 0)
goto done;
if (veclen){
xp = vec[0]; /* First peek to see if it is special case yang list */
if ((yp = xml_spec(xp)) != NULL)
ys_keyword = yang_keyword_get(xml_spec(xp));
else
ys_keyword = 0;
/* Special case LIST */
if ((ys_keyword == Y_LIST || ys_keyword == Y_LEAF_LIST) && format == FORMAT_JSON){
switch (format){
case FORMAT_JSON:
if (xml2json_vec(stdout, vec, veclen, pretty) < 0) // XXX cligen_output
goto done;
break;
default:
break;
}
}
else /* Default */
for (i=0; i<veclen; i++){
xp = vec[i];
if ((yp = xml_spec(xp)) != NULL)
ys_keyword = yang_keyword_get(xml_spec(xp));
else
ys_keyword = 0;
/* Print configuration according to format */
switch (format){
case FORMAT_XML:
if (clixon_xml2file(stdout, xp, 0, pretty, cligen_output, 0, 1) < 0)
goto done;
if (!pretty && i == veclen-1)
cligen_output(stdout, "\n");
break;
case FORMAT_JSON:
if (clixon_json2file(stdout, xp, pretty, cligen_output, 0, 1) < 0)
goto done;
break;
case FORMAT_TEXT: /* XXX does not handle multiple leaf-list */
if (clixon_txt2file(stdout, xp, 0, cligen_output, 0, 1) < 0)
goto done;
break;
case FORMAT_CLI:
if (clixon_cli2file(h, stdout, xp, prefix, cligen_output, 0) < 0) /* cli syntax */
goto done;
break;
case FORMAT_NETCONF:
fprintf(stdout, "<rpc><edit-config><target><candidate/></target><config>\n");
if (clixon_xml2file(stdout, xp, 2, 1, fprintf, 0, 1) < 0)
goto done;
fprintf(stdout, "</config></edit-config></rpc>]]>]]>\n");
break;
case FORMAT_JSON:
if (clixon_json2file(stdout, xp, 1, cligen_output, 0, 1) < 0)
goto done;
break;
case FORMAT_TEXT:
if (clixon_txt2file(stdout, xp, 0, cligen_output, 0, 1) < 0)
goto done;
break;
case FORMAT_XML:
if (clixon_xml2file(stdout, xp, 0, 1, fprintf, 0, 1) < 0)
if (i==0){
cligen_output(stdout, "<rpc xmlns=\"%s\" %s><edit-config><target><candidate/></target><config>",
NETCONF_BASE_NAMESPACE, NETCONF_MESSAGE_ID_ATTR);
if (pretty)
cligen_output(stdout, "\n");
}
if (clixon_xml2file(stdout, xp, 2, pretty, cligen_output, 0, 1) < 0)
goto done;
if (i == veclen-1)
cligen_output(stdout, "</config></edit-config></rpc>]]>]]>\n");
break;
}
}
}
retval = 0;
done:
if (boolcv)
cv_free(boolcv);
if (nsc)
xml_nsctx_free(nsc);
if (api_path)
free(api_path);
if (vec)
free(vec);
if (xpath)
free(xpath);
if (xt)
@ -801,7 +893,11 @@ cli_show_auto1(clicon_handle h,
* <api_path_fmt> Generated API PATH
* <dbname> "running"|"candidate"|"startup"
* <format> "text"|"xml"|"json"|"cli"|"netconf" (see format_enum)
* <prefix> to print before cli syntax outptu
* <pretty> true|false: pretty-print or not (Optional)
* <state> true|false: also print state
* <default> Retrieval default mode: report-all, trim, explicit, report-all-tagged,
* report-all-tagged-default, report-all-tagged-strip (Optional)
* <prefix> To print before cli syntax outptu
* @see cli_show_auto_state For config and state
* @note SHOULD be used: ... @datamodel, cli_show_auto(<dbname>,...) to get correct #args
* @see cli_auto_show
@ -820,6 +916,9 @@ cli_show_auto(clicon_handle h,
* <api_path_fmt> Generated API PATH
* <dbname> "running"
* <format> "text"|"xml"|"json"|"cli"|"netconf" (see format_enum)
* <pretty> true|false: pretty-print or not (Optional)
* <default> Retrieval default mode: report-all, trim, explicit, report-all-tagged,
* report-all-tagged-default, report-all-tagged-strip (Optional)
* <prefix> to print before cli syntax output
* @see cli_show_auto For config only
* @see cli_show_config_state Not auto-generated

View file

@ -69,7 +69,13 @@ copy("Copy and create a new object") {
discard("Discard edits (rollback 0)"), discard_changes();
show("Show a particular state of the system"){
auto("Show expand") @datamodelshow, cli_show_auto("candidate", "xml");
auto("Show expand x"){
xml @datamodelshow, cli_show_auto("candidate", "xml", true, false, "report-all");
text @datamodelshow, cli_show_auto("candidate", "text", true, false, "report-all");
json @datamodelshow, cli_show_auto("candidate", "json", true, false, "report-all");
netconf @datamodelshow, cli_show_auto("candidate", "netconf", true, false, "report-all");
cli @datamodelshow, cli_show_auto("candidate", "cli", true, false, "report-all", "set ");
}
xpath("Show configuration") <xpath:string>("XPATH expression")
[<ns:string>("Namespace")], show_conf_xpath("candidate");
version("Show version"), cli_show_version("candidate", "text", "/");

View file

@ -149,9 +149,9 @@ merge @datamodel, cli_merge();
create @datamodel, cli_create();
delete @datamodel, cli_del();
show config, cli_show_config("candidate", "cli", "/", 0, "set ");
show config @datamodel, cli_show_auto("candidate", "cli", "set ");
show config @datamodel, cli_show_auto("candidate", "cli", true, false, "report-all", "set ");
show state, cli_show_config_state("running", "cli", "/", "set ");
show state @datamodelstate, cli_show_auto_state("running", "cli", "set ");
show state @datamodelstate, cli_show_auto_state("running", "cli", true, true, "report-all", "set ");
show xml, cli_show_config("candidate", "xml", "/");
show xml @datamodel, cli_show_auto("candidate", "xml");
commit, cli_commit();

232
test/test_autocli_show.sh Executable file
View file

@ -0,0 +1,232 @@
#!/usr/bin/env bash
# Autocli show tests
# Go through all formats and show for all formats
# 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
clidir=$dir/cli
fyang=$dir/clixon-example.yang
formatdir=$dir/format
test -d ${formatdir} || rm -rf ${formatdir}
mkdir $formatdir
test -d ${clidir} || rm -rf ${clidir}
mkdir $clidir
# Use yang in example
cat <<EOF > $cfg
<clixon-config xmlns="http://clicon.org/config">
<CLICON_FEATURE>ietf-netconf:startup</CLICON_FEATURE>
<CLICON_CONFIGFILE>$cfg</CLICON_CONFIGFILE>
<CLICON_YANG_DIR>${YANG_INSTALLDIR}</CLICON_YANG_DIR>
<CLICON_YANG_DIR>$IETFRFC</CLICON_YANG_DIR>
<CLICON_YANG_MAIN_DIR>$dir</CLICON_YANG_MAIN_DIR>
<CLICON_BACKEND_DIR>/usr/local/lib/$APPNAME/backend</CLICON_BACKEND_DIR>
<CLICON_CLI_MODE>$APPNAME</CLICON_CLI_MODE>
<CLICON_CLI_DIR>/usr/local/lib/$APPNAME/cli</CLICON_CLI_DIR>
<CLICON_CLISPEC_DIR>$clidir</CLICON_CLISPEC_DIR>
<CLICON_SOCK>/usr/local/var/$APPNAME/$APPNAME.sock</CLICON_SOCK>
<CLICON_BACKEND_PIDFILE>/usr/local/var/$APPNAME/$APPNAME.pidfile</CLICON_BACKEND_PIDFILE>
<CLICON_XMLDB_DIR>/usr/local/var/$APPNAME</CLICON_XMLDB_DIR>
</clixon-config>
EOF
cat <<EOF > $fyang
module clixon-example {
yang-version 1.1;
namespace "urn:example:clixon";
prefix ex;
/* Generic config data */
container table{
list parameter{
key name;
leaf name{
type string;
}
leaf value{
type string;
}
leaf-list array1{
type string;
}
}
}
}
EOF
cat <<EOF > $clidir/ex.cli
# Clixon example specification
CLICON_MODE="example";
CLICON_PROMPT="%U@%H %W> ";
CLICON_PLUGIN="example_cli";
set @datamodel, cli_auto_set();
delete("Delete a configuration item") {
@datamodel, cli_auto_del();
all("Delete whole candidate configuration"), delete_all("candidate");
}
validate("Validate changes"), cli_validate();
commit("Commit the changes"), cli_commit();
quit("Quit"), cli_quit();
discard("Discard edits (rollback 0)"), discard_changes();
show("Show a particular state of the system"){
configuration("Show configuration"){
xml("Show configuration as XML"), cli_auto_show("datamodel", "candidate", "xml", false, false);
json("Show configuration as JSON"), cli_auto_show("datamodel", "candidate", "json", false, false);
text("Show configuration as TEXT"), cli_auto_show("datamodel", "candidate", "text", false, false);
cli("Show configuration as CLI commands"), cli_auto_show("datamodel", "candidate", "cli", false, false, "report-all", "set ");
netconf("Show configuration as NETCONF"), cli_auto_show("datamodel", "candidate", "netconf", false, false);
}
auto("Show auto") {
xml("Show configuration as XML") @datamodelshow, cli_show_auto("candidate", "xml", false, false, "report-all");
json("Show configuration as JSON") @datamodelshow, cli_show_auto("candidate", "json", false, false, "report-all");
text("Show configuration as TEXT")@datamodelshow, cli_show_auto("candidate", "text", false, false, "report-all");
cli("Show configuration as CLI commands") @datamodelshow, cli_show_auto("candidate", "cli", false, false, "report-all", "set ");
netconf("Show configuration as NETCONF")@datamodelshow, cli_show_auto("candidate", "netconf", false, false, "report-all");
}
}
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
# Create two lists
new "cli create list table x"
expectpart "$($clixon_cli -1 -f $cfg -l o set table parameter x value 1)" 0 "^$"
new "cli create list table y"
expectpart "$($clixon_cli -1 -f $cfg -l o set table parameter y value 2)" 0 "^$"
# Create two leaf-lists
new "cli create leaflist array1 a"
expectpart "$($clixon_cli -1 -f $cfg -l o set table parameter x array1 a)" 0 "^$"
new "cli create leaflist array1 b"
expectpart "$($clixon_cli -1 -f $cfg -l o set table parameter x array1 b)" 0 "^$"
new "cli commit"
expectpart "$($clixon_cli -1 -f $cfg -l o commit)" 0 "^$"
# XML
format=xml
new "cli check show config $format"
X='<table xmlns="urn:example:clixon"><parameter><name>x</name><value>1</value><array1>a</array1><array1>b</array1></parameter><parameter><name>y</name><value>2</value></parameter></table>'
expectpart "$($clixon_cli -1 -f $cfg -l o show config $format)" 0 "^$X$"
new "cli check show auto $format table"
expectpart "$($clixon_cli -1 -f $cfg -l o show auto $format table)" 0 "^$X$"
new "cli check show auto $format table parameter"
X='<parameter><name>x</name><value>1</value><array1>a</array1><array1>b</array1></parameter><parameter><name>y</name><value>2</value></parameter>'
expectpart "$($clixon_cli -1 -f $cfg -l o show auto $format table parameter)" 0 "^$X$"
new "cli check show auto $format table parameter x"
X='<parameter><name>x</name><value>1</value><array1>a</array1><array1>b</array1></parameter>'
expectpart "$($clixon_cli -1 -f $cfg -l o show auto $format table parameter x)" 0 "^$X$"
new "cli check show auto $format table parameter x array1"
X='<array1>a</array1><array1>b</array1>'
expectpart "$($clixon_cli -1 -f $cfg -l o show auto $format table parameter x array1)" 0 "^$X$"
# JSON
format=json
new "cli check show config $format"
X='{"clixon-example:table":{"parameter":\[{"name":"x","value":"1","array1":\["a","b"\]},{"name":"y","value":"2"}\]}}'
expectpart "$($clixon_cli -1 -f $cfg -l o show config $format)" 0 "^$X$"
new "cli check show auto $format table"
expectpart "$($clixon_cli -1 -f $cfg -l o show auto $format table)" 0 "^$X$"
new "cli check show auto $format table parameter"
X='{"clixon-example:parameter":\[{"name":"x","value":"1","array1":\["a","b"\]},{"name":"y","value":"2"}\]}'
expectpart "$($clixon_cli -1 -f $cfg -l o show auto $format table parameter)" 0 "^$X$"
new "cli check show auto $format table parameter x"
X='{"clixon-example:parameter":\[{"name":"x","value":"1","array1":\["a","b"\]}\]}'
expectpart "$($clixon_cli -1 -f $cfg -l o show auto $format table parameter x)" 0 "^$X$"
new "cli check show auto $format table parameter x array1"
X='{"clixon-example:array1":\["a","b"\]}'
expectpart "$($clixon_cli -1 -f $cfg -l o show auto $format table parameter x array1)" 0 "^$X$"
# TEXT
format=text
new "cli check show config $format"
expectpart "$($clixon_cli -1 -f $cfg -l o show config $format)" 0 "clixon-example:table {" "parameter x {" "array1 \[" "parameter y {"
new "cli check show auto $format table"
expectpart "$($clixon_cli -1 -f $cfg -l o show auto $format table)" 0
new "cli check show auto $format table parameter"
expectpart "$($clixon_cli -1 -f $cfg -l o show auto $format table parameter)" 0 "parameter x {" "array1 \[" "parameter y {" --not-- "clixon-example:table {"
new "cli check show auto $format table parameter x"
expectpart "$($clixon_cli -1 -f $cfg -l o show auto $format table parameter x)" 0 "parameter x {" "array1 \[" --not-- "clixon-example:table {" "parameter y {"
# XXX prints two [] lists, should only print one
new "cli check show auto $format table parameter x array1"
expectpart "$($clixon_cli -1 -f $cfg -l o show auto $format table parameter x array1)" 0 "array1 \[" --not-- "clixon-example:table {" "parameter y {" "parameter x {"
# CLI
format=cli
new "cli check show config $format"
expectpart "$($clixon_cli -1 -f $cfg -l o show config $format)" 0 "set table parameter x" "set table parameter x value 1" "set table parameter x array1 a" "set table parameter x array1 b" "set table parameter y" "set table parameter y value 2"
new "cli check show auto $format table"
expectpart "$($clixon_cli -1 -f $cfg -l o show auto $format table)" 0 "set table parameter x" "set table parameter x value 1" "set table parameter x array1 a" "set table parameter x array1 b" "set table parameter y" "set table parameter y value 2"
# XXX rest does not print whole CLI path to root, eg does not include "table"
# NETCONF
format=netconf
# XXX netconf base capability 0, EOM framing
new "cli check show config $format"
X='<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="42"><edit-config><target><candidate/></target><config><table xmlns="urn:example:clixon"><parameter><name>x</name><value>1</value><array1>a</array1><array1>b</array1></parameter><parameter><name>y</name><value>2</value></parameter></table></config></edit-config></rpc>]]>]]>'
expectpart "$($clixon_cli -1 -f $cfg -l o show config $format)" 0 "^$X$"
new "cli check show auto $format table"
expectpart "$($clixon_cli -1 -f $cfg -l o show auto $format table)" 0 "^$X$"
# XXX rest does not print whole NETCONF path to root, eg does not include "table"
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

View file

@ -111,9 +111,9 @@ CLICON_MODE="example";
CLICON_PROMPT="%U@%H> ";
show {
base @datamodel, cli_show_auto_state("running", "cli", "set ");
add-nonconfig @datamodelstate, cli_show_auto_state("running", "cli", "set ");
add-show @datamodelshow, cli_show_auto_state("running", "cli", "set ");
base @datamodel, cli_show_auto_state("running", "cli", true, false, "report-all","set ");
add-nonconfig @datamodelstate, cli_show_auto_state("running", "cli", true, false, "report-all","set ");
add-show @datamodelshow, cli_show_auto_state("running", "cli", true, false, "report-all","set ");
}
auto {

View file

@ -92,7 +92,7 @@ validate("Validate changes"), cli_validate();
commit("Commit the changes"), cli_commit();
quit("Quit"), cli_quit();
show("Show a particular state of the system"){
auto("Show expand") @datamodel, cli_show_auto("running", "xml", "set");
auto("Show expand") @datamodel, cli_show_auto("running", "xml");
candidate("Show configuration"), cli_auto_show("datamodel", "candidate", "xml", false, false);
running("Show configuration"), cli_auto_show("datamodel", "running", "xml", false, false);
}

View file

@ -60,10 +60,6 @@ module clixon-example {
leaf-list array1{
type string;
}
/* leaf-list array2{
type string;
}
*/
}
}
}
@ -109,8 +105,8 @@ show("Show a particular state of the system"){
}
configuration("Show configuration"), cli_auto_show("datamodel", "candidate", "text", true, false);{
cli("Show configuration as CLI commands"), cli_auto_show("datamodel", "candidate", "cli", true, false, "report-all", "set ");
xml("Show configuration as XML"), cli_auto_show("datamodel", "candidate", "xml", true, false, "set ");
text("Show configuration as TEXT"), cli_auto_show("datamodel", "candidate", "text", true, false, "set ");
xml("Show configuration as XML"), cli_auto_show("datamodel", "candidate", "xml", true, false);
text("Show configuration as TEXT"), cli_auto_show("datamodel", "candidate", "text", true, false);
}
}
save("Save candidate configuration to XML file") <filename:string>("Filename (local filename)"), save_config_file("candidate","filename", "xml"){