CLI configurable format: [Default format should be configurable](https://github.com/clicon/clixon-controller/issues/87)
Added option: `CLICON_CLI_OUTPUT_FORMAT` - Default CLI output format
This commit is contained in:
parent
bd3a841103
commit
60a774cbf7
18 changed files with 168 additions and 83 deletions
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
if [ $(whoami) != root ]; then
|
||||
EXTRAUSER="<user-name>$(whoami)</user-name>"
|
||||
else
|
||||
EXTRAUSER=""
|
||||
fi
|
||||
|
||||
# Three groups from RFC8341 A.1 (admin extended with $USER)
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ cat <<EOF > $cfg
|
|||
<CLICON_BACKEND_PIDFILE>/usr/local/var/run/$APPNAME.pidfile</CLICON_BACKEND_PIDFILE>
|
||||
<CLICON_XMLDB_DIR>$dir</CLICON_XMLDB_DIR>
|
||||
<CLICON_YANG_LIBRARY>true</CLICON_YANG_LIBRARY>
|
||||
<CLICON_CLI_OUTPUT_FORMAT>xml</CLICON_CLI_OUTPUT_FORMAT>
|
||||
</clixon-config>
|
||||
EOF
|
||||
|
||||
|
|
@ -89,19 +90,19 @@ new "wait backend"
|
|||
wait_backend
|
||||
|
||||
new "cli show config startup"
|
||||
expectpart "$($clixon_cli -1 -f $cfg -l o show config xml default report-all)" 0 '<table xmlns="urn:example:clixon">' '<map xmlns="urn:example:augment">' '<enable>true</enable>'
|
||||
expectpart "$($clixon_cli -1 -f $cfg -l o show config default report-all)" 0 '<table xmlns="urn:example:clixon">' '<map xmlns="urn:example:augment">' '<enable>true</enable>'
|
||||
|
||||
new "cli delete map name"
|
||||
expectpart "$($clixon_cli -1 -f $cfg -l o delete table map name me)" 0 ""
|
||||
|
||||
new "cli show config deleted"
|
||||
expectpart "$($clixon_cli -1 -f $cfg -l o show config xml default report-all)" 0 '<table xmlns="urn:example:clixon">' '<map xmlns="urn:example:augment">' '<enable>true</enable>'
|
||||
expectpart "$($clixon_cli -1 -f $cfg -l o show config default report-all)" 0 '<table xmlns="urn:example:clixon">' '<map xmlns="urn:example:augment">' '<enable>true</enable>'
|
||||
|
||||
new "cli set map name"
|
||||
expectpart "$($clixon_cli -1 -f $cfg -l o set table map name x)" 0 ""
|
||||
|
||||
new "cli show config set"
|
||||
expectpart "$($clixon_cli -1 -f $cfg -l o show config xml default report-all)" 0 '<table xmlns="urn:example:clixon">' '<map xmlns="urn:example:augment">' '<enable>true</enable>'
|
||||
expectpart "$($clixon_cli -1 -f $cfg -l o show config default report-all)" 0 '<table xmlns="urn:example:clixon">' '<map xmlns="urn:example:augment">' '<enable>true</enable>'
|
||||
|
||||
if [ $BE -ne 0 ]; then
|
||||
new "Kill backend"
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ cat <<EOF > $cfg
|
|||
<CLICON_SOCK>/usr/local/var/run/$APPNAME.sock</CLICON_SOCK>
|
||||
<CLICON_BACKEND_PIDFILE>/usr/local/var/run/$APPNAME.pidfile</CLICON_BACKEND_PIDFILE>
|
||||
<CLICON_XMLDB_DIR>$dir</CLICON_XMLDB_DIR>
|
||||
<CLICON_CLI_OUTPUT_FORMAT>cli</CLICON_CLI_OUTPUT_FORMAT>
|
||||
</clixon-config>
|
||||
EOF
|
||||
|
||||
|
|
@ -73,10 +74,10 @@ new "cli set 43 exclude keys"
|
|||
expectpart "$($clixon_cli -1 -o CLICON_CLI_VARONLY=1 -f $cfg set table parameter 43)" 0 "^$"
|
||||
|
||||
new "cli show 42 43 include"
|
||||
expectpart "$($clixon_cli -1 -o CLICON_CLI_VARONLY=0 -f $cfg show conf cli)" 0 "set table parameter 42" "set table parameter 43"
|
||||
expectpart "$($clixon_cli -1 -o CLICON_CLI_VARONLY=0 -f $cfg show conf)" 0 "set table parameter 42" "set table parameter 43"
|
||||
|
||||
new "cli show 42 43 exclude"
|
||||
expectpart "$($clixon_cli -1 -o CLICON_CLI_VARONLY=1 -f $cfg show conf cli)" 0 "set table parameter 42" "set table parameter 43"
|
||||
expectpart "$($clixon_cli -1 -o CLICON_CLI_VARONLY=1 -f $cfg show conf)" 0 "set table parameter 42" "set table parameter 43"
|
||||
|
||||
new "cli expand include keys"
|
||||
expectpart "$(echo "set table parameter ?" | $clixon_cli -o CLICON_CLI_VARONLY=0 -f $cfg 2>&1)" 0 42 43
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ cat <<EOF > $cfg
|
|||
<CLICON_NACM_MODE>external</CLICON_NACM_MODE>
|
||||
<CLICON_NACM_FILE>$nacmfile</CLICON_NACM_FILE>
|
||||
<CLICON_NACM_CREDENTIALS>none</CLICON_NACM_CREDENTIALS>
|
||||
<CLICON_CLI_OUTPUT_FORMAT>text</CLICON_CLI_OUTPUT_FORMAT>
|
||||
$RESTCONFIG
|
||||
</clixon-config>
|
||||
EOF
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ cat <<EOF > $cfg
|
|||
<CLICON_BACKEND_PIDFILE>/usr/local/var/run/$APPNAME.pidfile</CLICON_BACKEND_PIDFILE>
|
||||
<CLICON_XMLDB_DIR>/usr/local/var/$APPNAME</CLICON_XMLDB_DIR>
|
||||
<CLICON_VALIDATE_STATE_XML>true</CLICON_VALIDATE_STATE_XML>
|
||||
<CLICON_CLI_OUTPUT_FORMAT>cli</CLICON_CLI_OUTPUT_FORMAT>
|
||||
</clixon-config>
|
||||
EOF
|
||||
|
||||
|
|
@ -301,7 +302,7 @@ new "netconf get replaced config (report-all)"
|
|||
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><get-config><source><candidate/></source><with-defaults xmlns=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\">report-all</with-defaults></get-config></rpc>" "" "<rpc-reply $DEFAULTNS><data><interfaces xmlns=\"urn:ietf:params:xml:ns:yang:ietf-interfaces\"><interface><name>eth&</name><type>t<></type><enabled>true</enabled></interface><interface xmlns:ex=\"urn:example:clixon\"><name>eth1</name><type>ex:eth</type><enabled>true</enabled></interface><interface xmlns:ex=\"urn:example:clixon\"><name>eth2</name><type>ex:eth</type><enabled>true</enabled></interface></interfaces></data></rpc-reply>"
|
||||
|
||||
new "cli show configuration eth& - encoding tests"
|
||||
expectpart "$($clixon_cli -1 -f $cfg show conf cli)" 0 "interfaces interface eth& type t<>
|
||||
expectpart "$($clixon_cli -1 -f $cfg show conf)" 0 "interfaces interface eth& type t<>
|
||||
interfaces interface eth& enabled true"
|
||||
|
||||
new "netconf edit CDATA"
|
||||
|
|
|
|||
|
|
@ -240,6 +240,7 @@ function testrun(){
|
|||
<CLICON_BACKEND_PIDFILE>/usr/local/var/run/$APPNAME.pidfile</CLICON_BACKEND_PIDFILE>
|
||||
<CLICON_XMLDB_DIR>/usr/local/var/$APPNAME</CLICON_XMLDB_DIR>
|
||||
<CLICON_XMLDB_FORMAT>$format</CLICON_XMLDB_FORMAT>
|
||||
<CLICON_CLI_OUTPUT_FORMAT>text</CLICON_CLI_OUTPUT_FORMAT>
|
||||
${AUTOCLI}
|
||||
</clixon-config>
|
||||
EOF
|
||||
|
|
|
|||
|
|
@ -147,6 +147,7 @@ function testrun()
|
|||
<CLICON_YANG_UNKNOWN_ANYDATA>$unknown</CLICON_YANG_UNKNOWN_ANYDATA>
|
||||
<CLICON_STREAM_DISCOVERY_RFC8040>false</CLICON_STREAM_DISCOVERY_RFC8040>
|
||||
<CLICON_NETCONF_MONITORING>false</CLICON_NETCONF_MONITORING>
|
||||
<CLICON_CLI_OUTPUT_FORMAT>xml</CLICON_CLI_OUTPUT_FORMAT>
|
||||
$F
|
||||
$RESTCONFIG
|
||||
</clixon-config>
|
||||
|
|
@ -209,7 +210,7 @@ EOF
|
|||
|
||||
# Add other functions, (based on previous errors), eg cli show config, cli commit.
|
||||
new "cli show configuration"
|
||||
expectpart "$($clixon_cli -1 -f $cfg show conf xml)" 0 "<u31>42</u31>"
|
||||
expectpart "$($clixon_cli -1 -f $cfg show conf)" 0 "<u31>42</u31>"
|
||||
|
||||
new "cli commit"
|
||||
expectpart "$($clixon_cli -1 -f $cfg commit)" 0 "^$"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue