Refactor of cli show commands:

- Changed `cli_show_config()`
- Removed `cli_show_config_state()`
- Replaced `cli_auto_show()` with `cli_show_auto_mode()`
This commit is contained in:
Olof hagsand 2022-09-15 17:42:57 +02:00
parent 9a224ea4a0
commit a6f67755b3
32 changed files with 706 additions and 746 deletions

View file

@ -80,14 +80,14 @@ validate("Validate changes"), cli_validate();
commit("Commit the changes"), cli_commit();
quit("Quit"), cli_quit();
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);
cli("Show configuration as CLI commands"), cli_auto_show("datamodel", "candidate", "cli", false, false, "report-all", "set ");
netconf("Show configuration as netconf edit-config operation"), cli_auto_show("datamodel", "candidate", "netconf", false, false);
text("Show configuration as text"), cli_auto_show("datamodel", "candidate", "text", false, false);
json("Show configuration as JSON"), cli_auto_show("datamodel", "candidate", "json", false, false);
configuration("Show configuration"), cli_show_auto_mode("candidate", "text", true, false);{
xml("Show configuration as XML"), cli_show_auto_mode("candidate", "xml", false, false);
cli("Show configuration as CLI commands"), cli_show_auto_mode("candidate", "cli", false, false, "report-all", "set ");
netconf("Show configuration as netconf edit-config operation"), cli_show_auto_mode("candidate", "netconf", false, false);
text("Show configuration as text"), cli_show_auto_mode("candidate", "text", false, false);
json("Show configuration as JSON"), cli_show_auto_mode("candidate", "json", false, false);
}
state("Show configuration and state"), cli_auto_show("datamodel", "running", "xml", false, true);
state("Show configuration and state"), cli_show_auto_mode("running", "xml", false, true);
}
EOF

View file

@ -61,8 +61,8 @@ delete("Delete a configuration item") {
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);
configuration("Show configuration"), cli_show_auto_mode("candidate", "text", true, false);{
xml("Show configuration as XML"), cli_show_auto_mode("candidate", "xml", false, false);
}
}
EOF

View file

@ -148,11 +148,13 @@ set @datamodel, cli_set();
merge @datamodel, cli_merge();
create @datamodel, cli_create();
delete @datamodel, cli_del();
show config, cli_show_config("candidate", "cli", "/", 0, "set ");
show config, cli_show_config("candidate", "cli", "/", NULL, true, false, NULL,"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", true, true, "report-all", "set ");
show xml, cli_show_config("candidate", "xml", "/");
show state, cli_show_auto_mode("running", "cli", true, true, NULL, "set ");
show state @datamodelstate, cli_show_auto("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();
discard, discard_changes();
@ -267,7 +269,6 @@ function testrun()
fi
new "set a"
echo "$clixon_cli -1 -f $cfg set$table parameter$name a value x"
expectpart "$($clixon_cli -1 -f $cfg set$table parameter$name a value x)" 0 ""
new "set b"

View file

@ -80,18 +80,18 @@ 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);
xml("Show configuration as XML"), cli_show_auto_mode("candidate", "xml", false, false);
json("Show configuration as JSON"), cli_show_auto_mode("candidate", "json", false, false);
text("Show configuration as TEXT"), cli_show_auto_mode("candidate", "text", false, false);
cli("Show configuration as CLI commands"), cli_show_auto_mode("candidate", "cli", false, false, NULL, "set ");
netconf("Show configuration as NETCONF"), cli_show_auto_mode("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");
xml("Show configuration as XML") @datamodelshow, cli_show_auto("candidate", "xml", false, false, NULL);
json("Show configuration as JSON") @datamodelshow, cli_show_auto("candidate", "json", false, false, NULL);
text("Show configuration as TEXT")@datamodelshow, cli_show_auto("candidate", "text", false, false, NULL);
cli("Show configuration as CLI commands") @datamodelshow, cli_show_auto("candidate", "cli", false, false, NULL, "set ");
netconf("Show configuration as NETCONF")@datamodelshow, cli_show_auto("candidate", "netconf", false, false, NULL);
}
}
EOF

View file

@ -79,14 +79,14 @@ validate("Validate changes"), cli_validate();
commit("Commit the changes"), cli_commit();
quit("Quit"), cli_quit();
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);
cli("Show configuration as CLI commands"), cli_auto_show("datamodel", "candidate", "cli", false, false, "report-all", "set ");
netconf("Show configuration as netconf edit-config operation"), cli_auto_show("datamodel", "candidate", "netconf", false, false);
text("Show configuration as text"), cli_auto_show("datamodel", "candidate", "text", false, false);
json("Show configuration as JSON"), cli_auto_show("datamodel", "candidate", "json", false, false);
configuration("Show configuration"), cli_show_auto_mode("candidate", "text", true, false);{
xml("Show configuration as XML"), cli_show_auto_mode("candidate", "xml", false, false);
cli("Show configuration as CLI commands"), cli_show_auto_mode("candidate", "cli", false, false, "report-all", "set ");
netconf("Show configuration as netconf edit-config operation"), cli_show_auto_mode("candidate", "netconf", false, false);
text("Show configuration as text"), cli_show_auto_mode("candidate", "text", false, false);
json("Show configuration as JSON"), cli_show_auto_mode("candidate", "json", false, false);
}
state("Show configuration and state"), cli_auto_show("datamodel", "running", "xml", false, true);
state("Show configuration and state"), cli_show_auto_mode("running", "xml", false, true);
}
EOF

View file

@ -57,7 +57,7 @@ delete("Delete a configuration item") {
all("Delete whole candidate configuration"), delete_all("candidate");
}
show("Show a particular state of the system")
configuration("Show configuration"), cli_auto_show("datamodel", "candidate", "xml", false, false);
configuration("Show configuration"), cli_show_auto_mode("candidate", "xml", false, false);
EOF
# Yang specs must be here first for backend. But then the specs are changed but just for CLI

View file

@ -92,8 +92,8 @@ delete("Delete a configuration item") {
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);
configuration("Show configuration"), cli_show_auto_mode("candidate", "text", true, false);{
xml("Show configuration as XML"), cli_show_auto_mode("candidate", "xml", false, false);
}
}
EOF

View file

@ -111,14 +111,14 @@ CLICON_MODE="example";
CLICON_PROMPT="%U@%H> ";
show {
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 ");
base @datamodel, cli_show_auto("running", "cli", true, true, "report-all","set ");
add-nonconfig @datamodelstate, cli_show_auto("running", "cli", true, true, "report-all","set ");
add-show @datamodelshow, cli_show_auto("running", "cli", true, true, "report-all","set ");
}
auto {
set @datamodel, cli_auto_set();
show, cli_auto_show("datamodel", "candidate", "text", true, false);
show, cli_show_auto_mode("candidate", "text", true, false);
}
EOF

View file

@ -200,9 +200,9 @@ quit("Quit"), cli_quit();
discard("Discard edits (rollback 0)"), discard_changes();
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, NULL);
configuration("Show configuration"), cli_show_auto_mode("candidate", "text", true, false);{
cli("Show configuration as CLI commands"), cli_show_auto_mode("candidate", "cli", true, false, "report-all", "set ");
xml("Show configuration as XML"), cli_show_auto_mode("candidate", "xml", true, false, NULL);
}
}
EOF

View file

@ -96,7 +96,7 @@ quit("Quit"), cli_quit();
discard("Discard edits (rollback 0)"), discard_changes();
show("Show a particular state of the system"){
configuration("Show configuration"), cli_auto_show("datamodel", "candidate", "xml", false, false);
configuration("Show configuration"), cli_show_auto_mode("candidate", "xml", false, false);
}
EOF

View file

@ -133,10 +133,10 @@ show("Show a particular state of the system"){
xml("Show comparison in xml"), compare_dbs((int32)0);
text("Show comparison in text"), compare_dbs((int32)1);
}
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);
text("Show configuration as TEXT"), cli_auto_show("datamodel", "candidate", "text", true, false);
configuration("Show configuration"), cli_show_auto_mode("candidate", "text", true, false);{
cli("Show configuration as CLI commands"), cli_show_auto_mode("candidate", "cli", true, false, "report-all", "set ");
xml("Show configuration as XML"), cli_show_auto_mode("candidate", "xml", true, false);
text("Show configuration as TEXT"), cli_show_auto_mode("candidate", "text", true, false);
}
}
save("Save candidate configuration to XML file") <filename:string>("Filename (local filename)"), save_config_file("candidate","filename", "xml"){

View file

@ -93,7 +93,7 @@ validate("Validate changes"), cli_validate();
commit("Commit the changes"), cli_commit();
quit("Quit"), cli_quit();
show("Show a particular state of the system")
configuration("Show configuration"), cli_auto_show("datamodel", "candidate", "text", true, false);
configuration("Show configuration"), cli_show_auto_mode("candidate", "text", true, false);
@extra;
EOF

View file

@ -71,8 +71,8 @@ delete("Delete a configuration item") {
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);
configuration("Show configuration"), cli_show_auto_mode("candidate", "text", true, false);{
xml("Show configuration as XML"), cli_show_auto_mode("candidate", "xml", false, false);
}
}
EOF

View file

@ -166,8 +166,8 @@ delete("Delete a configuration item") {
}
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 ");
configuration("Show configuration"), cli_show_auto_mode("candidate", "text", true, false);{
cli("Show configuration as CLI commands"), cli_show_auto_mode("candidate", "cli", true, false, "report-all", "set ");
}
}
validate("Validate changes"), cli_validate();

View file

@ -51,7 +51,7 @@ cat <<EOF > $clidir/cli1.cli
( <desc:rest>
| <desc:rest expand_dbvar("candidate","/clixon-example:description")> ),
cli_set("/clixon-example:description");
show configuration("Show configuration"), cli_auto_show("datamodel", "candidate", "xml", false, false);
show configuration("Show configuration"), cli_show_auto_mode("candidate", "xml", false, false);
EOF
new "test params: -f $cfg"

View file

@ -62,7 +62,7 @@ CLICON_PLUGIN="example_cli";
translate <value:string translate:cli_incstr()>, cli_set("/clixon-example:table/parameter=translate/value");
show("Show a particular state of the system"){
configuration("Show configuration"), cli_auto_show("datamodel", "candidate", "xml", false, false);
configuration("Show configuration"), cli_show_auto_mode("candidate", "xml", false, false);
}
validate("Validate changes"), cli_validate();
commit("Commit the changes"), cli_commit();

View file

@ -93,8 +93,8 @@ 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");
candidate("Show configuration"), cli_auto_show("datamodel", "candidate", "xml", false, false);
running("Show configuration"), cli_auto_show("datamodel", "running", "xml", false, false);
candidate("Show configuration"), cli_show_auto_mode("candidate", "xml", false, false);
running("Show configuration"), cli_show_auto_mode("running", "xml", false, false);
}
EOF

View file

@ -103,10 +103,10 @@ show("Show a particular state of the system"){
xml("Show comparison in xml"), compare_dbs((int32)0);
text("Show comparison in text"), compare_dbs((int32)1);
}
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);
text("Show configuration as TEXT"), cli_auto_show("datamodel", "candidate", "text", true, false);
configuration("Show configuration"), cli_show_auto_mode("candidate", "text", true, false);{
cli("Show configuration as CLI commands"), cli_show_auto_mode("candidate", "cli", true, false, "report-all", "set ");
xml("Show configuration as XML"), cli_show_auto_mode("candidate", "xml", true, false);
text("Show configuration as TEXT"), cli_show_auto_mode("candidate", "text", true, false);
}
}
save("Save candidate configuration to XML file") <filename:string>("Filename (local filename)"), save_config_file("candidate","filename", "xml"){

View file

@ -82,7 +82,7 @@ save("Save candidate configuration to XML file") <filename:string>("Filename (lo
json("Save configuration as JSON"), save_config_file("candidate","filename", "json");
}
show("Show a particular state of the system")
configuration("Show configuration"), cli_auto_show("datamodel", "candidate", "xml", false, false);
configuration("Show configuration"), cli_show_auto_mode("candidate", "xml", false, false);
quit("Quit"), cli_quit();
EOF

View file

@ -90,7 +90,7 @@ validate("Validate changes"), cli_validate();
commit("Commit the changes"), cli_commit();
quit("Quit"), cli_quit();
show("Show a particular state of the system")
configuration("Show configuration"), cli_show_config("candidate", "text", "/");
configuration("Show configuration"), cli_show_config("candidate", "text");
EOF

View file

@ -70,10 +70,7 @@ new "test params: -y $fyang"
testrun "top one leaf-list" '{"json:l1":[1]}' '<l1 xmlns="urn:example:clixon">1</l1>'
# XXX There is a problem with how clixon shows json and xml on top-level
# Typically, there is a loop over xml children to cope with the case if there is more
# than one top-level which is invalid in XML.
# See for example clixon_util_xml.c, clixon_util_json.c, cli_auto_show, cli_show_config
#testrun "top two leaf-list" '{"json:l1":[1,2]}' '<l1 xmlns="urn:example:clixon">1</l1><l1 xmlns="urn:example:clixon">2</l1>'
testrun "one leaf-list" '{"json:c":{"l1":[1]}}' '<c xmlns="urn:example:clixon"><l1>1</l1></c>'

View file

@ -100,7 +100,7 @@ save("Save candidate configuration to XML file") <filename:string>("Filename (lo
cli("Save configuration as CLI commands"), save_config_file("candidate","filename", "cli");
}
show("Show a particular state of the system"){
configuration("Show configuration"), cli_auto_show("datamodel", "candidate", "xml", false, false);
configuration("Show configuration"), cli_show_auto_mode("candidate", "xml", false, false);
version("Show version"), cli_show_version("candidate", "text", "/");
}
validate("Validate changes"), cli_validate();

View file

@ -213,14 +213,14 @@ validate("Validate changes"), cli_validate();
commit("Commit the changes"), cli_commit();
quit("Quit"), cli_quit();
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", true, false);
cli("Show configuration as CLI commands"), cli_auto_show("datamodel", "candidate", "cli", false, false, "report-all", "set ");
netconf("Show configuration as netconf edit-config operation"), cli_auto_show("datamodel", "candidate", "netconf", false, false);
text("Show configuration as text"), cli_auto_show("datamodel", "candidate", "text", false, false);
json("Show configuration as JSON"), cli_auto_show("datamodel", "candidate", "json", false, false);
configuration("Show configuration"), cli_show_auto_mode("candidate", "text", true, false);{
xml("Show configuration as XML"), cli_show_auto_mode("candidate", "xml", true, false);
cli("Show configuration as CLI commands"), cli_show_auto_mode("candidate", "cli", false, false, "report-all", "set ");
netconf("Show configuration as netconf edit-config operation"), cli_show_auto_mode("candidate", "netconf", false, false);
text("Show configuration as text"), cli_show_auto_mode("candidate", "text", false, false);
json("Show configuration as JSON"), cli_show_auto_mode("candidate", "json", false, false);
}
state("Show configuration and state"), cli_auto_show("datamodel", "running", "xml", false, true);
state("Show configuration and state"), cli_show_auto_mode("running", "xml", false, true);
}
EOF
@ -334,8 +334,8 @@ if [ $t -lt 2 -o $t -gt 4 ]; then
fi
t0=$(date +"%s")
new "Send GET and try idle-timeout, client keeps socket open"
expectpart "$(${clixon_restconf_callhome_client} -o -t 30 -p 8336 -D $DBG -f $frequest -a 127.0.0.1 -c $srvcert -k $srvkey -C $cacert -n 1)" 0 "HTTP/$HVERCH 200" "OK 1" $expectreply "Close 1 remote" --not-- "OK 2" "Close 2"
new "Send GET: idle-timeout, client keeps socket open, server closes"
expectpart "$(${clixon_restconf_callhome_client} -o -t 60 -p 8336 -D $DBG -f $frequest -a 127.0.0.1 -c $srvcert -k $srvkey -C $cacert -n 1)" 0 "HTTP/$HVERCH 200" "OK 1" $expectreply "Close 1 remote" --not-- "OK 2" "Close 2"
t1=$(date +"%s")
let t=t1-t0

View file

@ -164,7 +164,7 @@ cat <<EOF > $dclispec/clispec.cli
set @datamodel, cli_set();
merge @datamodel, cli_merge();
create @datamodel, cli_create();
show, cli_show_config("candidate", "text", "/");
show, cli_show_config("candidate", "text");
quit("Quit"), cli_quit();
EOF

View file

@ -153,7 +153,7 @@ set @datamodel, cli_set();
commit("Commit the changes"), cli_commit();
quit("Quit"), cli_quit();
show("Show a particular state of the system"){
configuration("Show configuration"), cli_show_config("candidate", "text", "/");
configuration("Show configuration"), cli_show_config("candidate", "text");
version("Show version"), cli_show_version("candidate", "text", "/");
xpath("Show configuration") <xpath:string>("XPATH expression") <ns:string>("Namespace"), show_conf_xpath("candidate");
yang("Show yang specs"), show_yang(); {

View file

@ -58,8 +58,8 @@ delete("Delete a configuration item") {
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);
configuration("Show configuration"), cli_show_auto_mode("candidate", "text", true, false);{
xml("Show configuration as XML"), cli_show_auto_mode("candidate", "xml", false, false);
}
}
validate("Validate changes"), cli_validate();

View file

@ -131,22 +131,22 @@ show("Show a particular state of the system"){
configuration("Show configuration")
xml("Show configuration and state as XML")
default("With-default mode"){
report-all, cli_auto_show("datamodel", "candidate", "xml", false, false, "report-all");
trim, cli_auto_show("datamodel", "candidate", "xml", false, false, "trim");
explicit, cli_auto_show("datamodel", "candidate", "xml", false, false, "explicit");
report-all-tagged, cli_auto_show("datamodel", "candidate", "xml", false, false, "report-all-tagged");
report-all-tagged-default, cli_auto_show("datamodel", "candidate", "xml", false, false, "report-all-tagged-default");
report-all-tagged-strip, cli_auto_show("datamodel", "candidate", "xml", false, false, "report-all-tagged-strip");
report-all, cli_show_auto_mode("candidate", "xml", false, false, "report-all");
trim, cli_show_auto_mode("candidate", "xml", false, false, "trim");
explicit, cli_show_auto_mode("candidate", "xml", false, false, "explicit");
report-all-tagged, cli_show_auto_mode("candidate", "xml", false, false, "report-all-tagged");
report-all-tagged-default, cli_show_auto_mode("candidate", "xml", false, false, "report-all-tagged-default");
report-all-tagged-strip, cli_show_auto_mode("candidate", "xml", false, false, "report-all-tagged-strip");
}
state("Show configuration and state")
xml("Show configuration and state as XML")
default("With-default mode"){
report-all, cli_auto_show("datamodel", "running", "xml", false, true, "report-all");
trim, cli_auto_show("datamodel", "running", "xml", false, true, "trim");
explicit, cli_auto_show("datamodel", "running", "xml", false, true, "explicit");
report-all-tagged, cli_auto_show("datamodel", "running", "xml", false, true, "report-all-tagged");
report-all-tagged-default, cli_auto_show("datamodel", "running", "xml", false, true, "report-all-tagged-default");
report-all-tagged-strip, cli_auto_show("datamodel", "running", "xml", false, true, "report-all-tagged-strip");
report-all, cli_show_auto_mode("running", "xml", false, true, "report-all");
trim, cli_show_auto_mode("running", "xml", false, true, "trim");
explicit, cli_show_auto_mode("running", "xml", false, true, "explicit");
report-all-tagged, cli_show_auto_mode("running", "xml", false, true, "report-all-tagged");
report-all-tagged-default, cli_show_auto_mode("running", "xml", false, true, "report-all-tagged-default");
report-all-tagged-strip, cli_show_auto_mode("running", "xml", false, true, "report-all-tagged-strip");
}
}
EOF