* Changed autocli tree-labels using ac_ and act_ prefixes

* New automatic edit-mode design
   * Control which modes to use with `edit-mode-default`
     * Default is create edit-mode for all
   * New edit-mode tree: @datamodelmode
This commit is contained in:
Olof hagsand 2022-01-18 10:12:15 +01:00
parent 9b99d63411
commit f922211212
11 changed files with 382 additions and 158 deletions

View file

@ -6,6 +6,8 @@ s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
APPNAME=example
LEAFMODE=false # XXX NYI
# include err() and new() functions and creates $dir
cfg=$dir/conf_yang.xml
@ -14,6 +16,9 @@ fin=$dir/in
fstate=$dir/state.xml
fyang=$dir/clixon-example.yang
# Generate autocli for these modules
AUTOCLI=$(autocli_config clixon-example kw-nokey false)
# Use yang in example
cat <<EOF > $cfg
<clixon-config xmlns="http://clicon.org/config">
@ -29,6 +34,7 @@ cat <<EOF > $cfg
<CLICON_BACKEND_PIDFILE>/usr/local/var/$APPNAME/$APPNAME.pidfile</CLICON_BACKEND_PIDFILE>
<CLICON_XMLDB_DIR>$dir</CLICON_XMLDB_DIR>
<CLICON_XMLDB_PRETTY>false</CLICON_XMLDB_PRETTY>
${AUTOCLI}
</clixon-config>
EOF
@ -63,7 +69,7 @@ CLICON_PROMPT="%U@%H %W> ";
CLICON_PLUGIN="example_cli";
# Autocli syntax tree operations
edit @datamodelshow, cli_auto_edit("basemodel");
edit @datamodelmode, cli_auto_edit("basemodel");
up, cli_auto_up("basemodel");
top, cli_auto_top("basemodel");
set @datamodel, cli_auto_set();
@ -145,6 +151,7 @@ EOF
new "edit table parameter a; show"
expectpart "$(cat $fin | $clixon_cli -f $cfg 2>&1)" 0 "/clixon-example:table/parameter=a/>" "<name>a</name><value>42</value>" --not-- '<table xmlns="urn:example:clixon">' "<parameter>"
if $LEAFMODE; then
cat <<EOF > $fin
edit table
edit parameter
@ -153,6 +160,7 @@ show config xml
EOF
new "edit table; edit parameter; edit a; show"
expectpart "$(cat $fin | $clixon_cli -f $cfg 2>&1)" 0 "<name>a</name><value>42</value>" --not-- '<table xmlns="urn:example:clixon">' "<parameter>"
fi
cat <<EOF > $fin
edit table
@ -162,12 +170,14 @@ EOF
new "edit table; edit parameter a; show"
expectpart "$(cat $fin | $clixon_cli -f $cfg 2>&1)" 0 "<name>a</name><value>42</value>" --not-- '<table xmlns="urn:example:clixon">' "<parameter>"
if $LEAFMODE; then
cat <<EOF > $fin
edit table parameter a value 42
show config xml
EOF
new "edit table parameter a value 42; show"
expectpart "$(cat $fin | $clixon_cli -f $cfg 2>&1)" 0 --not-- '<table xmlns="urn:example:clixon">' "<parameter>" "<name>a</name>" "<value>42</value>"
fi
# edit -> top
cat <<EOF > $fin
@ -196,6 +206,7 @@ EOF
new "edit table; up; show"
expectpart "$(cat $fin | $clixon_cli -f $cfg 2>&1)" 0 '<table xmlns="urn:example:clixon"><parameter><name>a</name><value>42</value></parameter></table>$'
if $LEAFMODE; then
cat <<EOF > $fin
edit table parameter a
up
@ -203,6 +214,7 @@ show config xml
EOF
new "edit table parameter a; up; show"
expectpart "$(cat $fin | $clixon_cli -f $cfg 2>&1)" 0 "/clixon-example:table>" "<parameter><name>a</name><value>42</value></parameter>$" --not-- '<table xmlns="urn:example:clixon">'
fi
cat <<EOF > $fin
edit table parameter a

View file

@ -160,7 +160,7 @@ EOF
# Set config for CLI
# 1. listkw - either none, vars, all
# 2 compress - surrounding container entities are removed from list nodes
# 2. compress - surrounding container entities are removed from list nodes
# 3. openconfig - config and state containers are "compressed" out of the schema in openconfig modules
function setconfig()
{
@ -245,20 +245,14 @@ fi
new "wait backend"
wait_backend
# Simple run trying setting a config,
# then deleting it, and reloading it
# 1. mode - either VARS Keywords on non-key variables: a <x> y <y> or
# ALL Keywords on all variables: a x <x> y <y>
# HIDE
# OC_COMPRESS
# 2. listkw - either none, vars, all
# 3. compress - surrounding container entities are removed from list nodes
# 4. openconfig - config and state containers are "compressed" out of the schema in openconfig modules
# Simple run trying setting a config, then deleting it, and reloading it
# Run setconfig first
# 1. listkw - either none, vars, all
# 2. compress - surrounding container entities are removed from list nodes
function testrun()
{
mode=$1
listkw=$2
compress=$3
listkw=$1
compress=$2
if [ $listkw = kw-all ]; then
name=" name"
@ -329,25 +323,25 @@ new "Config: Keywords on non-keys"
setconfig kw-nokey false false
new "Keywords on non-keys"
testrun VARS kw-nokey false
testrun kw-nokey false
new "Config: Keywords on all"
setconfig kw-all false false
new "Keywords on all"
testrun ALL kw-all false
testrun kw-all false
new "Config: Keywords on non-keys, container compress"
setconfig kw-nokey true false
new "Keywords on non-keys, container compress"
testrun HIDE kw-nokey true
testrun kw-nokey true
new "Config:Keywords on non-keys, container and openconfig compress"
setconfig kw-nokey true true
new "Keywords on non-keys, container and openconfig compress"
testrun OC_COMPRESS kw-nokey true
testrun kw-nokey true
new "Config:default"
setconfig kw-nokey false false