[Code formatting: Change indentation style to space](https://github.com/clicon/clixon/issues/379)

* Applies to all c/h/y/l/sh files and .editorconfig
This commit is contained in:
Olof hagsand 2022-10-27 14:21:17 +02:00
parent a9d1ab006c
commit d84c529ff1
376 changed files with 38147 additions and 38133 deletions

View file

@ -34,10 +34,10 @@ for test in $pattern; do
errcode=$?
endsuite
if [ $errcode -ne 0 ]; then
allerr=1
echo -e "\e[31mError in $test errcode=$errcode"
echo -ne "\e[0m"
exit $errcode
allerr=1
echo -e "\e[31mError in $test errcode=$errcode"
echo -ne "\e[0m"
exit $errcode
fi
done
if [ $allerr -eq 0 ]; then

View file

@ -119,7 +119,7 @@ cat <<EOF > $fexample
leaf-list following {
type leafref {
path "/members/member/member-id";
require-instance false;
require-instance false;
}
description
"Other members this members is following.";
@ -217,8 +217,8 @@ cat <<EOF > $fexample
description
"Operational state members values.";
leaf-list numbers {
description "config false extension";
type int32;
description "config false extension";
type int32;
}
leaf joined {
type yang:date-and-time;

View file

@ -37,9 +37,9 @@ cat <<EOF > $cfg
<log-destination>file</log-destination>
<socket>
<namespace>default</namespace>
<address>0.0.0.0</address>
<port>8088</port>
<ssl>false</ssl>
<address>0.0.0.0</address>
<port>8088</port>
<ssl>false</ssl>
</socket>
</restconf>
</clixon-config>

View file

@ -34,7 +34,7 @@
if [ -f ./config.sh ]; then
. ./config.sh
if [ $? -ne 0 ]; then
return -1 # error
return -1 # error
fi
fi
@ -130,11 +130,11 @@ fi
if [ ${HVER} = 2 ]; then
if ${HAVE_HTTP1}; then
# This is if http/1 is enabled (unset proto=HTTP_2 in restconf_accept_client)
CURLOPTS="${CURLOPTS} --http2"
# This is if http/1 is enabled (unset proto=HTTP_2 in restconf_accept_client)
CURLOPTS="${CURLOPTS} --http2"
else
# This is if http/1 is disabled (set proto=HTTP_2 in restconf_accept_client)
CURLOPTS="${CURLOPTS} --http2-prior-knowledge"
# This is if http/1 is disabled (set proto=HTTP_2 in restconf_accept_client)
CURLOPTS="${CURLOPTS} --http2-prior-knowledge"
fi
else
CURLOPTS="${CURLOPTS} --http1.1"
@ -199,14 +199,14 @@ BUSER=clicon
if [ -f ./site.sh ]; then
. ./site.sh
if [ $? -ne 0 ]; then
return -1 # skip
return -1 # skip
fi
# test skiplist.
for f in $SKIPLIST; do
if [ "$testfile" = "$f" ]; then
echo "...skipped (see site.sh)"
return -1 # skip
fi
if [ "$testfile" = "$f" ]; then
echo "...skipped (see site.sh)"
return -1 # skip
fi
done
fi
@ -229,10 +229,10 @@ if $SNMPCHECK; then
snmptranslate="$(type -p snmptranslate) "
if [ "${ENABLE_NETSNMP}" == "yes" ]; then
pgrep snmpd > /dev/null
pgrep snmpd > /dev/null
if [ $? != 0 ]; then
echo -e "\e[31m\nenable-netsnmp set but snmpd not running, start with:"
echo "systemctl start snmpd"
echo -e "\e[31m\nenable-netsnmp set but snmpd not running, start with:"
echo "systemctl start snmpd"
echo ""
echo "snmpd must be configured to use a Unix socket for agent communication"
echo "and have a rwcommunity configured, make sure the following lines are"
@ -244,8 +244,8 @@ if $SNMPCHECK; then
echo ""
echo "If you don't rely on systemd you can configure the lines above"
echo "and start snmpd manually with 'snmpd -Lo -p /var/run/snmpd.pid'."
echo -e "\e[0m"
exit -1
echo -e "\e[0m"
exit -1
fi
fi
@ -292,23 +292,23 @@ fi
# Sanity nginx running on systemd platforms
if $NGINXCHECK; then
if systemctl > /dev/null 2>&1 ; then
# even if systemd exists, nginx may be started in other ways
nginxactive=$(systemctl show nginx |grep ActiveState=active)
if [ "${WITH_RESTCONF}" = "fcgi" ]; then
if [ -z "$nginxactive" -a ! -f /var/run/nginx.pid ]; then
echo -e "\e[31m\nwith-restconf=fcgi set but nginx not running, start with:"
echo "systemctl start nginx"
echo -e "\e[0m"
exit -1
fi
else
if [ -n "$nginxactive" -o -f /var/run/nginx.pid ]; then
echo -e "\e[31m\nwith-restconf=fcgi not set but nginx running, stop with:"
echo "systemctl stop nginx"
echo -e "\e[0m"
exit -1
fi
fi
# even if systemd exists, nginx may be started in other ways
nginxactive=$(systemctl show nginx |grep ActiveState=active)
if [ "${WITH_RESTCONF}" = "fcgi" ]; then
if [ -z "$nginxactive" -a ! -f /var/run/nginx.pid ]; then
echo -e "\e[31m\nwith-restconf=fcgi set but nginx not running, start with:"
echo "systemctl start nginx"
echo -e "\e[0m"
exit -1
fi
else
if [ -n "$nginxactive" -o -f /var/run/nginx.pid ]; then
echo -e "\e[31m\nwith-restconf=fcgi not set but nginx running, stop with:"
echo "systemctl stop nginx"
echo -e "\e[0m"
exit -1
fi
fi
fi # systemctl
fi
@ -335,40 +335,40 @@ function restconf_config()
# Change this to fixed parameters
if [ $# -gt 2 ]; then
myproto=$3
myproto=$3
else
myproto=$RCPROTO
myproto=$RCPROTO
fi
if [ $# -gt 3 ]; then
myhttpdata=$4
myhttpdata=$4
else
myhttpdata=false
myhttpdata=false
fi
echo -n "<CLICON_FEATURE>clixon-restconf:fcgi</CLICON_FEATURE>"
if [ $myproto = http ]; then
echo -n "<restconf><enable>true</enable>"
if ${myhttpdata}; then
echo -n "<enable-http-data>true</enable-http-data>"
fi
echo "<auth-type>$AUTH</auth-type><pretty>$PRETTY</pretty><debug>$DBG</debug><socket><namespace>default</namespace><address>0.0.0.0</address><port>80</port><ssl>false</ssl></socket></restconf>"
echo -n "<restconf><enable>true</enable>"
if ${myhttpdata}; then
echo -n "<enable-http-data>true</enable-http-data>"
fi
echo "<auth-type>$AUTH</auth-type><pretty>$PRETTY</pretty><debug>$DBG</debug><socket><namespace>default</namespace><address>0.0.0.0</address><port>80</port><ssl>false</ssl></socket></restconf>"
else
certdir=$dir/certs
if [ ! -f ${dir}/clixon-server-crt.pem ]; then
certdir=$dir/certs
test -d $certdir || mkdir $certdir
srvcert=${certdir}/clixon-server-crt.pem
srvkey=${certdir}/clixon-server-key.pem
cacert=${certdir}/clixon-ca-crt.pem
cakey=${certdir}/clixon-ca-key.pem
cacerts $cakey $cacert
servercerts $cakey $cacert $srvkey $srvcert
fi
echo -n "<restconf><enable>true</enable>"
if ${myhttpdata}; then
echo -n "<enable-http-data>true</enable-http-data>"
fi
echo "<auth-type>$AUTH</auth-type><pretty>$PRETTY</pretty><server-cert-path>${certdir}/clixon-server-crt.pem</server-cert-path><server-key-path>${certdir}/clixon-server-key.pem</server-key-path><server-ca-cert-path>${certdir}/clixon-ca-crt.pem</server-ca-cert-path><debug>$DBG</debug><socket><namespace>default</namespace><address>0.0.0.0</address><port>443</port><ssl>true</ssl></socket></restconf>"
certdir=$dir/certs
if [ ! -f ${dir}/clixon-server-crt.pem ]; then
certdir=$dir/certs
test -d $certdir || mkdir $certdir
srvcert=${certdir}/clixon-server-crt.pem
srvkey=${certdir}/clixon-server-key.pem
cacert=${certdir}/clixon-ca-crt.pem
cakey=${certdir}/clixon-ca-key.pem
cacerts $cakey $cacert
servercerts $cakey $cacert $srvkey $srvcert
fi
echo -n "<restconf><enable>true</enable>"
if ${myhttpdata}; then
echo -n "<enable-http-data>true</enable-http-data>"
fi
echo "<auth-type>$AUTH</auth-type><pretty>$PRETTY</pretty><server-cert-path>${certdir}/clixon-server-crt.pem</server-cert-path><server-key-path>${certdir}/clixon-server-key.pem</server-key-path><server-ca-cert-path>${certdir}/clixon-ca-crt.pem</server-ca-cert-path><debug>$DBG</debug><socket><namespace>default</namespace><address>0.0.0.0</address><port>443</port><ssl>true</ssl></socket></restconf>"
fi
}
@ -457,19 +457,19 @@ function err1(){
# Test is previous test had valgrind errors if so quit
function checkvalgrind(){
if [ -f $valgrindfile ]; then
res=$(cat $valgrindfile | grep -e "Invalid" |awk '{print $4}' | grep -v '^0$')
if [ -n "$res" ]; then
>&2 cat $valgrindfile
sudo rm -f $valgrindfile
exit -1
fi
res=$(cat $valgrindfile | grep -e "reachable" -e "lost:"|awk '{print $4}' | grep -v '^0$')
if [ -n "$res" ]; then
>&2 cat $valgrindfile
sudo rm -f $valgrindfile
exit -1
fi
sudo rm -f $valgrindfile
res=$(cat $valgrindfile | grep -e "Invalid" |awk '{print $4}' | grep -v '^0$')
if [ -n "$res" ]; then
>&2 cat $valgrindfile
sudo rm -f $valgrindfile
exit -1
fi
res=$(cat $valgrindfile | grep -e "reachable" -e "lost:"|awk '{print $4}' | grep -v '^0$')
if [ -n "$res" ]; then
>&2 cat $valgrindfile
sudo rm -f $valgrindfile
exit -1
fi
sudo rm -f $valgrindfile
fi
}
@ -480,9 +480,9 @@ function chunked_equal()
echo "1:$1"
echo "2:$2"
if [ "$1" == "$2" ]; then
return 0
return 0
else
return 255
return 255
fi
}
@ -506,18 +506,18 @@ function start_snmp(){
$clixon_snmp -f $cfg -D $DBG &
if [ $? -ne 0 ]; then
err
err
fi
}
# Stop clixon_snmp and Valgrind if needed
function stop_snmp(){
if [ $valgrindtest -eq 4 ]; then
pkill -f clixon_snmp
sleep 1
checkvalgrind
pkill -f clixon_snmp
sleep 1
checkvalgrind
else
killall -q clixon_snmp
killall -q clixon_snmp
fi
rm -f ${clixon_snmp_pidfile}
}
@ -526,25 +526,25 @@ function stop_snmp(){
# If valgrindtest == 2, start valgrind
function start_backend(){
if [ $valgrindtest -eq 2 ]; then
# Start in background since daemon version creates two traces: parent,
# child. If background then only the single relevant.
sudo $clixon_backend -F -D $DBG $* &
# Start in background since daemon version creates two traces: parent,
# child. If background then only the single relevant.
sudo $clixon_backend -F -D $DBG $* &
else
sudo $clixon_backend -D $DBG $*
sudo $clixon_backend -D $DBG $*
fi
if [ $? -ne 0 ]; then
err
err
fi
}
function stop_backend(){
sudo clixon_backend -z $*
if [ $? -ne 0 ]; then
err "kill backend"
err "kill backend"
fi
if [ $valgrindtest -eq 2 ]; then
sleep 1
checkvalgrind
sleep 1
checkvalgrind
fi
sudo pkill -f clixon_backend # extra ($BUSER?)
}
@ -557,15 +557,15 @@ function wait_backend(){
# chunked_equal "$reply" "$freply"
let i=0;
while [[ $reply != *"<rpc-reply"* ]]; do
# echo "sleep $DEMSLEEP"
sleep $DEMSLEEP
reply=$(echo "<rpc $ÐEFAULTSNS $LIBNS><ping/></rpc>]]>]]>" | clixon_netconf -qef $cfg 2> /dev/null)
# echo "reply:$reply"
let i++;
# echo "wait_backend $i"
if [ $i -ge $DEMLOOP ]; then
err "backend timeout $DEMWAIT seconds"
fi
# echo "sleep $DEMSLEEP"
sleep $DEMSLEEP
reply=$(echo "<rpc $ÐEFAULTSNS $LIBNS><ping/></rpc>]]>]]>" | clixon_netconf -qef $cfg 2> /dev/null)
# echo "reply:$reply"
let i++;
# echo "wait_backend $i"
if [ $i -ge $DEMLOOP ]; then
err "backend timeout $DEMWAIT seconds"
fi
done
}
@ -577,7 +577,7 @@ function start_restconf(){
echo "sudo -u $wwwstartuser -s $clixon_restconf $RCLOG -D $DBG $*"
sudo -u $wwwstartuser -s $clixon_restconf $RCLOG -D $DBG $* </dev/null &>/dev/null &
if [ $? -ne 0 ]; then
err1 "expected 0" "$?"
err1 "expected 0" "$?"
fi
}
@ -594,8 +594,8 @@ function stop_restconf_pre(){
function stop_restconf(){
sudo pkill -f clixon_restconf
if [ $valgrindtest -eq 3 ]; then
sleep 1
checkvalgrind
sleep 1
checkvalgrind
fi
}
@ -607,27 +607,27 @@ function stop_restconf(){
# 1: (optional) override RCPROTO with http or https
function wait_restconf(){
if [ $# = 1 ]; then
myproto=$1
myproto=$1
else
myproto=${RCPROTO}
myproto=${RCPROTO}
fi
# echo "curl $CURLOPTS -X GET $myproto://localhost/restconf"
hdr=$(curl $CURLOPTS -X GET $myproto://localhost/restconf 2> /dev/null)
# echo "hdr:\"$hdr\""
let i=0;
while [[ "$hdr" != *"200"* ]]; do
# echo "wait_restconf $i"
if [ $i -ge $DEMLOOP ]; then
err1 "restconf timeout $DEMWAIT seconds"
fi
sleep $DEMSLEEP
# echo "curl $CURLOPTS -X GET $myproto://localhost/restconf"
hdr=$(curl $CURLOPTS -X GET $myproto://localhost/restconf 2> /dev/null)
# echo "hdr:\"$hdr\""
let i++;
# echo "wait_restconf $i"
if [ $i -ge $DEMLOOP ]; then
err1 "restconf timeout $DEMWAIT seconds"
fi
sleep $DEMSLEEP
# echo "curl $CURLOPTS -X GET $myproto://localhost/restconf"
hdr=$(curl $CURLOPTS -X GET $myproto://localhost/restconf 2> /dev/null)
# echo "hdr:\"$hdr\""
let i++;
done
if [ $valgrindtest -eq 3 ]; then
sleep 2 # some problems with valgrind
sleep 2 # some problems with valgrind
fi
stty $STTYSETTINGS
@ -642,17 +642,17 @@ function wait_restconf_stopped(){
# echo "hdr:\"$hdr\""
let i=0;
while [[ $hdr = *"200 OK"* ]]; do
# echo "wait_restconf_stopped $i"
if [ $i -ge $DEMLOOP ]; then
err1 "restconf timeout $DEMWAIT seconds"
fi
sleep $DEMSLEEP
hdr=$(curl $CURLOPTS $* $RCPROTO://localhost/restconf 2> /dev/null)
# echo "hdr:\"$hdr\""
let i++;
# echo "wait_restconf_stopped $i"
if [ $i -ge $DEMLOOP ]; then
err1 "restconf timeout $DEMWAIT seconds"
fi
sleep $DEMSLEEP
hdr=$(curl $CURLOPTS $* $RCPROTO://localhost/restconf 2> /dev/null)
# echo "hdr:\"$hdr\""
let i++;
done
if [ $valgrindtest -eq 3 ]; then
sleep 2 # some problems with valgrind
sleep 2 # some problems with valgrind
fi
}
@ -661,11 +661,11 @@ function wait_snmp()
{
let i=0;
while [ ! -f ${clixon_snmp_pidfile} ]; do
if [ $i -ge $DEMLOOP ]; then
err1 "snmp timeout $DEMWAIT seconds"
fi
sleep $DEMSLEEP
let i++;
if [ $i -ge $DEMLOOP ]; then
err1 "snmp timeout $DEMWAIT seconds"
fi
sleep $DEMSLEEP
let i++;
done
}
@ -674,7 +674,7 @@ function wait_snmp()
function endtest()
{
if [ $valgrindtest -eq 1 ]; then
checkvalgrind
checkvalgrind
fi
}
@ -715,21 +715,21 @@ function expectpart(){
# echo "expect:\"$expect\""
if [ "$retval" -eq "$retval" 2> /dev/null ] ; then # single retval
if [ $r != $retval ]; then
echo -e "\e[31m\nError ($r != $retval) in Test$testnr [$testname]:"
echo -e "\e[0m:"
exit -1
echo -e "\e[31m\nError ($r != $retval) in Test$testnr [$testname]:"
echo -e "\e[0m:"
exit -1
fi
else # List of retvals
found=0
for rv in $retval; do
if [ $r == $rv ]; then
found=1
fi
if [ $r == $rv ]; then
found=1
fi
done
if [ $found -eq 0 ]; then
echo -e "\e[31m\nError ($r != $retval) in Test$testnr [$testname]:"
echo -e "\e[0m:"
exit -1
echo -e "\e[31m\nError ($r != $retval) in Test$testnr [$testname]:"
echo -e "\e[0m:"
exit -1
fi
fi
if [ -z "$ret" -a -z "$expect" ]; then
@ -742,22 +742,22 @@ function expectpart(){
let i=0;
for exp in "$@"; do
if [ $i -gt 1 ]; then
if [ "$exp" == "--not--" ]; then
positive=false;
else
# echo "echo \"$ret\" | grep --null -o \"$exp"\"
match=$(echo "$ret" | grep --null -i -o "$exp") #-i ignore case XXX -EZo: -E cant handle {}
r=$?
if $positive; then
if [ $r != 0 ]; then
err "$exp" "$ret"
fi
else
if [ $r == 0 ]; then
err "not $exp" "$ret"
fi
fi
fi
if [ "$exp" == "--not--" ]; then
positive=false;
else
# echo "echo \"$ret\" | grep --null -o \"$exp"\"
match=$(echo "$ret" | grep --null -i -o "$exp") #-i ignore case XXX -EZo: -E cant handle {}
r=$?
if $positive; then
if [ $r != 0 ]; then
err "$exp" "$ret"
fi
else
if [ $r == 0 ]; then
err "not $exp" "$ret"
fi
fi
fi
fi
let i++;
done
@ -786,7 +786,7 @@ function expecteof(){
ret=$($cmd 2> $errfile <<EOF
$input
EOF
)
)
r=$?
else
# Do while read stuff
@ -810,18 +810,18 @@ EOF
: # null
else
# -G for basic regexp (eg ^$). -E for extended regular expression - differs in \
# --null for nul character, -x for implicit ^$ -q for quiet
# --null for nul character, -x for implicit ^$ -q for quiet
# -o only matching
# Two variants: --null -Eo and -Fxq
# match=`echo "$ret" | grep --null -Fo "$expect"`
if [ $# -gt 4 ]; then # stderr
rerr=$(cat $errfile)
rm -f $errfile
r=$(echo "$rerr" | grep --null -Go "$expecterr")
match=$?
if [ $match -ne 0 ]; then
err "$expecterr" "$rerr"
fi
rerr=$(cat $errfile)
rm -f $errfile
r=$(echo "$rerr" | grep --null -Go "$expecterr")
match=$?
if [ $match -ne 0 ]; then
err "$expecterr" "$rerr"
fi
fi
r=$(echo "$ret" | grep --null -Go "$expect")
@ -832,7 +832,7 @@ EOF
# echo "expect:\"$expect\""
# echo "match:\"$match\""
if [ $match -ne 0 ]; then
err "$expect" "$ret"
err "$expect" "$ret"
fi
fi
}
@ -891,7 +891,7 @@ EOF
r=$(echo "$ret" | grep --null -Go "$expect1")
match=$?
if [ $match -ne 0 ]; then
err "$expect1" "$ret"
err "$expect1" "$ret"
fi
fi
if [ -z "$ret" -a -z "$expectenc" ]; then
@ -899,14 +899,14 @@ EOF
else
while read i
do
# -F fixed strings
# -G basic regexp
# r=$(echo "$ret" | grep --null -Go "$i")
r=$(echo "$ret" | grep --null -Fo "$i")
match=$?
if [ $match -ne 0 ]; then
err "$expectenc" "$ret"
fi
# -F fixed strings
# -G basic regexp
# r=$(echo "$ret" | grep --null -Go "$i")
r=$(echo "$ret" | grep --null -Fo "$i")
match=$?
if [ $match -ne 0 ]; then
err "$expectenc" "$ret"
fi
done <<< "$expectenc"
fi
}
@ -1063,8 +1063,8 @@ function expectwait(){
read -t 20 r
# echo "r:<$r>"
if [ -z "$r" ]; then
sleep 1
continue
sleep 1
continue
fi
# Append $r to $ret
ret="$ret$r"
@ -1074,38 +1074,38 @@ function expectwait(){
let ok=0
let fail=0
for exp in "$@"; do
if [ $i -gt 4 ]; then
# echo "i:$i"
# echo "exp:$exp"
if [ "$exp" == "--not--" ]; then
positive=false;
else
match=$(echo "$ret" | grep --null -i -o "$exp")
# match=$(echo "$ret" | grep -Eo "$exp");
r=$?
if $positive; then
if [ $r != 0 ]; then
# echo "fail: $exp"
let fail++
break
fi
else
if [ $r == 0 ]; then
# echo "fail: $exp"
let fail++
break
fi
fi
fi
fi
let i++;
if [ $i -gt 4 ]; then
# echo "i:$i"
# echo "exp:$exp"
if [ "$exp" == "--not--" ]; then
positive=false;
else
match=$(echo "$ret" | grep --null -i -o "$exp")
# match=$(echo "$ret" | grep -Eo "$exp");
r=$?
if $positive; then
if [ $r != 0 ]; then
# echo "fail: $exp"
let fail++
break
fi
else
if [ $r == 0 ]; then
# echo "fail: $exp"
let fail++
break
fi
fi
fi
fi
let i++;
done # for exp
# echo "fail:$fail"
if [ $fail -eq 0 ]; then
# echo ok
echo ok > $dir/expectwaitresult
# break
exit 0
# echo ok
echo ok > $dir/expectwaitresult
# break
exit 0
fi
done
# cat $dir/expectwaitresult
@ -1126,23 +1126,23 @@ function expectmatch(){
# echo "expret:$expret"
# echo "expect:$expect"
if [ $r != $expret ]; then
echo -e "\e[31m\nError ($r != $retval) in Test$testnr [$testname]:"
echo -e "\e[0m:"
exit -1
echo -e "\e[31m\nError ($r != $retval) in Test$testnr [$testname]:"
echo -e "\e[0m:"
exit -1
fi
if [ -z "$ret" -a -z "$expect" ]; then
echo > /dev/null
echo > /dev/null
else
match=$(echo "$ret" | grep -Eo "$expect")
if [ -z "$match" ]; then
err "$expect" "$ret"
fi
if [ -n "$expect2" ]; then
match=`echo "$ret" | grep --null -Eo "$expect2"`
if [ -z "$match" ]; then
err $expect "$ret"
fi
fi
match=$(echo "$ret" | grep -Eo "$expect")
if [ -z "$match" ]; then
err "$expect" "$ret"
fi
if [ -n "$expect2" ]; then
match=`echo "$ret" | grep --null -Eo "$expect2"`
if [ -z "$match" ]; then
err $expect "$ret"
fi
fi
fi
}
@ -1154,8 +1154,8 @@ function expectmatch(){
function cacerts()
{
if [ $# -ne 2 ]; then
echo "cacerts function: Expected: cakey cacert"
exit 1
echo "cacerts function: Expected: cakey cacert"
exit 1
fi
local cakey=$1
local cacert=$2
@ -1215,8 +1215,8 @@ EOF
function servercerts()
{
if [ $# -ne 4 ]; then
echo "servercerts function: Expected: cakey cacert srvkey srvcert"
exit 1
echo "servercerts function: Expected: cakey cacert srvkey srvcert"
exit 1
fi
cakey=$1
cacert=$2

View file

@ -70,7 +70,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
err
fi
new "start backend -s init -f $cfg"
@ -131,7 +131,7 @@ if [ $BE -ne 0 ]; then
# Check if premature kill
pid=`pgrep -u root -f clixon_backend`
if [ -z "$pid" ]; then
err "backend already dead"
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg

View file

@ -20,69 +20,69 @@ function memonce(){
clixon_restconf=
clixon_snmp=
case "$what" in
'cli')
valgrindtest=1
: ${DEMWAIT:=5} # valgrind backend needs some time to get up
clixon_cli="/usr/bin/valgrind --leak-check=full --show-leak-kinds=all --suppressions=./valgrind-clixon.supp --track-fds=yes --trace-children=no --child-silent-after-fork=yes --log-file=$valgrindfile clixon_cli"
;;
'netconf')
valgrindtest=1
: ${DEMWAIT:=5} # valgrind backend needs some time to get up
clixon_netconf="/usr/bin/valgrind --leak-check=full --show-leak-kinds=all --suppressions=./valgrind-clixon.supp --track-fds=yes --trace-children=no --child-silent-after-fork=yes --log-file=$valgrindfile clixon_netconf"
;;
'backend')
valgrindtest=2 # This means backend valgrind test
: ${DEMWAIT:=10} # valgrind backend needs some time to get up
# trace-children=no for test_restconf_rpc.sh
clixon_backend="/usr/bin/valgrind --num-callers=50 --leak-check=full --show-leak-kinds=all --suppressions=./valgrind-clixon.supp --track-fds=yes --trace-children=no --log-file=$valgrindfile clixon_backend"
;;
'restconf')
valgrindtest=3 # This means restconf valgrind test
sudo chmod 660 $valgrindfile
sudo chown www-data $valgrindfile
: ${DEMWAIT:=15} # valgrind backend needs some time to get up
clixon_restconf="/usr/bin/valgrind --num-callers=50 --leak-check=full --show-leak-kinds=all --suppressions=./valgrind-clixon.supp --track-fds=yes --trace-children=no --child-silent-after-fork=yes --log-file=$valgrindfile clixon_restconf"
;;
'snmp')
valgrindtest=4 # This means snmp valgrind test
'cli')
valgrindtest=1
: ${DEMWAIT:=5} # valgrind backend needs some time to get up
clixon_cli="/usr/bin/valgrind --leak-check=full --show-leak-kinds=all --suppressions=./valgrind-clixon.supp --track-fds=yes --trace-children=no --child-silent-after-fork=yes --log-file=$valgrindfile clixon_cli"
;;
'netconf')
valgrindtest=1
: ${DEMWAIT:=5} # valgrind backend needs some time to get up
clixon_netconf="/usr/bin/valgrind --leak-check=full --show-leak-kinds=all --suppressions=./valgrind-clixon.supp --track-fds=yes --trace-children=no --child-silent-after-fork=yes --log-file=$valgrindfile clixon_netconf"
;;
'backend')
valgrindtest=2 # This means backend valgrind test
: ${DEMWAIT:=10} # valgrind backend needs some time to get up
# trace-children=no for test_restconf_rpc.sh
clixon_backend="/usr/bin/valgrind --num-callers=50 --leak-check=full --show-leak-kinds=all --suppressions=./valgrind-clixon.supp --track-fds=yes --trace-children=no --log-file=$valgrindfile clixon_backend"
;;
'restconf')
valgrindtest=3 # This means restconf valgrind test
sudo chmod 660 $valgrindfile
: ${DEMWAIT:=15} # valgrind snmp needs some time to get up
clixon_snmp="/usr/bin/valgrind --num-callers=50 --leak-check=full --show-leak-kinds=all --suppressions=./valgrind-clixon.supp --track-fds=yes --trace-children=no --child-silent-after-fork=yes --log-file=$valgrindfile clixon_snmp"
;;
sudo chown www-data $valgrindfile
: ${DEMWAIT:=15} # valgrind backend needs some time to get up
clixon_restconf="/usr/bin/valgrind --num-callers=50 --leak-check=full --show-leak-kinds=all --suppressions=./valgrind-clixon.supp --track-fds=yes --trace-children=no --child-silent-after-fork=yes --log-file=$valgrindfile clixon_restconf"
*)
echo "usage: $0 cli|netconf|restconf|backend|snmp" # valgrind memleak checks
rm -f $valgrindfile
exit -1
;;
;;
'snmp')
valgrindtest=4 # This means snmp valgrind test
sudo chmod 660 $valgrindfile
: ${DEMWAIT:=15} # valgrind snmp needs some time to get up
clixon_snmp="/usr/bin/valgrind --num-callers=50 --leak-check=full --show-leak-kinds=all --suppressions=./valgrind-clixon.supp --track-fds=yes --trace-children=no --child-silent-after-fork=yes --log-file=$valgrindfile clixon_snmp"
;;
*)
echo "usage: $0 cli|netconf|restconf|backend|snmp" # valgrind memleak checks
rm -f $valgrindfile
exit -1
;;
esac
memerr=0
for test in $pattern; do
# Can happen if no pattern, eg pattern=foo but "foo" does not exist
if [ ! -f $test ]; then
echo -e "\e[31mNo such file: $test"
echo -ne "\e[0m"
exit -1
fi
if [ $testnr != 0 ]; then echo; fi
perfnr=1000 # Limit performance tests
testfile=$test
. ./$test
errcode=$?
endsuite
if [ $errcode -ne 0 ]; then
memerr=1
echo -e "\e[31mError in $test errcode=$errcode"
echo -ne "\e[0m"
exit $errcode
fi
# Can happen if no pattern, eg pattern=foo but "foo" does not exist
if [ ! -f $test ]; then
echo -e "\e[31mNo such file: $test"
echo -ne "\e[0m"
exit -1
fi
if [ $testnr != 0 ]; then echo; fi
perfnr=1000 # Limit performance tests
testfile=$test
. ./$test
errcode=$?
endsuite
if [ $errcode -ne 0 ]; then
memerr=1
echo -e "\e[31mError in $test errcode=$errcode"
echo -ne "\e[0m"
exit $errcode
fi
done
if [ $valgrindtest -eq 1 ]; then
checkvalgrind
sudo rm -f $valgrindfile
checkvalgrind
sudo rm -f $valgrindfile
fi
}
@ -93,8 +93,8 @@ function println(){
length=$(echo "$str" | wc -c)
let i=1
while [ $i -lt $length ]; do
echo -n "="
let i++
echo -n "="
let i++
done
echo
}
@ -108,10 +108,10 @@ fi
# First run sanity
for c in $cmds; do
if [ $c != cli -a $c != netconf -a $c != restconf -a $c != backend -a $c != snmp ]; then
echo "c:$c"
echo "usage: $0 [cli|netconf|restconf|backend|snmp]+"
echo " with no args run all"
exit -1
echo "c:$c"
echo "usage: $0 [cli|netconf|restconf|backend|snmp]+"
echo " with no args run all"
exit -1
fi
done

View file

@ -90,20 +90,20 @@ EOF
# argument: <n> <proto>
function genfile(){
if [ $2 = netconf ]; then
echo -n "<rpc><edit-config><target><candidate/></target><default-operation>replace</default-operation><config><x xmlns=\"urn:example:clixon\">" > $fxml
for (( i=0; i<$1; i++ )); do
echo -n "<y><a>$i</a><b>$i</b></y>" >> $fxml
done
echo "</x></config></edit-config></rpc>]]>]]>" >> $fxml
echo -n "<rpc><edit-config><target><candidate/></target><default-operation>replace</default-operation><config><x xmlns=\"urn:example:clixon\">" > $fxml
for (( i=0; i<$1; i++ )); do
echo -n "<y><a>$i</a><b>$i</b></y>" >> $fxml
done
echo "</x></config></edit-config></rpc>]]>]]>" >> $fxml
else # restconf
echo -n '{"scaling:x":{"y":[' > $fjson
for (( i=0; i<$1; i++ )); do
if [ $i -ne 0 ]; then
echo -n ',' >> $fjson
fi
echo -n "{\"a\":$i,\"b\":\"$i\"}" >> $fjson
done
echo ']}}' >> $fjson
echo -n '{"scaling:x":{"y":[' > $fjson
for (( i=0; i<$1; i++ )); do
if [ $i -ne 0 ]; then
echo -n ',' >> $fjson
fi
echo -n "{\"a\":$i,\"b\":\"$i\"}" >> $fjson
done
echo ']}}' >> $fjson
fi
}
@ -121,40 +121,40 @@ function runnet(){
file=$resdir/$op-netconf-$reqs-$arch
echo -n "$nr " >> $file
case $op in
put)
if [ $reqs = 0 ]; then # Write all in one go
genfile $nr netconf;
{ time -p cat $fxml | $clixon_netconf -qf $cfg -y $fyang ; } 2>&1 | awk '/real/ {print $2}' | tr , . >> $file
else # reqs != 0
{ time -p for (( i=0; i<$reqs; i++ )); do
rnd=$(( ( RANDOM % $nr ) ));
echo "<rpc><edit-config><target><candidate/></target><config><x xmlns=\"urn:example:clixon\"><y><a>$rnd</a><b>$rnd</b></y></x></config></edit-config></rpc>]]>]]>";
put)
if [ $reqs = 0 ]; then # Write all in one go
genfile $nr netconf;
{ time -p cat $fxml | $clixon_netconf -qf $cfg -y $fyang ; } 2>&1 | awk '/real/ {print $2}' | tr , . >> $file
else # reqs != 0
{ time -p for (( i=0; i<$reqs; i++ )); do
rnd=$(( ( RANDOM % $nr ) ));
echo "<rpc><edit-config><target><candidate/></target><config><x xmlns=\"urn:example:clixon\"><y><a>$rnd</a><b>$rnd</b></y></x></config></edit-config></rpc>]]>]]>";
done | $clixon_netconf -qf $cfg -y $fyang > /dev/null; } 2>&1 | awk '/real/ {print $2}' | tr , . >> $file
fi
;;
get)
if [ $reqs = 0 ]; then # Read all in one go
{ time -p echo "<rpc><get-config><source><running/></source></get-config></rpc>]]>]]>" | $clixon_netconf -qf $cfg -y $fyang > /dev/null ; } 2>&1 | awk '/real/ {print $2}' | tr , . >> $file
else # reqs != 0
{ time -p for (( i=0; i<$reqs; i++ )); do
rnd=$(( ( RANDOM % $nr ) ))
echo "<rpc><edit-config><target><candidate/></target><config><x xmlns=\"urn:example:clixon\"><y><a>$rnd</a><b>$rnd</b></y></x></config></edit-config></rpc>]]>]]>"
done | $clixon_netconf -qf $cfg -y $fyang > /dev/null; } 2>&1 | awk '/real/ {print $2}' | tr , . >> $file
fi
;;
delete)
{ time -p for (( i=0; i<$reqs; i++ )); do
rnd=$(( ( RANDOM % $nr ) ))
echo "<rpc><edit-config><target><candidate/></target><config><x xmlns=\"urn:example:clixon\"><y><a>$rnd</a><b>$rnd</b></y></x></config></edit-config></rpc>]]>]]>"
fi
;;
get)
if [ $reqs = 0 ]; then # Read all in one go
{ time -p echo "<rpc><get-config><source><running/></source></get-config></rpc>]]>]]>" | $clixon_netconf -qf $cfg -y $fyang > /dev/null ; } 2>&1 | awk '/real/ {print $2}' | tr , . >> $file
else # reqs != 0
{ time -p for (( i=0; i<$reqs; i++ )); do
rnd=$(( ( RANDOM % $nr ) ))
echo "<rpc><edit-config><target><candidate/></target><config><x xmlns=\"urn:example:clixon\"><y><a>$rnd</a><b>$rnd</b></y></x></config></edit-config></rpc>]]>]]>"
done | $clixon_netconf -qf $cfg -y $fyang > /dev/null; } 2>&1 | awk '/real/ {print $2}' | tr , . >> $file
fi
;;
delete)
{ time -p for (( i=0; i<$reqs; i++ )); do
rnd=$(( ( RANDOM % $nr ) ))
echo "<rpc><edit-config><target><candidate/></target><config><x xmlns=\"urn:example:clixon\"><y><a>$rnd</a><b>$rnd</b></y></x></config></edit-config></rpc>]]>]]>"
done | $clixon_netconf -qf $cfg -y $fyang; } 2>&1 | awk '/real/ {print $2}' | tr , . >> $file
;;
commit)
{ time -p echo "<rpc><commit/></rpc>]]>]]>" | $clixon_netconf -qf $cfg -y $fyang > /dev/null ; } 2>&1 | awk '/real/ {print $2}' | tr , . >> $file
;;
*)
err "Operation not supported" "$op"
exit
;;
;;
commit)
{ time -p echo "<rpc><commit/></rpc>]]>]]>" | $clixon_netconf -qf $cfg -y $fyang > /dev/null ; } 2>&1 | awk '/real/ {print $2}' | tr , . >> $file
;;
*)
err "Operation not supported" "$op"
exit
;;
esac
}
@ -172,39 +172,39 @@ function runrest(){
file=$resdir/$op-restconf-$reqs-$arch
echo -n "$nr " >> $file
case $op in
put)
if [ $reqs = 0 ]; then # Write all in one go
genfile $nr restconf
# restconf @- means from stdin
{ time -p curl $CURLOPTS -X PUT -d @$fjson http://localhost/restconf/data/scaling:x ; } 2>&1 | awk '/real/ {print $2}' | tr , . >> $file
else # Small requests
{ time -p for (( i=0; i<$reqs; i++ )); do
rnd=$(( ( RANDOM % $nr ) ));
curl $CURLOPTS -X PUT http://localhost/restconf/data/scaling:x/y=$rnd -d "{\"scaling:y\":{\"a\":$rnd,\"b\":\"$rnd\"}}"
put)
if [ $reqs = 0 ]; then # Write all in one go
genfile $nr restconf
# restconf @- means from stdin
{ time -p curl $CURLOPTS -X PUT -d @$fjson http://localhost/restconf/data/scaling:x ; } 2>&1 | awk '/real/ {print $2}' | tr , . >> $file
else # Small requests
{ time -p for (( i=0; i<$reqs; i++ )); do
rnd=$(( ( RANDOM % $nr ) ));
curl $CURLOPTS -X PUT http://localhost/restconf/data/scaling:x/y=$rnd -d "{\"scaling:y\":{\"a\":$rnd,\"b\":\"$rnd\"}}"
done ; } 2>&1 | awk '/real/ {print $2}' | tr , .>> $file
#
fi
;;
get)
if [ $reqs = 0 ]; then # Read all in one go
{ time -p curl $CURLOPTS -X GET http://localhost/restconf/data/scaling:x > /dev/null; } 2>&1 | awk '/real/ {print $2}' | tr , . >> $file
else # Small requests
{ time -p for (( i=0; i<$reqs; i++ )); do
rnd=$(( ( RANDOM % $nr ) ));
curl $CURLOPTS -X GET http://localhost/restconf/data/scaling:x/y=$rnd
#
fi
;;
get)
if [ $reqs = 0 ]; then # Read all in one go
{ time -p curl $CURLOPTS -X GET http://localhost/restconf/data/scaling:x > /dev/null; } 2>&1 | awk '/real/ {print $2}' | tr , . >> $file
else # Small requests
{ time -p for (( i=0; i<$reqs; i++ )); do
rnd=$(( ( RANDOM % $nr ) ));
curl $CURLOPTS -X GET http://localhost/restconf/data/scaling:x/y=$rnd
done ; } 2>&1 | awk '/real/ {print $2}' | tr , .>> $file
fi
;;
delete)
{ time -p for (( i=0; i<$reqs; i++ )); do
rnd=$(( ( RANDOM % $nr ) ));
curl $CURLOPTS -X GET http://localhost/restconf/data/scaling:x/y=$rnd
fi
;;
delete)
{ time -p for (( i=0; i<$reqs; i++ )); do
rnd=$(( ( RANDOM % $nr ) ));
curl $CURLOPTS -X GET http://localhost/restconf/data/scaling:x/y=$rnd
done ; } 2>&1 | awk '/real/ {print $2}' | tr , .>> $file
;;
*)
err "Operation not supported" "$op"
exit
;;
;;
*)
err "Operation not supported" "$op"
exit
;;
esac
}
@ -246,26 +246,26 @@ function plot(){
run=$8
if [ $# -ne 8 ]; then
exit "plot should be called with 8 arguments, got $#"
exit "plot should be called with 8 arguments, got $#"
fi
# reset file
new "Create file $resdir/$op-$proto-$reqs-$arch"
echo -n "" > $resdir/$op-$proto-$reqs-$arch
for (( n=$from; n<=$to; n=$n+$step )); do
reset
if [ $can = n ]; then
load $n
if [ $run = n ]; then
commit
fi
fi
new "$op-$proto-$reqs-$arch $n"
if [ $proto = netconf ]; then
runnet $op $n $reqs
else
runrest $op $n $reqs
fi
reset
if [ $can = n ]; then
load $n
if [ $run = n ]; then
commit
fi
fi
new "$op-$proto-$reqs-$arch $n"
if [ $proto = netconf ]; then
runnet $op $n $reqs
else
runrest $op $n $reqs
fi
done
echo # newline
}
@ -281,7 +281,7 @@ function startup(){
mode=startup
if [ $# -ne 3 ]; then
exit "plot should be called with 3 arguments, got $#"
exit "plot should be called with 3 arguments, got $#"
fi
# gnuplot file
@ -294,17 +294,17 @@ function startup(){
sudo touch $dbfile
sudo chmod 666 $dbfile
for (( n=$from; n<=$to; n=$n+$step )); do
new "startup-$arch $n"
new "Generate $n entries to $dbfile"
echo -n "<config><x xmlns=\"urn:example:clixon\">" > $dbfile
for (( i=0; i<$n; i++ )); do
echo -n "<y><a>$i</a><b>$i</b></y>" >> $dbfile
done
echo "</x></config>" >> $dbfile
new "startup-$arch $n"
new "Generate $n entries to $dbfile"
echo -n "<config><x xmlns=\"urn:example:clixon\">" > $dbfile
for (( i=0; i<$n; i++ )); do
echo -n "<y><a>$i</a><b>$i</b></y>" >> $dbfile
done
echo "</x></config>" >> $dbfile
new "Startup backend once -s $mode -f $cfg -y $fyang"
echo -n "$n " >> $gfile
{ time -p sudo $clixon_backend -F1 -D $DBG -s $mode -f $cfg -y $fyang 2> /dev/null; } 2>&1 | awk '/real/ {print $2}' | tr , . >> $gfile
new "Startup backend once -s $mode -f $cfg -y $fyang"
echo -n "$n " >> $gfile
{ time -p sudo $clixon_backend -F1 -D $DBG -s $mode -f $cfg -y $fyang 2> /dev/null; } 2>&1 | awk '/real/ {print $2}' | tr , . >> $gfile
done
echo # newline
@ -318,13 +318,13 @@ if $run; then
new "test params: -f $cfg -y $fyang"
if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -zf $cfg -y $fyang
if [ $? -ne 0 ]; then
err
fi
new "start backend -s init -f $cfg -y $fyang"
start_backend -s init -f $cfg -y $fyang
new "kill old backend"
sudo clixon_backend -zf $cfg -y $fyang
if [ $? -ne 0 ]; then
err
fi
new "start backend -s init -f $cfg -y $fyang"
start_backend -s init -f $cfg -y $fyang
fi
new "kill old restconf daemon"
@ -343,14 +343,14 @@ if $run; then
# Put all tests
for proto in netconf restconf; do
new "$proto put all entries to candidate (restconf:running)"
plot put $proto $step $step $to 0 0 0 # all candidate 0 running 0
new "$proto put all entries to candidate (restconf:running)"
plot put $proto $step $step $to 0 0 0 # all candidate 0 running 0
done
# Get all tests
for proto in netconf restconf; do
new "$proto get all entries from running"
plot get $proto $step $step $to 0 n n # start w full datastore
new "$proto get all entries from running"
plot get $proto $step $step $to 0 n n # start w full datastore
done
# Netconf commit all
@ -360,28 +360,28 @@ if $run; then
# Transactions get/put/delete
reqs=$reqs0
for proto in netconf restconf; do
new "$proto get $reqs from full database"
plot get $proto $step $step $to $reqs n n
new "$proto get $reqs from full database"
plot get $proto $step $step $to $reqs n n
new "$proto put $reqs to full database(replace / alter values)"
plot put $proto $step $step $to $reqs n n
new "$proto put $reqs to full database(replace / alter values)"
plot put $proto $step $step $to $reqs n n
new "$proto delete $reqs from full database(replace / alter values)"
plot delete $proto $step $step $to $reqs n n
new "$proto delete $reqs from full database(replace / alter values)"
plot delete $proto $step $step $to $reqs n n
done
new "Kill restconf daemon"
stop_restconf
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
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
fi # if run

View file

@ -15,7 +15,7 @@
dir=/var/tmp/$0
if $detail; then
if [ ! -d $dir ]; then
mkdir $dir
mkdir $dir
fi
fi
@ -40,18 +40,18 @@ let sumerr=0 # error counter
for testfile in $pattern; do # For lib.sh the variable must be called testfile
echo "Running $testfile"
if $detail; then
./$testfile > $dir/err.log 2>&1
./$testfile > $dir/err.log 2>&1
else
./$testfile > /dev/null 2>&1
./$testfile > /dev/null 2>&1
fi
errcode=$?
if [ $errcode -ne 0 ]; then
let sumerr++
echo -e "\e[31mError in $testfile errcode=$errcode"
echo -ne "\e[0m"
if $detail; then
detail=false; # Just once for now, print at end
fi
echo -e "\e[31mError in $testfile errcode=$errcode"
echo -ne "\e[0m"
if $detail; then
detail=false; # Just once for now, print at end
fi
fi
done
if [ $sumerr -eq 0 ]; then
@ -59,10 +59,10 @@ if [ $sumerr -eq 0 ]; then
else
echo -e "\e[31m"
if [ -f $dir/err.log ]; then
echo "Detailed output of first error:"
echo -ne "\e[0m"
cat $dir/err.log
echo
echo "Detailed output of first error:"
echo -ne "\e[0m"
cat $dir/err.log
echo
fi
echo -e "\e[31m${sumerr} Errors"
echo -ne "\e[0m"

View file

@ -81,7 +81,7 @@ module example-api{
}
}
rpc trigger {
description "trigger an action in the backend";
description "trigger an action in the backend";
}
}
EOF
@ -107,10 +107,10 @@ cat<<EOF > $cfile
static int
trigger_rpc(clicon_handle h, /* Clicon handle */
cxobj *xe, /* Request: <rpc><xn></rpc> */
cbuf *cbret, /* Reply eg <rpc-reply>... */
void *arg, /* client_entry */
void *regarg) /* Argument given at register */
cxobj *xe, /* Request: <rpc><xn></rpc> */
cbuf *cbret, /* Reply eg <rpc-reply>... */
void *arg, /* client_entry */
void *regarg) /* Argument given at register */
{
int retval = -1;
cxobj *xret = NULL;
@ -152,11 +152,11 @@ trigger_rpc(clicon_handle h, /* Clicon handle */
val = NULL;
/* Add key/value vector */
if ((cvk = cvec_new(0)) == NULL){
clicon_err(OE_YANG, errno, "cvec_new");
goto done;
clicon_err(OE_YANG, errno, "cvec_new");
goto done;
}
if ((cv = cvec_add(cvk, CGV_STRING)) == NULL)
goto done;
goto done;
cv_name_set(cv, "k");
cv_string_set(cv, "5");
if ((xv = clixon_xvec_new()) == NULL)
@ -175,7 +175,7 @@ trigger_rpc(clicon_handle h, /* Clicon handle */
done:
clicon_debug(1, "%s retval:%d", __FUNCTION__, retval);
if (cvk)
cvec_free(cvk);
cvec_free(cvk);
if (xret)
xml_free(xret);
if (xv)
@ -202,11 +202,11 @@ clixon_plugin_init(clicon_handle h)
/* From example.yang (clicon) */
if (rpc_callback_register(h, trigger_rpc,
NULL,
"urn:example:api",
"trigger"/* Xml tag when callback is made */
) < 0)
return NULL;
NULL,
"urn:example:api",
"trigger"/* Xml tag when callback is made */
) < 0)
return NULL;
return &api;
}
@ -222,7 +222,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
err
fi
new "start backend"
start_backend -s init -f $cfg
@ -264,7 +264,7 @@ if [ $BE -ne 0 ]; then
# Check if premature kill
pid=`pgrep -u root -f clixon_backend`
if [ -z "$pid" ]; then
err "backend already dead"
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg

View file

@ -243,7 +243,7 @@ echo -n '<x6 xmlns="urn:example:b">' > $xml6
for (( i=0; i<$nr; i++ )); do
echo -n "<yy><kk1>b$i</kk1><kk2>b$i</kk2><zz>foo$i</zz>" >> $xml6
for (( j=0; j<3; j++ )); do
echo -n "<y xmlns=\"urn:example:a\"><k1>a$j</k1><k2>a$j</k2><z>foo$j</z></y>" >> $xml6
echo -n "<y xmlns=\"urn:example:a\"><k1>a$j</k1><k2>a$j</k2><z>foo$j</z></y>" >> $xml6
done
echo -n "</yy>" >> $xml6
done

View file

@ -138,7 +138,7 @@ module example-augment {
when 'derived-from-or-self(if:type, "mymod:some-new-iftype")';
container ospf { /* moved from test_restconf_err (two-level augment) */
leaf reference-bandwidth {
type uint32;
type uint32;
}
}
leaf mandatory-leaf {
@ -161,7 +161,7 @@ module example-augment {
default 80;
}
refine ip {
description "double refine triggered mem error";
description "double refine triggered mem error";
}
}
uses localgroup {
@ -174,7 +174,7 @@ module example-augment {
/* augment choice */
augment "/if:target" {
case datastore {
leaf two{
leaf two{
type uint32;
}
}
@ -188,13 +188,13 @@ module example-augment {
/* augment a list */
augment "/if:interfaces" {
list ports{
key id;
leaf id {
key id;
leaf id {
type int32;
}
leaf str {
}
leaf str {
type string;
}
}
}
}
}
@ -207,7 +207,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
err
fi
new "start backend -s init -f $cfg"
start_backend -s init -f $cfg
@ -337,7 +337,7 @@ if [ $BE -ne 0 ]; then
# Check if premature kill
pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then
err "backend already dead"
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg

View file

@ -53,9 +53,9 @@ module augment {
leaf name{
type string;
}
leaf enable {
type boolean;
default true;
leaf enable {
type boolean;
default true;
}
}
}
@ -79,7 +79,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
err
fi
new "start backend -s startup -f $cfg"
start_backend -s startup -f $cfg
@ -108,7 +108,7 @@ if [ $BE -ne 0 ]; then
# Check if premature kill
pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then
err "backend already dead"
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg

View file

@ -44,11 +44,11 @@ module example-lib {
description "Global base default state";
type string;
default "gbds";
}
}
leaf gbos{
description "Global base optional state";
type string;
}
}
container nopres{
description "This should be removed";
}
@ -57,18 +57,18 @@ module example-lib {
list parameter{
key name;
leaf name{
type string;
type string;
}
container param-state {
config false;
leaf lbds{
description "Local base default state";
type string;
default "lbds";
description "Local base default state";
type string;
default "lbds";
}
leaf lbos{
description "Local base optional state";
type string;
description "Local base optional state";
type string;
}
}
}
@ -92,11 +92,11 @@ module example-augment {
description "Global augmented default state";
type string;
default "gads";
}
}
leaf gaos{
description "Global augmented optional state";
type string;
}
}
}
/* Augments state in config in-line */
augment "/lib:base-config/lib:parameter/lib:param-state" {
@ -104,11 +104,11 @@ module example-augment {
description "Local augmented default state";
type string;
default "lads";
}
}
leaf laos{
description "Local augmented optional state";
type string;
}
}
}
}
EOF
@ -124,9 +124,9 @@ function testrun()
new "get config"
if [ -z "$config" ]; then
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><get-config><source><running/></source></get-config></rpc>" "^<rpc-reply $DEFAULTNS><data/></rpc-reply>$"
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><get-config><source><running/></source></get-config></rpc>" "^<rpc-reply $DEFAULTNS><data/></rpc-reply>$"
else
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><get-config><source><running/></source></get-config></rpc>" "^<rpc-reply $DEFAULTNS><data>$config</data></rpc-reply>$"
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><get-config><source><running/></source></get-config></rpc>" "^<rpc-reply $DEFAULTNS><data>$config</data></rpc-reply>$"
fi
new "get state"
@ -139,7 +139,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
err
fi
new "start backend -s init -f $cfg -- -sS $fstate"
start_backend -s init -f $cfg -- -sS $fstate
@ -253,7 +253,7 @@ if [ $BE -ne 0 ]; then
# Check if premature kill
pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then
err "backend already dead"
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg

View file

@ -48,7 +48,7 @@ module example-lib {
list parameter{
key name;
leaf name{
type string;
type string;
}
}
}
@ -69,7 +69,7 @@ module example-augment1 {
augment "/lib:base-config/lib:parameter" {
container aug1{
description "Local augmented optional";
}
}
}
}
EOF
@ -93,7 +93,7 @@ module example-augment2 {
leaf aug2{
description "Local augmented optional";
type string;
}
}
}
}
EOF
@ -104,7 +104,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
err
fi
new "start backend -s init -f $cfg"
start_backend -s init -f $cfg
@ -130,7 +130,7 @@ if [ $BE -ne 0 ]; then
# Check if premature kill
pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then
err "backend already dead"
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg

View file

@ -45,20 +45,20 @@ module clixon-example {
prefix ex;
/* Generic config data */
container table{
list parameter{
key name;
leaf name{
type string;
}
leaf value{
type string;
}
leaf stat{
description "Inline state data for example application";
config false;
type int32;
}
}
list parameter{
key name;
leaf name{
type string;
}
leaf value{
type string;
}
leaf stat{
description "Inline state data for example application";
config false;
type int32;
}
}
}
}
EOF
@ -81,11 +81,11 @@ commit("Commit the changes"), cli_commit();
quit("Quit"), cli_quit();
show("Show a particular state of the system"){
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);
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_show_auto_mode("running", "xml", false, true);
}
@ -117,7 +117,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -z -f $cfg
if [ $? -ne 0 ]; then
err
err
fi
new "start backend -s startup -f $cfg -- -sS $fstate"
start_backend -s startup -f $cfg -- -sS $fstate
@ -325,7 +325,7 @@ if [ $BE -ne 0 ]; then
# Check if premature kill
pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then
err "backend already dead"
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg

View file

@ -87,10 +87,10 @@ module example {
}
list index{
key i;
leaf i{
type string;
}
leaf iv{
leaf i{
type string;
}
leaf iv{
type string;
}
}
@ -170,7 +170,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -z -f $cfg
if [ $? -ne 0 ]; then
err
err
fi
new "start backend -s init -f $cfg"
start_backend -s init -f $cfg
@ -208,10 +208,10 @@ module example {
}
list index{
key i;
leaf i{
type string;
}
leaf iv{
leaf i{
type string;
}
leaf iv{
type string;
}
}
@ -241,10 +241,10 @@ module example {
}
list index{
key i;
leaf i{
type string;
}
leaf iv{
leaf i{
type string;
}
leaf iv{
type string;
}
}
@ -336,10 +336,10 @@ module example-augment {
}
list index{
key i;
leaf i{
type string;
}
leaf iv{
leaf i{
type string;
}
leaf iv{
type string;
}
}
@ -355,7 +355,7 @@ if [ $BE -ne 0 ]; then
# Check if premature kill
pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then
err "backend already dead"
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg

View file

@ -66,26 +66,26 @@ module $APPNAME {
type string;
}
container config {
leaf enabled {
type boolean;
default false;
description "Whether the interface is enabled or not.";
}
leaf enabled {
type boolean;
default false;
description "Whether the interface is enabled or not.";
}
}
container state {
config false;
leaf oper-status {
type enumeration {
enum UP {
value 1;
description "Ready to pass packets.";
}
enum DOWN {
value 2;
description "The interface does not pass any packets.";
}
}
}
config false;
leaf oper-status {
type enumeration {
enum UP {
value 1;
description "Ready to pass packets.";
}
enum DOWN {
value 2;
description "The interface does not pass any packets.";
}
}
}
}
}
}
@ -105,26 +105,26 @@ module ${APPNAME}2 {
type string;
}
container config {
leaf enabled {
type boolean;
default false;
description "Whether the interface is enabled or not.";
}
leaf enabled {
type boolean;
default false;
description "Whether the interface is enabled or not.";
}
}
container state {
config false;
leaf oper-status {
type enumeration {
enum UP {
value 1;
description "Ready to pass packets.";
}
enum DOWN {
value 2;
description "The interface does not pass any packets.";
}
}
}
config false;
leaf oper-status {
type enumeration {
enum UP {
value 1;
description "Ready to pass packets.";
}
enum DOWN {
value 2;
description "The interface does not pass any packets.";
}
}
}
}
}
}
@ -176,29 +176,29 @@ COMPRESS=$(cat <<EOF
<rule>
<name>compress</name>
<operation>compress</operation>
<yang-keyword>container</yang-keyword>
<yang-keyword-child>list</yang-keyword-child>
<yang-keyword>container</yang-keyword>
<yang-keyword-child>list</yang-keyword-child>
</rule>
EOF
)
else
COMPRESS=""
COMPRESS=""
fi
if $openconfig; then
OCOMPRESS=$(cat <<EOF
<rule>
<name>openconfig compress</name>
<operation>compress</operation>
<yang-keyword>container</yang-keyword>
<schema-nodeid>config</schema-nodeid>
<!--schema-nodeid>state</schema-nodeid-->
<!--module-name>openconfig*</module-name-->
<extension>oc-ext:openconfig-version</extension>
<operation>compress</operation>
<yang-keyword>container</yang-keyword>
<schema-nodeid>config</schema-nodeid>
<!--schema-nodeid>state</schema-nodeid-->
<!--module-name>openconfig*</module-name-->
<extension>oc-ext:openconfig-version</extension>
</rule>"
EOF
)
else
OCOMPRESS=""
OCOMPRESS=""
fi
cat <<EOF > $cfg
<clixon-config xmlns="http://clicon.org/config">
@ -239,7 +239,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -z -f $cfg
if [ $? -ne 0 ]; then
err
err
fi
new "start backend -s init -f $cfg -- -sS $fstate"
start_backend -s init -f $cfg -- -sS $fstate
@ -258,14 +258,14 @@ function testrun()
compress=$2
if [ $listkw = kw-all ]; then
name=" name"
name=" name"
else
name=
name=
fi
if $compress; then
table=
table=
else
table=" table"
table=" table"
fi
new "set a"
@ -392,7 +392,7 @@ if [ $BE -ne 0 ]; then
# Check if premature kill
pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then
err "backend already dead"
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg

View file

@ -47,18 +47,18 @@ module clixon-example {
prefix ex;
/* Generic config data */
container table{
list parameter{
key name;
leaf name{
type string;
}
leaf value{
type string;
}
leaf-list array1{
type string;
list parameter{
key name;
leaf name{
type string;
}
}
leaf value{
type string;
}
leaf-list array1{
type string;
}
}
}
}
EOF
@ -101,7 +101,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -z -f $cfg
if [ $? -ne 0 ]; then
err
err
fi
new "start backend -s init -f $cfg"
start_backend -s init -f $cfg
@ -220,7 +220,7 @@ if [ $BE -ne 0 ]; then
# Check if premature kill
pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then
err "backend already dead"
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg

View file

@ -22,20 +22,20 @@ module clixon-example {
prefix ex;
/* Generic config data */
container table{
list parameter{
key name;
leaf name{
type string;
}
leaf value{
type string;
}
leaf stat{
description "Inline state data for example application";
config false;
type int32;
}
}
list parameter{
key name;
leaf name{
type string;
}
leaf value{
type string;
}
leaf stat{
description "Inline state data for example application";
config false;
type int32;
}
}
}
}
EOF
@ -47,20 +47,20 @@ module clixon-example2 {
prefix ex2;
/* Alt config data */
container table2{
list parameter{
key name;
leaf name{
type string;
}
leaf value{
type string;
}
leaf stat{
description "Inline state data for example application";
config false;
type int32;
}
}
list parameter{
key name;
leaf name{
type string;
}
leaf value{
type string;
}
leaf stat{
description "Inline state data for example application";
config false;
type int32;
}
}
}
}
EOF
@ -80,11 +80,11 @@ commit("Commit the changes"), cli_commit();
quit("Quit"), cli_quit();
show("Show a particular state of the system"){
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);
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_show_auto_mode("running", "xml", false, true);
}
@ -146,7 +146,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -z -f $cfg
if [ $? -ne 0 ]; then
err
err
fi
new "start backend -s startup -f $cfg -- -sS $fstate"
start_backend -s startup -f $cfg -- -sS $fstate
@ -207,7 +207,7 @@ if [ $BE -ne 0 ]; then
# Check if premature kill
pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then
err "backend already dead"
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg

View file

@ -99,7 +99,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -z -f $cfg
if [ $? -ne 0 ]; then
err
err
fi
new "start backend -s init -f $cfg"
start_backend -s init -f $cfg
@ -148,7 +148,7 @@ if [ $BE -ne 0 ]; then
# Check if premature kill
pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then
err "backend already dead"
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg

View file

@ -56,10 +56,10 @@ module $APPNAME {
}
list index{
key i;
leaf i{
type string;
}
leaf iv{
leaf i{
type string;
}
leaf iv{
type string;
}
}
@ -118,7 +118,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -z -f $cfg
if [ $? -ne 0 ]; then
err
err
fi
new "start backend -s startup -f $cfg"
start_backend -s startup -f $cfg
@ -157,7 +157,7 @@ if [ $BE -ne 0 ]; then
# Check if premature kill
pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then
err "backend already dead"
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg

View file

@ -127,7 +127,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -z -f $cfg
if [ $? -ne 0 ]; then
err
err
fi
new "start backend -s init -f $cfg -- -sS $fstate"
start_backend -s init -f $cfg -- -sS $fstate
@ -204,7 +204,7 @@ if [ $BE -ne 0 ]; then
# Check if premature kill
pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then
err "backend already dead"
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg

View file

@ -19,7 +19,7 @@ cat <<EOF > $cfg
<clixon-config xmlns="http://clicon.org/config">
<CLICON_CONFIGFILE>$cfg</CLICON_CONFIGFILE>
<CLICON_YANG_DIR>${YANG_INSTALLDIR}</CLICON_YANG_DIR>
<CLICON_YANG_MAIN_FILE>$fyang</CLICON_YANG_MAIN_FILE>
<CLICON_YANG_MAIN_FILE>$fyang</CLICON_YANG_MAIN_FILE>
<CLICON_BACKEND_DIR>$dir/backend</CLICON_BACKEND_DIR>
<CLICON_CLISPEC_DIR>/usr/local/lib/$APPNAME/clispec</CLICON_CLISPEC_DIR>
<CLICON_CLI_DIR>/usr/local/lib/$APPNAME/cli</CLICON_CLI_DIR>
@ -36,32 +36,32 @@ module clixon-example{
namespace "urn:example:clixon";
prefix ex;
rpc example {
description "Some example input/output for testing RFC7950 7.14.
description "Some example input/output for testing RFC7950 7.14.
RPC simply echoes the input for debugging.";
input {
leaf x {
description
"If a leaf in the input tree has a 'mandatory' statement with
input {
leaf x {
description
"If a leaf in the input tree has a 'mandatory' statement with
the value 'true', the leaf MUST be present in an RPC invocation.";
type string;
mandatory true;
}
leaf y {
description
type string;
mandatory true;
}
leaf y {
description
"If a leaf in the input tree has a 'mandatory' statement with the
value 'true', the leaf MUST be present in an RPC invocation.";
type string;
default "42";
}
}
output {
leaf x {
type string;
}
leaf y {
type string;
}
}
type string;
default "42";
}
}
output {
leaf x {
type string;
}
leaf y {
type string;
}
}
}
}
EOF
@ -122,10 +122,10 @@ static netconf_test api(clixon_plugin_init, plugin_start, plugin_exit);
/*! Local example netconf rpc callback
*/
int example_rpc(clicon_handle h,
cxobj *xe,
cbuf *cbret,
void *arg,
void *regarg)
cxobj *xe,
cbuf *cbret,
void *arg,
void *regarg)
{
int retval = -1;
cxobj *x = NULL;
@ -134,12 +134,12 @@ int example_rpc(clicon_handle h,
/* get namespace from rpc name, return back in each output parameter */
if ((ns = xml_find_type_value(xe, NULL, "xmlns", CX_ATTR)) == NULL)
{
clicon_err(OE_XML, ENOENT, "No namespace given in rpc %s", xml_name(xe));
goto done;
clicon_err(OE_XML, ENOENT, "No namespace given in rpc %s", xml_name(xe));
goto done;
}
cprintf(cbret, "<rpc-reply xmlns=\"%s\">", NETCONF_BASE_NAMESPACE);
if (!xml_child_nr_type(xe, CX_ELMNT))
cprintf(cbret, "<ok/>");
cprintf(cbret, "<ok/>");
else{
while ((x = xml_child_each(xe, x, CX_ELMNT)) != NULL) {
if (xmlns_set(x, NULL, ns) < 0)
@ -165,7 +165,7 @@ clixon_plugin_api* clixon_plugin_init(clicon_handle h)
clicon_debug(1, "%s netconf", __FUNCTION__);
/* Register local netconf rpc client (note not backend rpc client) */
if (rpc_callback_register(h, example_rpc, NULL, "urn:example:clixon", "example") < 0)
return NULL;
return NULL;
return api.get_api();
}
@ -180,7 +180,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
err
fi
new "start backend -s init -f $cfg"
start_backend -s init -f $cfg

View file

@ -111,16 +111,16 @@ module system{
presence true;
choice name {
container udp {
leaf udp1{
type string;
leaf udp1{
type string;
}
leaf udp2{
type string;
leaf udp2{
type string;
}
}
container tcp {
leaf tcp1{
type string;
leaf tcp1{
type string;
}
}
}
@ -131,27 +131,27 @@ module system{
choice name {
case a {
leaf a1 {
type string;
type string;
}
leaf a2 {
mandatory true;
type string;
mandatory true;
type string;
}
}
case b {
leaf b1 {
type string;
type string;
}
}
case c {
leaf c1 {
mandatory true;
type string;
leaf c1 {
mandatory true;
type string;
}
choice c2 {
case cc1 {
leaf ccc1 {
type string;
choice c2 {
case cc1 {
leaf ccc1 {
type string;
}
}
}
@ -166,14 +166,14 @@ module system{
choice c {
case c1 {
leaf c1 {
mandatory true;
type string;
}
choice c1c {
case c1c1 {
leaf c1c1l {
mandatory true;
type string;
}
choice c1c {
case c1c1 {
leaf c1c1l {
type string;
}
}
}
}
}
@ -201,8 +201,8 @@ discard("Discard edits (rollback 0)"), discard_changes();
show("Show a particular state of the system"){
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);
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
@ -213,7 +213,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
err
fi
sudo pkill -f clixon_backend # to be sure
@ -479,7 +479,7 @@ if [ $BE -ne 0 ]; then
# Check if premature kill
pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then
err "backend already dead"
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg

View file

@ -37,43 +37,43 @@ module system{
namespace "urn:example:config";
prefix ex;
container c {
choice top{
case topA {
choice A{
mandatory true;
case A1{
leaf A1x{
type string;
}
choice top{
case topA {
choice A{
mandatory true;
case A1{
leaf A1x{
type string;
}
}
case A2{
leaf A2x{
type string;
}
case A2{
leaf A2x{
type string;
}
}
}
leaf Ay{
type string;
}
}
case topB{
choice B{
case B1{
leaf B1x{
type string;
}
}
case B2{
leaf B2x{
type string;
}
}
}
leaf By{
type string;
}
}
}
}
leaf Ay{
type string;
}
}
case topB{
choice B{
case B1{
leaf B1x{
type string;
}
}
case B2{
leaf B2x{
type string;
}
}
}
leaf By{
type string;
}
}
}
}
}
EOF
@ -106,7 +106,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
err
fi
sudo pkill -f clixon_backend # to be sure
@ -167,7 +167,7 @@ if [ $BE -ne 0 ]; then
# Check if premature kill
pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then
err "backend already dead"
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg

View file

@ -45,60 +45,60 @@ module clixon-example {
namespace "urn:example:clixon";
prefix ex;
import ietf-interfaces {
prefix if;
prefix if;
}
import ietf-ip {
prefix ip;
prefix ip;
}
import iana-if-type {
prefix ianaift;
prefix ianaift;
}
import clixon-autocli{
prefix autocli;
prefix autocli;
}
/* Example interface type for tests, local callbacks, etc */
identity eth {
base if:interface-type;
base if:interface-type;
}
/* Generic config data */
container table{
list parameter{
key name;
leaf name{
type string;
}
leaf value{
type string;
}
}
list parameter{
key name;
leaf name{
type string;
}
leaf value{
type string;
}
}
}
rpc example {
description "Some example input/output for testing RFC7950 7.14.
description "Some example input/output for testing RFC7950 7.14.
RPC simply echoes the input for debugging.";
input {
leaf x {
description
"If a leaf in the input tree has a 'mandatory' statement with
input {
leaf x {
description
"If a leaf in the input tree has a 'mandatory' statement with
the value 'true', the leaf MUST be present in an RPC invocation.";
type string;
mandatory true;
}
leaf y {
description
"If a leaf in the input tree has a 'mandatory' statement with the
type string;
mandatory true;
}
leaf y {
description
"If a leaf in the input tree has a 'mandatory' statement with the
value 'true', the leaf MUST be present in an RPC invocation.";
type string;
default "42";
}
}
output {
leaf x {
type string;
}
leaf y {
type string;
}
}
type string;
default "42";
}
}
output {
leaf x {
type string;
}
leaf y {
type string;
}
}
}
}
EOF
@ -120,23 +120,23 @@ quit("Quit"), cli_quit();
shell("System command") <source:rest>, cli_start_shell("bash");
copy("Copy and create a new object"){
interface("Copy interface"){
(<name:string>|<name:string expand_dbvar("candidate","/ietf-interfaces:interfaces/interface=%s/name")>("name of interface to copy from")) to("Copy to interface") <toname:string>("Name of interface to copy to"), cli_copy_config("candidate","//interface[%s='%s']","urn:ietf:params:xml:ns:yang:ietf-interfaces","name","name","toname");
(<name:string>|<name:string expand_dbvar("candidate","/ietf-interfaces:interfaces/interface=%s/name")>("name of interface to copy from")) to("Copy to interface") <toname:string>("Name of interface to copy to"), cli_copy_config("candidate","//interface[%s='%s']","urn:ietf:params:xml:ns:yang:ietf-interfaces","name","name","toname");
}
}
discard("Discard edits (rollback 0)"), discard_changes();
debug("Debugging parts of the system"){
cli("Set cli debug") <level:int32>("Set debug level (0..n)"), cli_debug_cli();
cli("Set cli debug") <level:int32>("Set debug level (0..n)"), cli_debug_cli();
}
show("Show a particular state of the system"){
xpath("Show configuration") <xpath:string>("XPATH expression") <ns:string>("Namespace"), show_conf_xpath("candidate");
compare("Compare candidate and running databases"), compare_dbs((int32)0);{
xml("Show comparison in xml"), compare_dbs((int32)0);
text("Show comparison in text"), compare_dbs((int32)1);
xml("Show comparison in xml"), compare_dbs((int32)0);
text("Show comparison in text"), compare_dbs((int32)1);
}
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);
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"){
@ -146,10 +146,10 @@ save("Save candidate configuration to XML file") <filename:string>("Filename (lo
text("Save configuration as TEXT"), save_config_file("candidate","filename", "text");
}
load("Load configuration from XML file") <filename:string>("Filename (local filename)"),load_config_file("filename", "replace");{
cli("Replace candidate with file containing CLI commands"), load_config_file("filename", "replace", "cli");
xml("Replace candidate with file containing XML"), load_config_file("filename", "replace", "xml");
json("Replace candidate with file containing JSON"), load_config_file("filename", "replace", "json");
text("Replace candidate with file containing TEXT"), load_config_file("filename", "replace", "text");
cli("Replace candidate with file containing CLI commands"), load_config_file("filename", "replace", "cli");
xml("Replace candidate with file containing XML"), load_config_file("filename", "replace", "xml");
json("Replace candidate with file containing JSON"), load_config_file("filename", "replace", "json");
text("Replace candidate with file containing TEXT"), load_config_file("filename", "replace", "text");
}
rpc("example rpc") <a:string>("routing instance"), example_client_rpc("");
@ -167,7 +167,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -z -f $cfg
if [ $? -ne 0 ]; then
err
err
fi
new "start backend -s init -f $cfg"
start_backend -s init -f $cfg
@ -272,7 +272,7 @@ if [ $BE -ne 0 ]; then
# Check if premature kill
pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then
err "backend already dead"
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg

View file

@ -83,7 +83,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -z -f $cfg
if [ $? -ne 0 ]; then
err
err
fi
new "start backend -s init -f $cfg"
start_backend -s init -f $cfg
@ -117,7 +117,7 @@ if [ $BE -ne 0 ]; then
# Check if premature kill
pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then
err "backend already dead"
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg

View file

@ -26,37 +26,37 @@ module example {
prefix ex;
typedef uniontype {
type union {
type enumeration {
type enumeration {
enum u1;
enum u2;
}
type string;
type string;
}
}
/* Generic config data */
container tableleaf{
list parleaf{
description "leaf is union type";
key name;
leaf name{
type string;
}
leaf value{
type uniontype;
}
}
list parleaf{
description "leaf is union type";
key name;
leaf name{
type string;
}
leaf value{
type uniontype;
}
}
}
container tablekey{
list parkey{
description "key is union type";
key name;
leaf name{
type uniontype;
}
leaf value{
type string;
}
}
list parkey{
description "key is union type";
key name;
leaf name{
type uniontype;
}
leaf value{
type string;
}
}
}
}
EOF
@ -115,7 +115,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -z -f $cfg
if [ $? -ne 0 ]; then
err
err
fi
new "start backend -s init -f $cfg"
start_backend -s init -f $cfg
@ -169,7 +169,7 @@ if [ $BE -ne 0 ]; then
# Check if premature kill
pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then
err "backend already dead"
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg

View file

@ -22,7 +22,7 @@ cat <<EOF > $cfg
<clixon-config xmlns="http://clicon.org/config">
<CLICON_CONFIGFILE>$cfg</CLICON_CONFIGFILE>
<CLICON_YANG_DIR>${YANG_INSTALLDIR}</CLICON_YANG_DIR>
<CLICON_YANG_MAIN_FILE>$fyang</CLICON_YANG_MAIN_FILE>
<CLICON_YANG_MAIN_FILE>$fyang</CLICON_YANG_MAIN_FILE>
<CLICON_BACKEND_DIR>/usr/local/lib/$APPNAME/backend</CLICON_BACKEND_DIR>
<CLICON_CLISPEC_DIR>$clidir</CLICON_CLISPEC_DIR>
<CLICON_CLI_DIR>/usr/local/lib/$APPNAME/cli</CLICON_CLI_DIR>
@ -39,7 +39,7 @@ module clixon-example{
namespace "urn:example:clixon";
prefix ex;
list list1{
key "key1";
key "key1";
leaf key1{
type string;
}
@ -47,7 +47,7 @@ module clixon-example{
key "key2";
leaf key2{
type string;
}
}
}
}
}
@ -82,7 +82,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -z -f $cfg
if [ $? -ne 0 ]; then
err
err
fi
new "start backend -s init -f $cfg"
start_backend -s init -f $cfg
@ -111,7 +111,7 @@ if [ $BE -ne 0 ]; then
# Check if premature kill
pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then
err "backend already dead"
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg

View file

@ -18,7 +18,7 @@ cat <<EOF > $cfg
<clixon-config xmlns="http://clicon.org/config">
<CLICON_CONFIGFILE>$cfg</CLICON_CONFIGFILE>
<CLICON_YANG_DIR>${YANG_INSTALLDIR}</CLICON_YANG_DIR>
<CLICON_YANG_MAIN_FILE>$fyang</CLICON_YANG_MAIN_FILE>
<CLICON_YANG_MAIN_FILE>$fyang</CLICON_YANG_MAIN_FILE>
<CLICON_BACKEND_DIR>/usr/local/lib/$APPNAME/backend</CLICON_BACKEND_DIR>
<CLICON_CLISPEC_DIR>/usr/local/lib/$APPNAME/clispec</CLICON_CLISPEC_DIR>
<CLICON_CLI_DIR>/usr/local/lib/$APPNAME/cli</CLICON_CLI_DIR>
@ -49,7 +49,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -z -f $cfg
if [ $? -ne 0 ]; then
err
err
fi
new "start backend -s init -f $cfg"
start_backend -s init -f $cfg
@ -135,7 +135,7 @@ if [ $BE -ne 0 ]; then
# Check if premature kill
pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then
err "backend already dead"
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg

View file

@ -59,87 +59,87 @@ module example-leafref{
}
/* Basic config data */
container table{
list parameter{
key name;
leaf name{
type uint32;
}
leaf value{
type string;
}
list parameter{
key name;
leaf name{
type uint32;
}
leaf value{
type string;
}
}
}
/* first level leafref */
container leafrefs {
description "Leafref relative path, no require-instance";
list leafref{
key name;
leaf name {
type leafref{
list leafref{
key name;
leaf name {
type leafref{
path "../../../table/parameter/name";
require-instance false;
require-instance false;
}
}
}
}
/* first level leafref absolute */
/* first level leafref absolute */
container leafrefsabs {
description "Leafref absolute path, no require-instance";
list leafref{
key name;
leaf name {
type leafref{
list leafref{
key name;
leaf name {
type leafref{
path "/table/parameter/name";
require-instance false;
require-instance false;
}
}
}
}
/* first level leafref require-instance */
/* first level leafref require-instance */
container leafrefsreqinst {
description "Leafref absolute path, require-instance true";
list leafref{
key name;
leaf name {
type leafref{
list leafref{
key name;
leaf name {
type leafref{
path "/table/parameter/name";
require-instance true;
require-instance true;
}
}
}
}
/* first level identityrefs */
container identityrefs {
list identityref{
description "Identityref base";
key name;
leaf name {
type identityref{
base "ex:crypto-alg";
list identityref{
description "Identityref base";
key name;
leaf name {
type identityref{
base "ex:crypto-alg";
}
}
}
}
/* second level leafref */
container leafrefs2 {
list leafref{
key name;
leaf name {
type leafref{
list leafref{
key name;
leaf name {
type leafref{
path "../../../leafrefs/leafref/name";
require-instance false;
require-instance false;
}
}
}
}
/* second level identityref */
container identityrefs2 {
list identityref{
key name;
leaf name {
type leafref{
list identityref{
key name;
leaf name {
type leafref{
path "../../../identityrefs/identityref/name";
require-instance false;
require-instance false;
}
}
}
@ -196,7 +196,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -z -f $cfg
if [ $? -ne 0 ]; then
err
err
fi
new "start backend -s startup -f $cfg"
start_backend -s startup -f $cfg
@ -296,7 +296,7 @@ if [ $BE -ne 0 ]; then
# Check if premature kill
pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then
err "backend already dead"
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg

View file

@ -39,30 +39,30 @@ module $APPNAME{
container ex {
list x{
key "a b" ;
leaf a {
type string;
}
leaf b {
type enumeration{
enum v1;
enum v2;
enum v3;
}
}
leaf a {
type string;
}
leaf b {
type enumeration{
enum v1;
enum v2;
enum v3;
}
}
}
list y{
key "a b" ;
ordered-by user;
leaf a {
type string;
}
leaf b {
type enumeration{
enum v1;
enum v2;
enum v3;
}
}
leaf a {
type string;
}
leaf b {
type enumeration{
enum v1;
enum v2;
enum v3;
}
}
}
}
}
@ -73,7 +73,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -z -f $cfg
if [ $? -ne 0 ]; then
err
err
fi
new "start backend -s init -f $cfg"
start_backend -s init -f $cfg
@ -130,7 +130,7 @@ if [ $BE -ne 0 ]; then
# Check if premature kill
pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then
err "backend already dead"
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg

View file

@ -21,7 +21,7 @@ cat <<EOF > $cfg
<clixon-config xmlns="http://clicon.org/config">
<CLICON_CONFIGFILE>$cfg</CLICON_CONFIGFILE>
<CLICON_YANG_DIR>${YANG_INSTALLDIR}</CLICON_YANG_DIR>
<CLICON_YANG_MAIN_FILE>$fyang</CLICON_YANG_MAIN_FILE>
<CLICON_YANG_MAIN_FILE>$fyang</CLICON_YANG_MAIN_FILE>
<CLICON_BACKEND_DIR>/usr/local/lib/$APPNAME/backend</CLICON_BACKEND_DIR>
<CLICON_CLISPEC_DIR>$clidir</CLICON_CLISPEC_DIR>
<CLICON_CLI_DIR>/usr/local/lib/$APPNAME/cli</CLICON_CLI_DIR>
@ -59,7 +59,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -z -f $cfg
if [ $? -ne 0 ]; then
err
err
fi
new "start backend -s init -f $cfg"
start_backend -s init -f $cfg
@ -100,7 +100,7 @@ if [ $BE -ne 0 ]; then
# Check if premature kill
pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then
err "backend already dead"
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg

View file

@ -26,7 +26,7 @@ cat <<EOF > $cfg
<clixon-config xmlns="http://clicon.org/config">
<CLICON_CONFIGFILE>$cfg</CLICON_CONFIGFILE>
<CLICON_YANG_DIR>${YANG_INSTALLDIR}</CLICON_YANG_DIR>
<CLICON_YANG_MAIN_FILE>$fyang</CLICON_YANG_MAIN_FILE>
<CLICON_YANG_MAIN_FILE>$fyang</CLICON_YANG_MAIN_FILE>
<CLICON_BACKEND_DIR>/usr/local/lib/$APPNAME/backend</CLICON_BACKEND_DIR>
<CLICON_CLISPEC_DIR>$clidir</CLICON_CLISPEC_DIR>
<CLICON_CLI_DIR>/usr/local/lib/$APPNAME/cli</CLICON_CLI_DIR>
@ -81,7 +81,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -z -f $cfg
if [ $? -ne 0 ]; then
err
err
fi
new "start backend -s init -f $cfg"
start_backend -s init -f $cfg
@ -119,7 +119,7 @@ if [ $BE -ne 0 ]; then
# Check if premature kill
pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then
err "backend already dead"
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg

View file

@ -39,14 +39,14 @@ module clixon-example{
prefix ex;
/* Generic config data */
container table{
list parameter{
key name;
leaf name{
type string;
}
leaf value{
type string;
}
list parameter{
key name;
leaf name{
type string;
}
leaf value{
type string;
}
}
}
}
@ -74,7 +74,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -z -f $cfg
if [ $? -ne 0 ]; then
err
err
fi
new "start backend -s init -f $cfg"
start_backend -s init -f $cfg
@ -94,7 +94,7 @@ if [ $BE -ne 0 ]; then
# Check if premature kill
pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then
err "backend already dead"
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg

View file

@ -22,37 +22,37 @@ module example {
prefix ex;
typedef uniontype {
type union {
type enumeration {
type enumeration {
enum u1;
enum u2;
}
type string;
type string;
}
}
/* Generic config data */
container tableleaf{
list parleaf{
description "leaf is union type";
key name;
leaf name{
type string;
}
leaf value{
type uniontype;
}
}
list parleaf{
description "leaf is union type";
key name;
leaf name{
type string;
}
leaf value{
type uniontype;
}
}
}
container tablekey{
list parkey{
description "key is union type";
key name;
leaf name{
type uniontype;
}
leaf value{
type string;
}
}
list parkey{
description "key is union type";
key name;
leaf name{
type uniontype;
}
leaf value{
type string;
}
}
}
}
EOF
@ -103,7 +103,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -z -f $cfg
if [ $? -ne 0 ]; then
err
err
fi
new "start backend -s init -f $cfg"
start_backend -s init -f $cfg
@ -155,7 +155,7 @@ if [ $BE -ne 0 ]; then
# Check if premature kill
pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then
err "backend already dead"
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg

View file

@ -39,15 +39,15 @@ module example {
/* Generic config data */
container table{
list parameter{
key name;
leaf name{
type string;
}
leaf value{
type string;
}
}
list parameter{
key name;
leaf name{
type string;
}
leaf value{
type string;
}
}
}
}
EOF
@ -57,7 +57,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -z -f $cfg
if [ $? -ne 0 ]; then
err
err
fi
new "start backend -s init -f $cfg"
start_backend -s init -f $cfg
@ -89,7 +89,7 @@ if [ $BE -ne 0 ]; then
# Check if premature kill
pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then
err "backend already dead"
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg

View file

@ -52,21 +52,21 @@ module clixon-client {
namespace "urn:example:clixon-client";
prefix exc;
description
"Clixon client example yang";
"Clixon client example yang";
revision 2021-01-14 {
description "Added table/paramater/value as the primary data example";
}
/* Generic config data */
container table{
list parameter{
key name;
leaf name{
type string;
}
leaf value{
type uint32;
}
}
key name;
leaf name{
type string;
}
leaf value{
type uint32;
}
}
}
}
EOF
@ -111,7 +111,7 @@ main(int argc,
done:
clixon_client_disconnect(ch);
clixon_client_terminate(h);
printf("done\n"); /* for test output */
printf("done\n"); /* for test output */
return retval;
}
EOF
@ -132,7 +132,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
err
fi
new "start backend"
start_backend -s init -f $cfg
@ -174,7 +174,7 @@ if [ $BE -ne 0 ]; then
# Check if premature kill
pid=`pgrep -u root -f clixon_backend`
if [ -z "$pid" ]; then
err "backend already dead"
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg

View file

@ -47,12 +47,12 @@ module clixon-example{
/* Generic config data */
container table{
list parameter{
key name;
leaf name{
type string;
}
}
list parameter{
key name;
leaf name{
type string;
}
}
}
}
EOF
@ -462,7 +462,7 @@ if [ $BE -ne 0 ]; then
# Check if premature kill
pid=$(pgrep -u ${USER} -f clixon_backend)
if [ -z "$pid" ]; then
err "backend already dead"
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg

View file

@ -107,7 +107,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
err
fi
new "start backend -s init -f $cfg"
@ -227,7 +227,7 @@ if [ $BE -ne 0 ]; then
# Check if premature kill
pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then
err "backend already dead"
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg

View file

@ -49,18 +49,18 @@ module clixon-example {
prefix ex;
/* Generic config data */
container table{
list parameter{
key name;
leaf name{
type string;
}
leaf value{
type string;
}
leaf-list array1{
type string;
list parameter{
key name;
leaf name{
type string;
}
}
leaf value{
type string;
}
leaf-list array1{
type string;
}
}
}
}
EOF
@ -75,8 +75,8 @@ module clixon-augment {
}
augment "/ex:table/ex:parameter" {
leaf-list array2{
type string;
}
type string;
}
}
}
EOF
@ -100,13 +100,13 @@ discard("Discard edits (rollback 0)"), discard_changes();
show("Show a particular state of the system"){
xpath("Show configuration") <xpath:string>("XPATH expression") <ns:string>("Namespace"), show_conf_xpath("candidate");
compare("Compare candidate and running databases"), compare_dbs((int32)0);{
xml("Show comparison in xml"), compare_dbs((int32)0);
text("Show comparison in text"), compare_dbs((int32)1);
xml("Show comparison in xml"), compare_dbs((int32)0);
text("Show comparison in text"), compare_dbs((int32)1);
}
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);
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"){
@ -116,10 +116,10 @@ save("Save candidate configuration to XML file") <filename:string>("Filename (lo
text("Save configuration as TEXT"), save_config_file("candidate","filename", "text");
}
load("Load configuration from XML file") <filename:string>("Filename (local filename)"),load_config_file("filename", "replace");{
cli("Replace candidate with file containing CLI commands"), load_config_file("filename", "replace", "cli");
xml("Replace candidate with file containing XML"), load_config_file("filename", "replace", "xml");
json("Replace candidate with file containing JSON"), load_config_file("filename", "replace", "json");
text("Replace candidate with file containing TEXT"), load_config_file("filename", "replace", "text");
cli("Replace candidate with file containing CLI commands"), load_config_file("filename", "replace", "cli");
xml("Replace candidate with file containing XML"), load_config_file("filename", "replace", "xml");
json("Replace candidate with file containing JSON"), load_config_file("filename", "replace", "json");
text("Replace candidate with file containing TEXT"), load_config_file("filename", "replace", "text");
}
EOF
@ -129,7 +129,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -z -f $cfg
if [ $? -ne 0 ]; then
err
err
fi
new "start backend -s init -f $cfg"
start_backend -s init -f $cfg
@ -162,8 +162,8 @@ for format in cli text xml json; do
expectpart "$($clixon_cli -1 -f $cfg -l o load $formatdir/config.$format $format)" 0 "^$"
if [ $format != json ]; then # XXX JSON identity problem
new "cli check compare $format"
expectpart "$($clixon_cli -1 -f $cfg -l o show compare xml)" 0 "^$" --not-- "i" # interface?
new "cli check compare $format"
expectpart "$($clixon_cli -1 -f $cfg -l o show compare xml)" 0 "^$" --not-- "i" # interface?
fi
done
@ -173,7 +173,7 @@ if [ $BE -ne 0 ]; then
# Check if premature kill
pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then
err "backend already dead"
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg

View file

@ -85,14 +85,14 @@ function testrun(){
new "test params: -f $cfg -- -U" # -U : upgrade
# Bring your own backend
if [ $BE -ne 0 ]; then
# kill old backend (if any)
new "kill old backend"
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
fi
new "start backend -s startup -f $cfg -- -U"
start_backend -s startup -f $cfg -- -U
# kill old backend (if any)
new "kill old backend"
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
fi
new "start backend -s startup -f $cfg -- -U"
start_backend -s startup -f $cfg -- -U
fi
new "wait backend"
@ -102,14 +102,14 @@ function testrun(){
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><get-config><source><candidate/></source></get-config></rpc>" "" "<rpc-reply $DEFAULTNS><data>$AFTER</data></rpc-reply>"
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
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
} # end testrun

View file

@ -40,18 +40,18 @@ module clixon-example{
prefix ex;
/* Generic config data */
container table{
list parameter{
key name;
leaf name{
type string;
}
leaf value{
type string;
}
container two{
leaf a{
type string;
}
list parameter{
key name;
leaf name{
type string;
}
leaf value{
type string;
}
container two{
leaf a{
type string;
}
}
}
}
@ -95,13 +95,13 @@ function testrun()
pretty=$2
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 -o CLICON_XMLDB_FORMAT=$format -o CLICON_XMLDB_PRETTY=$pretty"
start_backend -s init -f $cfg -o CLICON_XMLDB_FORMAT=$format -o CLICON_XMLDB_PRETTY=$pretty
new "kill old backend"
sudo clixon_backend -z -f $cfg
if [ $? -ne 0 ]; then
err
fi
new "start backend -s init -f $cfg -o CLICON_XMLDB_FORMAT=$format -o CLICON_XMLDB_PRETTY=$pretty"
start_backend -s init -f $cfg -o CLICON_XMLDB_FORMAT=$format -o CLICON_XMLDB_PRETTY=$pretty
fi
new "wait backend"
@ -117,12 +117,12 @@ function testrun()
# permission kludges
sudo chmod 666 $dir/candidate_db
if [ "$format" = xml ]; then
if [ "$pretty" = false ]; then
cat <<EOF > $dir/expect
if [ "$pretty" = false ]; then
cat <<EOF > $dir/expect
<${DATASTORE_TOP}><table xmlns="urn:example:clixon"><parameter><name>a</name><value>42</value></parameter></table></${DATASTORE_TOP}>
EOF
else
cat <<EOF > $dir/expect
else
cat <<EOF > $dir/expect
<${DATASTORE_TOP}>
<table xmlns="urn:example:clixon">
<parameter>
@ -132,14 +132,14 @@ EOF
</table>
</${DATASTORE_TOP}>
EOF
fi
fi
else
if [ "$pretty" = false ]; then
cat <<EOF > $dir/expect
if [ "$pretty" = false ]; then
cat <<EOF > $dir/expect
{"$DATASTORE_TOP":{"clixon-example:table":{"parameter":[{"name":"a","value":"42"}]}}}
EOF
else
cat <<EOF > $dir/expect
else
cat <<EOF > $dir/expect
{
"${DATASTORE_TOP}": {
"clixon-example:table": {
@ -153,13 +153,13 @@ EOF
}
}
EOF
fi
fi
fi
# -w ignore white space
ret=$(diff -w $dir/candidate_db $dir/expect)
if [ $? -ne 0 ]; then
err "$(cat $dir/expect)" "$(cat $dir/candidate_db)"
err "$(cat $dir/expect)" "$(cat $dir/candidate_db)"
fi
new "save config file"
@ -175,14 +175,14 @@ EOF
expectpart "$($clixon_cli -1 -f $cfg show config)" 0 "^<table xmlns=\"urn:example:clixon\"><parameter><name>a</name><value>42</value></parameter></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
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
}
@ -190,8 +190,8 @@ new "test params: -f $cfg"
for format in xml json; do
for pretty in false true; do
new "test db $format pretty=$pretty"
testrun xml false
new "test db $format pretty=$pretty"
testrun xml false
done
done
@ -200,7 +200,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -z -f $cfg
if [ $? -ne 0 ]; then
err
err
fi
new "start backend -s init -f $cfg -o CLICON_XMLDB_FORMAT=$format -o CLICON_XMLDB_PRETTY=$pretty"
start_backend -s init -f $cfg -o CLICON_XMLDB_FORMAT=$format -o CLICON_XMLDB_PRETTY=$pretty
@ -237,8 +237,8 @@ cat <<EOF > $dir/myconfig
<parameter>
<name>a</name>
<value>42</value>
<two><a>1</a></two>
<two><a>2</a></two>
<two><a>1</a></two>
<two><a>2</a></two>
</parameter>
</table>
</${DATASTORE_TOP}>
@ -256,7 +256,7 @@ if [ $BE -ne 0 ]; then
# Check if premature kill
pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then
err "backend already dead"
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg

View file

@ -38,15 +38,15 @@ module example{
prefix ex;
/* Generic config data */
container table{
list parameter{
key name;
leaf name{
type string;
}
leaf value{
type string;
}
}
list parameter{
key name;
leaf name{
type string;
}
leaf value{
type string;
}
}
}
}
EOF
@ -57,7 +57,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
err
fi
sudo pkill -f clixon_backend # to be sure
new "start backend -s init -f $cfg"
@ -104,7 +104,7 @@ if [ $BE -ne 0 ]; then
# Check if premature kill
pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then
err1 "backend pid !=0" 0
err1 "backend pid !=0" 0
fi
# kill backend
stop_backend -f $cfg

View file

@ -50,7 +50,7 @@ module example{
namespace "urn:example:clixon";
prefix ex;
import ietf-routing {
prefix rt;
prefix rt;
}
feature A{
description "This test feature is enabled";
@ -119,13 +119,13 @@ module example{
}
leaf m9{
if-feature "(A or B "
+ "or B1) and A1";
+ "or B1) and A1";
description "Enabled";
type "string";
}
leaf m10{
if-feature "(A and A1 "
+ "and B1) or not A";
+ "and B1) or not A";
description "Disabled";
type "string";
}
@ -155,14 +155,14 @@ function testrun()
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><validate><source><candidate/></source></validate></rpc>" "" "<rpc-reply $DEFAULTNS><ok/></rpc-reply>"
if $enabled; then
new "netconf set extra element under $node (expect fail)"
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><edit-config><target><candidate/></target><config><$node xmlns=\"urn:example:clixon\"><kallekaka/></$node></config></edit-config></rpc>" "" "<rpc-reply $DEFAULTNS><rpc-error><error-type>application</error-type><error-tag>unknown-element</error-tag><error-info><bad-element>kallekaka</bad-element></error-info><error-severity>error</error-severity><error-message>Failed to find YANG spec of XML node: kallekaka with parent: $node in namespace: urn:example:clixon</error-message></rpc-error></rpc-reply>"
new "netconf set extra element under $node (expect fail)"
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><edit-config><target><candidate/></target><config><$node xmlns=\"urn:example:clixon\"><kallekaka/></$node></config></edit-config></rpc>" "" "<rpc-reply $DEFAULTNS><rpc-error><error-type>application</error-type><error-tag>unknown-element</error-tag><error-info><bad-element>kallekaka</bad-element></error-info><error-severity>error</error-severity><error-message>Failed to find YANG spec of XML node: kallekaka with parent: $node in namespace: urn:example:clixon</error-message></rpc-error></rpc-reply>"
else
new "netconf set extra element under $node"
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><edit-config><target><candidate/></target><config><$node xmlns=\"urn:example:clixon\"><kallekaka/></$node></config></edit-config></rpc>" "" "<rpc-reply $DEFAULTNS><ok/></rpc-reply>"
new "netconf set extra element under $node"
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><edit-config><target><candidate/></target><config><$node xmlns=\"urn:example:clixon\"><kallekaka/></$node></config></edit-config></rpc>" "" "<rpc-reply $DEFAULTNS><ok/></rpc-reply>"
new "netconf validate $node"
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><validate><source><candidate/></source></validate></rpc>" "" "<rpc-reply $DEFAULTNS><ok/></rpc-reply>"
new "netconf validate $node"
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><validate><source><candidate/></source></validate></rpc>" "" "<rpc-reply $DEFAULTNS><ok/></rpc-reply>"
fi
new "netconf discard-changes"
@ -174,7 +174,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
err
fi
new "start backend -s init -f $cfg"
@ -296,7 +296,7 @@ if [ $BE -ne 0 ]; then
# Check if premature kill
pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then
err "backend already dead"
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg
@ -324,7 +324,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
err
fi
new "start backend -s init -f $cfg: feature missing expected fail"

View file

@ -65,7 +65,7 @@ testrun()
new "kill old backend"
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
err
fi
new "start backend -s startup -f $cfg"
@ -88,7 +88,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
err
fi
# kill backend
stop_backend -f $cfg

View file

@ -23,7 +23,7 @@ cat <<EOF > $cfg
<CLICON_CONFIGFILE>$cfg</CLICON_CONFIGFILE>
<CLICON_FEATURE>clixon-restconf:allow-auth-none</CLICON_FEATURE>
<CLICON_YANG_DIR>${YANG_INSTALLDIR}</CLICON_YANG_DIR>
<CLICON_YANG_MAIN_FILE>$fyang</CLICON_YANG_MAIN_FILE>
<CLICON_YANG_MAIN_FILE>$fyang</CLICON_YANG_MAIN_FILE>
<CLICON_CLISPEC_DIR>$clispec</CLICON_CLISPEC_DIR>
<CLICON_CLI_MODE>hello</CLICON_CLI_MODE>
<CLICON_SOCK>$dir/hello.sock</CLICON_SOCK>
@ -43,9 +43,9 @@ cat <<EOF > $cfg
<log-destination>file</log-destination>
<socket>
<namespace>default</namespace>
<address>0.0.0.0</address>
<port>80</port>
<ssl>false</ssl>
<address>0.0.0.0</address>
<port>80</port>
<ssl>false</ssl>
</socket>
</restconf>
<autocli>
@ -65,13 +65,13 @@ module clixon-hello {
namespace "urn:example:hello";
prefix he;
revision 2019-04-17 {
description
"Clixon hello world example";
description
"Clixon hello world example";
}
container hello{
container world{
presence true;
}
container world{
presence true;
}
}
}
EOF
@ -101,7 +101,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
err
fi
new "start backend -s init -f $cfg"
start_backend -s init -f $cfg
@ -184,7 +184,7 @@ if [ $BE -ne 0 ]; then
# Check if premature kill
pid=$(pgrep -f clixon_backend)
if [ -z "$pid" ]; then
err "backend already dead"
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg

View file

@ -130,13 +130,13 @@ function testrun()
RESTCONFIG=$(restconf_config none false $proto $enable)
if true; then
# Proper test setup
datapath=/data
wdir=$dir/www
# Proper test setup
datapath=/data
wdir=$dir/www
else
# Experiments with local host
datapath=/
wdir=/var/www/html
# Experiments with local host
datapath=/
wdir=/var/www/html
fi
# Clixon config
cat <<EOF > $cfg
@ -165,26 +165,26 @@ EOF
new "test params: -f $cfg"
if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
fi
sudo pkill -f clixon_backend # to be sure
new "start backend -s init -f $cfg"
start_backend -s init -f $cfg
new "kill old backend"
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
fi
sudo pkill -f clixon_backend # to be sure
new "start backend -s init -f $cfg"
start_backend -s init -f $cfg
fi
new "wait backend"
wait_backend
if [ $RC -ne 0 ]; then
new "kill old restconf daemon"
stop_restconf_pre
new "kill old restconf daemon"
stop_restconf_pre
new "start restconf daemon"
start_restconf -f $cfg
new "start restconf daemon"
start_restconf -f $cfg
fi
new "wait restconf"
@ -193,95 +193,95 @@ EOF
# echo "curl $CURLOPTS -X GET -H 'Accept: text/html' $proto://localhost/data/index.html"
if ! $enable; then
# XXX or bad request?
new "WWW get html, not enabled, expect not found"
# echo "curl $CURLOPTS -X GET -H 'Accept: text/html' $proto://localhost/data/index.html"
expectpart "$(curl $CURLOPTS -X GET -H 'Accept: text/html' $proto://localhost/data/index.html)" 0 "HTTP/$HVER 404"
# XXX or bad request?
new "WWW get html, not enabled, expect not found"
# echo "curl $CURLOPTS -X GET -H 'Accept: text/html' $proto://localhost/data/index.html"
expectpart "$(curl $CURLOPTS -X GET -H 'Accept: text/html' $proto://localhost/data/index.html)" 0 "HTTP/$HVER 404"
else
new "WWW get root expect 404 without body"
expectpart "$(curl $CURLOPTS -X GET -H 'Accept: text/html' $proto://localhost/)" 0 "HTTP/$HVER 404" --not-- "Content-Type"
new "WWW get index.html"
expectpart "$(curl $CURLOPTS -X GET -H 'Accept: text/html' $proto://localhost/data/index.html)" 0 "HTTP/$HVER 200" "Content-Type: text/html" "<title>Welcome to Clixon!</title>"
new "WWW get dir -> expect index.html"
expectpart "$(curl $CURLOPTS -X GET -H 'Accept: text/html' $proto://localhost/data)" 0 "HTTP/$HVER 200" "Content-Type: text/html" "<title>Welcome to Clixon!</title>"
new "WWW get root expect 404 without body"
expectpart "$(curl $CURLOPTS -X GET -H 'Accept: text/html' $proto://localhost/)" 0 "HTTP/$HVER 404" --not-- "Content-Type"
new "WWW get index.html"
expectpart "$(curl $CURLOPTS -X GET -H 'Accept: text/html' $proto://localhost/data/index.html)" 0 "HTTP/$HVER 200" "Content-Type: text/html" "<title>Welcome to Clixon!</title>"
new "WWW get dir -> expect index.html"
expectpart "$(curl $CURLOPTS -X GET -H 'Accept: text/html' $proto://localhost/data)" 0 "HTTP/$HVER 200" "Content-Type: text/html" "<title>Welcome to Clixon!</title>"
# remove index
mv $dir/www/data/index.html $dir/www/data/tmp.index.html
# remove index
mv $dir/www/data/index.html $dir/www/data/tmp.index.html
new "WWW get dir -> no indirection expect 404"
expectpart "$(curl $CURLOPTS -X GET -H 'Accept: text/html' $proto://localhost/data)" 0 "HTTP/$HVER 404" "Content-Type: text/html" "<title>404 Not Found</title>"
new "WWW get dir -> no indirection expect 404"
expectpart "$(curl $CURLOPTS -X GET -H 'Accept: text/html' $proto://localhost/data)" 0 "HTTP/$HVER 404" "Content-Type: text/html" "<title>404 Not Found</title>"
# move index back
mv $dir/www/data/tmp.index.html $dir/www/data/index.html
new "WWW get css"
expectpart "$(curl $CURLOPTS -X GET -H 'Accept: text/html' $proto://localhost/data/example.css)" 0 "HTTP/$HVER 200" "Content-Type: text/css" "display: inline;" --not-- "Content-Type: text/html"
# move index back
mv $dir/www/data/tmp.index.html $dir/www/data/index.html
new "WWW get css"
expectpart "$(curl $CURLOPTS -X GET -H 'Accept: text/html' $proto://localhost/data/example.css)" 0 "HTTP/$HVER 200" "Content-Type: text/css" "display: inline;" --not-- "Content-Type: text/html"
new "WWW head"
expectpart "$(curl $CURLOPTS --head -H 'Accept: text/html' $proto://localhost/data/index.html)" 0 "HTTP/$HVER 200" "Content-Type: text/html" --not-- "<title>Welcome to Clixon!</title>"
new "WWW head"
expectpart "$(curl $CURLOPTS --head -H 'Accept: text/html' $proto://localhost/data/index.html)" 0 "HTTP/$HVER 200" "Content-Type: text/html" --not-- "<title>Welcome to Clixon!</title>"
new "WWW options"
expectpart "$(curl $CURLOPTS -X OPTIONS $proto://localhost/data/index.html)" 0 "HTTP/$HVER 200" "allow: OPTIONS,HEAD,GET"
new "WWW options"
expectpart "$(curl $CURLOPTS -X OPTIONS $proto://localhost/data/index.html)" 0 "HTTP/$HVER 200" "allow: OPTIONS,HEAD,GET"
# Remove -i option for binary transfer
CURLOPTS2=$(echo $CURLOPTS | sed 's/i//')
new "WWW binary bitmap"
curl $CURLOPTS2 -X GET $proto://localhost/data/clixon.png -o $dir/foo.png
cmp $dir/foo.png $dir/www/data/clixon.png
if [ $? -ne 0 ]; then
err1 "$dir/foo.png $dir/www/data/example.css should be equal" "Not equal"
fi
# Remove -i option for binary transfer
CURLOPTS2=$(echo $CURLOPTS | sed 's/i//')
new "WWW binary bitmap"
curl $CURLOPTS2 -X GET $proto://localhost/data/clixon.png -o $dir/foo.png
cmp $dir/foo.png $dir/www/data/clixon.png
if [ $? -ne 0 ]; then
err1 "$dir/foo.png $dir/www/data/example.css should be equal" "Not equal"
fi
# negative errors
new "WWW get http not found"
expectpart "$(curl $CURLOPTS -X GET -H 'Accept: text/html' $proto://localhost/data/notfound.html)" 0 "HTTP/$HVER 404" "Content-Type: text/html" "<title>404 Not Found</title>"
# negative errors
new "WWW get http not found"
expectpart "$(curl $CURLOPTS -X GET -H 'Accept: text/html' $proto://localhost/data/notfound.html)" 0 "HTTP/$HVER 404" "Content-Type: text/html" "<title>404 Not Found</title>"
new "WWW get http soft link"
expectpart "$(curl $CURLOPTS -X GET -H 'Accept: text/html' $proto://localhost/data/inside.html)" 0 "HTTP/$HVER 403" "Content-Type: text/html" "<title>403 Forbidden</title>" --not-- "<title>Dont access this</title>"
# Two cases where the privileges test is not run:
# 1) Docker in alpine for some reason
# 2) Restconf run explicitly as root (eg coverage)
if [ ! -f /.dockerenv ] ; then
new "WWW get http soft link"
expectpart "$(curl $CURLOPTS -X GET -H 'Accept: text/html' $proto://localhost/data/inside.html)" 0 "HTTP/$HVER 403" "Content-Type: text/html" "<title>403 Forbidden</title>" --not-- "<title>Dont access this</title>"
# Two cases where the privileges test is not run:
# 1) Docker in alpine for some reason
# 2) Restconf run explicitly as root (eg coverage)
if [ ! -f /.dockerenv ] ; then
if [[ "$clixon_restconf" != *"-r"* ]]; then
new "WWW get http not read access"
expectpart "$(curl $CURLOPTS -X GET -H 'Accept: text/html' $proto://localhost/data/noread.html)" 0 "HTTP/$HVER 403" "Content-Type: text/html" "<title>403 Forbidden</title>"
new "WWW get http not read access"
expectpart "$(curl $CURLOPTS -X GET -H 'Accept: text/html' $proto://localhost/data/noread.html)" 0 "HTTP/$HVER 403" "Content-Type: text/html" "<title>403 Forbidden</title>"
fi
fi
fi
# Try .. Cannot get .. in path to work in curl (it seems to remove it)
if [ "$proto" = http -a -n "$netcat" ]; then
new "WWW get outside using .. netcat"
expectpart "$(${netcat} 127.0.0.1 80 <<EOF
# Try .. Cannot get .. in path to work in curl (it seems to remove it)
if [ "$proto" = http -a -n "$netcat" ]; then
new "WWW get outside using .. netcat"
expectpart "$(${netcat} 127.0.0.1 80 <<EOF
GET /data/../../outside.html HTTP/1.1
Host: localhost
Accept: text_html
EOF
)" 0 "HTTP/1.1 403" "Forbidden"
fi
fi
new "WWW post not allowed"
expectpart "$(curl $CURLOPTS -X POST -H 'Accept: text/html' -H "Content-Type: application/yang-data+json" -d '{"ietf-interfaces:interfaces":{"interface":{"name":"eth/0/0","type":"clixon-example:eth","enabled":true}}}' $proto://localhost/data/notfound.html)" 0 "HTTP/$HVER 405" "Content-Type: text/html" "<title>405 Method Not Allowed</title>"
new "WWW post not allowed"
expectpart "$(curl $CURLOPTS -X POST -H 'Accept: text/html' -H "Content-Type: application/yang-data+json" -d '{"ietf-interfaces:interfaces":{"interface":{"name":"eth/0/0","type":"clixon-example:eth","enabled":true}}}' $proto://localhost/data/notfound.html)" 0 "HTTP/$HVER 405" "Content-Type: text/html" "<title>405 Method Not Allowed</title>"
fi
if [ $RC -ne 0 ]; then
new "Kill restconf daemon"
stop_restconf
new "Kill restconf daemon"
stop_restconf
fi
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
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
}
@ -299,8 +299,8 @@ fi
for proto in $protos; do
for enable in true false; do # false
new "http-data proto:$proto enabled:$enable"
testrun $proto $enable
new "http-data proto:$proto enabled:$enable"
testrun $proto $enable
done
done

View file

@ -134,7 +134,7 @@ module example-my-crypto {
type string;
}
leaf type {
type acl-type;
type acl-type;
}
}
}
@ -191,7 +191,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
err
fi
new "start backend -s init -f $cfg"
start_backend -s init -f $cfg
@ -395,7 +395,7 @@ if [ $BE -ne 0 ]; then
# Check if premature kill
pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then
err "backend already dead"
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg

View file

@ -37,10 +37,10 @@ module example {
revision 2019-01-13;
container c{
list a{
key x;
leaf x{
type int32;
}
key x;
leaf x{
type int32;
}
}
}
}
@ -62,13 +62,13 @@ function testrun(){
r0=$($clixon_util_xml_mod -y $fyang -x "$xi" -b "$x0" -p $xp $OPTS)
# If both are null something is amiss
if [ -z "$r0" -a -z "$rs" ]; then
err "length of retval is zero"
err "length of retval is zero"
fi
# echo "rs:$rs"
# echo "r0:$r0"
# Check they are equal
if [[ "$r0" != "$rs" ]]; then
err "$rs" "$r0"
err "$rs" "$r0"
fi
}
@ -178,10 +178,10 @@ module example {
}
}
list d{
key x;
leaf x{
type int32;
}
key x;
leaf x{
type int32;
}
ordered-by user;
}
leaf-list e{

View file

@ -39,13 +39,13 @@ new "Check installed files libclixon${SUFFIX}"
# This is a problem on some platforms that dont have /usr/local/ in LD_LIBRARY_PATH
if [ ! ${LIBOPT} $dir/usr/local/lib/libclixon${SUFFIX} ]; then
if [ ! ${LIBOPT} $dir/usr/lib/libclixon${SUFFIX} ]; then
err $dir/usr/local/lib/libclixon${SUFFIX}
err $dir/usr/local/lib/libclixon${SUFFIX}
fi
fi
new "Check installed files libclixon_backend${SUFFIX}"
if [ ! ${LIBOPT} $dir/usr/local/lib/libclixon_backend${SUFFIX} ]; then
if [ ! ${LIBOPT} $dir/usr/lib/libclixon_backend${SUFFIX} ]; then
err $dir/usr/local/lib/libclixon_backend${SUFFIX}
err $dir/usr/local/lib/libclixon_backend${SUFFIX}
fi
fi

View file

@ -282,7 +282,7 @@ echo -n '<x6 xmlns="urn:example:b">' > $xml6
for (( i=0; i<$nr; i++ )); do
echo -n "<yy><kk1>b$i</kk1><kk2>b$i</kk2><zz>foo$i</zz>" >> $xml6
for (( j=0; j<3; j++ )); do
echo -n "<y xmlns=\"urn:example:a\"><k1>a$j</k1><k2>a$j</k2><z>foo$j</z></y>" >> $xml6
echo -n "<y xmlns=\"urn:example:a\"><k1>a$j</k1><k2>a$j</k2><z>foo$j</z></y>" >> $xml6
done
echo -n "</yy>" >> $xml6
done

View file

@ -18,12 +18,12 @@ module json{
}
list l2{
key name;
leaf name{
type int32;
}
leaf value{
type string;
}
leaf name{
type int32;
}
leaf value{
type string;
}
}
leaf extra{
type string;

View file

@ -45,12 +45,12 @@ module example{
namespace "urn:example:clixon";
prefix ex;
leaf r1 {
description "Top level leaf";
description "Top level leaf";
type uint32;
default 11; /* should be set */
}
leaf r2 {
description "Top level leaf";
description "Top level leaf";
type uint32;
default 22; /* should be set on startup */
}
@ -69,13 +69,13 @@ module example{
/* Extra rules to check when condition */
leaf npleaf{
when "../s3 = '99'";
type uint32;
type uint32;
default 98;
}
container npcont{
when "../s3 = '99'";
leaf npext{
type uint32;
type uint32;
default 99;
}
}
@ -88,8 +88,8 @@ module example{
default 44;
}
container np45{
description "No presence container";
leaf s5 {
description "No presence container";
leaf s5 {
type uint32;
default 45;
}
@ -97,22 +97,22 @@ module example{
}
container xs-config {
description "Typical contruct where a list element has a default leaf";
list x {
key "name";
leaf name {
type string;
}
container y {
leaf inside {
type boolean;
default false;
}
list x {
key "name";
leaf name {
type string;
}
leaf outside {
type boolean;
default false;
}
}
container y {
leaf inside {
type boolean;
default false;
}
}
leaf outside {
type boolean;
default false;
}
}
}
}
EOF
@ -126,7 +126,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
err
fi
new "start backend -s init -f $cfg"
start_backend -s init -f $cfg
@ -168,7 +168,7 @@ if [ $BE -ne 0 ]; then
# Check if premature kill
pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then
err "backend already dead"
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg
@ -187,7 +187,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
err
fi
new "start backend -s startup -f $cfg"
start_backend -s startup -f $cfg
@ -210,7 +210,7 @@ moreret=$(diff $dir/running_db <(echo "<${DATASTORE_TOP}>
</${DATASTORE_TOP}>"))
if [ $? -ne 0 ]; then
err "<${DATASTORE_TOP}>$SXML</${DATASTORE_TOP}>" "$moreret"
fi
fi
new "Change default value r2"
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><edit-config><target><candidate/></target><config><r2 xmlns=\"urn:example:clixon\">88</r2></config></edit-config></rpc>" "" "<rpc-reply $DEFAULTNS><ok/></rpc-reply>"
@ -226,14 +226,14 @@ moreret=$(diff $dir/running_db <(echo "<${DATASTORE_TOP}>
</${DATASTORE_TOP}>"))
if [ $? -ne 0 ]; then
err "<${DATASTORE_TOP}>$SXML<r2 xmlns=\"urn:example:clixon\">88</r2></${DATASTORE_TOP}>" "$moreret"
fi
fi
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"
err "backend already dead"
fi
fi
@ -248,7 +248,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
err
fi
new "start backend -s startup -f $cfg"
start_backend -s startup -f $cfg
@ -265,7 +265,7 @@ if [ $BE -ne 0 ]; then
# Check if premature kill
pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then
err "backend already dead"
err "backend already dead"
fi
fi
@ -280,7 +280,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
err
fi
new "start backend -s startup -f $cfg"
start_backend -s startup -f $cfg
@ -297,7 +297,7 @@ if [ $BE -ne 0 ]; then
# Check if premature kill
pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then
err "backend already dead"
err "backend already dead"
fi
fi

View file

@ -31,29 +31,29 @@ module example{
namespace "urn:example:clixon";
prefix ex;
import ietf-interfaces {
prefix if;
prefix if;
}
import ietf-ip {
prefix ip;
}
identity eth {
base if:interface-type;
base if:interface-type;
}
identity lo {
base if:interface-type;
base if:interface-type;
}
container default-address {
leaf absname {
description "Absolute references existing interfaces in if module";
type leafref {
path "/if:interfaces/if:interface/if:name";
require-instance true;
require-instance true;
}
}
leaf relname {
type leafref {
path "../../if:interfaces/if:interface/if:name";
require-instance true;
require-instance true;
}
}
leaf address {
@ -61,14 +61,14 @@ module example{
type leafref {
path "../../if:interfaces/if:interface[if:name = current()/../relname]"
+ "/ip:ipv4/ip:address/ip:ip";
require-instance true;
require-instance true;
}
}
leaf wrong {
description "References leading nowhere in yang";
type leafref {
path "/ip:interfaces/ip:interface/ip:name";
require-instance true;
require-instance true;
}
}
}
@ -80,7 +80,7 @@ module example{
leaf template{
type leafref{
path "/sender/name";
require-instance true;
require-instance true;
}
}
}
@ -123,7 +123,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
err
fi
new "start backend -s init -f $cfg"
start_backend -s init -f $cfg
@ -197,7 +197,7 @@ if [ $BE -ne 0 ]; then
# Check if premature kill
pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then
err "backend already dead"
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg

View file

@ -56,34 +56,34 @@ module leafref{
namespace "urn:example:example";
prefix example;
typedef sender-ref {
description "For testing leafref across augment and grouping";
type leafref {
path "/ex:sender/ex:name";
require-instance true;
}
description "For testing leafref across augment and grouping";
type leafref {
path "/ex:sender/ex:name";
require-instance true;
}
}
typedef sender-ref-local {
description "For testing leafref local";
type leafref {
path "/example:sender/example:name";
require-instance true;
}
description "For testing leafref local";
type leafref {
path "/example:sender/example:name";
require-instance true;
}
}
list sender{
key name;
leaf name{
type string;
}
container stub{
description "Here is where augmentation is done";
container stub{
description "Here is where augmentation is done";
}
leaf ref{
description "top-level ref (wrong prefix)";
type sender-ref;
type sender-ref;
}
leaf ref-local{
description "top-level ref (right prefix)";
type sender-ref-local;
type sender-ref-local;
}
}
}
@ -96,7 +96,7 @@ module augment{
prefix aug;
import leafref {
description "Note different from canonical (leafref module own prefix is 'example'";
prefix "ex";
prefix "ex";
}
grouping attributes {
container track{
@ -112,19 +112,19 @@ module augment{
description "reference using path inline in data (not typedef)";
key name;
leaf name{
type leafref {
path "/ex:sender/ex:name";
require-instance true;
}
type leafref {
path "/ex:sender/ex:name";
require-instance true;
}
}
}
}
}
augment "/ex:sender/ex:stub" {
description "Main leafref/sender stub.";
description "Main leafref/sender stub.";
container extra{
presence "ensuring it is there";
uses attributes;
presence "ensuring it is there";
uses attributes;
}
}
}
@ -137,7 +137,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
err
fi
new "start backend -s init -f $cfg"
start_backend -s init -f $cfg
@ -251,7 +251,7 @@ if [ $BE -ne 0 ]; then
# Check if premature kill
pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then
err "backend already dead"
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg

View file

@ -62,9 +62,9 @@ module leafref{
config false;
key ref;
leaf ref{
type leafref {
path "/ex:sender-config/ex:name";
}
type leafref {
path "/ex:sender-config/ex:name";
}
}
}
}
@ -88,10 +88,10 @@ module leafref{
config false;
key ref;
leaf ref{
type leafref {
path "/ex:sender-config/ex:name";
require-instance false;
}
type leafref {
path "/ex:sender-config/ex:name";
require-instance false;
}
}
}
}
@ -111,7 +111,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
err
fi
new "start backend -s init -f $cfg -- -sS $fstate"
start_backend -s init -f $cfg -- -sS $fstate
@ -214,7 +214,7 @@ if [ $BE -ne 0 ]; then
# Check if premature kill
pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then
err "backend already dead"
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg
@ -227,7 +227,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
err
fi
new "start backend -s init -f $cfg -o CLICON_VALIDATE_STATE_XML=false -- -sS $fstate"
start_backend -s init -f $cfg -o CLICON_YANG_MAIN_FILE=$fyangno -- -sS $fstate
@ -269,7 +269,7 @@ if [ $BE -ne 0 ]; then
# Check if premature kill
pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then
err "backend already dead"
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg
@ -282,7 +282,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
err
fi
new "start backend -s init -f $cfg -o CLICON_VALIDATE_STATE_XML=false -- -sS $fstate"
start_backend -s init -f $cfg -o CLICON_VALIDATE_STATE_XML=false -- -sS $fstate
@ -324,7 +324,7 @@ if [ $BE -ne 0 ]; then
# Check if premature kill
pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then
err "backend already dead"
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg

View file

@ -74,10 +74,10 @@ module example{
description "idref union";
type union {
type identityref {
base crypto;
base crypto;
}
type identityref {
base airplane;
base airplane;
}
}
}
@ -85,7 +85,7 @@ module example{
description "Union mix of idref and leafref";
type union {
type identityref {
base crypto;
base crypto;
}
type leafref {
path "../x";
@ -103,7 +103,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
err
fi
new "start backend -s init -f $cfg"
start_backend -s init -f $cfg
@ -174,7 +174,7 @@ if [ $BE -ne 0 ]; then
# Check if premature kill
pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then
err "backend already dead"
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg

View file

@ -108,7 +108,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
err
fi
new "start backend -s init -f $cfg"
start_backend -s init -f $cfg
@ -155,7 +155,7 @@ if [ $BE -ne 0 ]; then
# Check if premature kill
pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then
err "backend already dead"
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg

View file

@ -106,12 +106,12 @@ module $APPNAME{
}
container b2c {
leaf-list b2ll{
min-elements 1;
type string;
min-elements 1;
type string;
}
}
leaf-list b3ll{
type string;
type string;
}
}
}
@ -124,7 +124,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
err
fi
new "start backend -s init -f $cfg"
# start new backend
@ -295,7 +295,7 @@ if [ $BE -ne 0 ]; then
# Check if premature kill
pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then
err "backend already dead"
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg

View file

@ -45,7 +45,7 @@ module nacm-example{
namespace "urn:example:nacm";
prefix nex;
import ietf-netconf-acm {
prefix nacm;
prefix nacm;
}
leaf x{
type int32;
@ -117,7 +117,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
err
fi
new "start backend -s init -f $cfg"
start_backend -s init -f $cfg
@ -192,7 +192,7 @@ if [ $BE -ne 0 ]; then
# Check if premature kill
pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then
err "backend already dead"
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg

View file

@ -27,7 +27,7 @@ module nacm-example{
namespace "urn:example:nacm";
prefix nex;
import ietf-netconf-acm {
prefix nacm;
prefix nacm;
}
leaf x{
type int32;
@ -126,13 +126,13 @@ EOF
new "test params: -f $cfg"
if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
fi
new "start backend -s init -f $cfg"
start_backend -s init -f $cfg
new "kill old backend"
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
fi
new "start backend -s init -f $cfg"
start_backend -s init -f $cfg
fi
new "wait backend"
@ -150,23 +150,23 @@ EOF
# raw socket test
if [ -n "$username" ]; then
XML="<rpc $DEFAULTNS username=\"$username\"><get-config><source><running/></source><filter type=\"xpath\" select=\"/ex:x\" xmlns:ex=\"urn:example:nacm\"/></get-config></rpc>"
XML="<rpc $DEFAULTNS username=\"$username\"><get-config><source><running/></source><filter type=\"xpath\" select=\"/ex:x\" xmlns:ex=\"urn:example:nacm\"/></get-config></rpc>"
else
XML="<rpc $DEFAULTNS><get-config><source><running/></source><filter type=\"xpath\" select=\"/ex:x\" xmlns:ex=\"urn:example:nacm\"/></get-config></rpc>"
XML="<rpc $DEFAULTNS><get-config><source><running/></source><filter type=\"xpath\" select=\"/ex:x\" xmlns:ex=\"urn:example:nacm\"/></get-config></rpc>"
fi
new "get-config mode:$mode user:$username $family $precmd"
expecteof_netconf "$precmd $clixon_util_socket -a $family -s $sock -D $DBG" 0 "" "$XML" "$ex"
if [ $BE -ne 0 ]; then # Bring your own backend
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
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
} # testrun

View file

@ -76,10 +76,10 @@ module nacm-example{
namespace "http://example.com/ns/netconf";
prefix ex;
import ietf-netconf-acm {
prefix nacm;
prefix nacm;
}
import itf {
prefix acme;
prefix acme;
}
container acme-netconf{
container config-parameters{
@ -220,7 +220,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
err
fi
new "start backend -s init -f $cfg"
start_backend -s init -f $cfg
@ -324,7 +324,7 @@ if [ $BE -ne 0 ]; then
# Check if premature kill
pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then
err "backend already dead"
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg

View file

@ -94,7 +94,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
err
fi
new "start backend -s startup -f $cfg"
start_backend -s startup -f $cfg
@ -160,7 +160,7 @@ if [ $BE -ne 0 ]; then # Bring your own backend
# Check if premature kill
pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then
err "backend already dead"
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg

View file

@ -206,9 +206,9 @@ function testrun(){
new "get table"
if $test3; then
expectpart "$(curl -u wilma:bar $CURLOPTS -X GET $RCPROTO://localhost/restconf/data/nacm-example:table?depth=1)" 0 "HTTP/$HVER 200" '{"nacm-example:table":{}}'
expectpart "$(curl -u wilma:bar $CURLOPTS -X GET $RCPROTO://localhost/restconf/data/nacm-example:table?depth=1)" 0 "HTTP/$HVER 200" '{"nacm-example:table":{}}'
else
expectpart "$(curl -u wilma:bar $CURLOPTS -X GET $RCPROTO://localhost/restconf/data/nacm-example:table?depth=1)" 0 "HTTP/$HVER 404" '{"ietf-restconf:errors":{"error":{"error-type":"application","error-tag":"invalid-value","error-severity":"error","error-message":"Instance does not exist"}}}'
expectpart "$(curl -u wilma:bar $CURLOPTS -X GET $RCPROTO://localhost/restconf/data/nacm-example:table?depth=1)" 0 "HTTP/$HVER 404" '{"ietf-restconf:errors":{"error":{"error-type":"application","error-tag":"invalid-value","error-severity":"error","error-message":"Instance does not exist"}}}'
fi
new "get parameter"
if $test4; then
@ -225,7 +225,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
err
fi
new "start backend -s init -f $cfg"
start_backend -s init -f $cfg
@ -291,7 +291,7 @@ if [ $BE -ne 0 ]; then # Bring your own backend
# Check if premature kill
pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then
err "backend already dead"
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg

View file

@ -188,29 +188,29 @@ function testrun(){
if $testu; then
expectpart "$(curl -u wilma:bar $CURLOPTS -X PUT -H "Content-Type: application/yang-data+json" $RCPROTO://localhost/restconf/data/nacm-example:table/parameter=a/next/parameter=b -d '{"nacm-example:parameter":[{"name":"b","value":"92"}]}')" 0 "HTTP/$HVER 204"
else
expectpart "$(curl -u wilma:bar $CURLOPTS -X PUT -H "Content-Type: application/yang-data+json" $RCPROTO://localhost/restconf/data/nacm-example:table/parameter=a/next/parameter=b -d '{"nacm-example:parameter":[{"name":"b","value":"92"}]}')" 0 "HTTP/$HVER 403"
# '{"ietf-restconf:errors":{"error":{"error-type":"application","error-tag":"access-denied","error-severity":"error","error-message":"access denied"}}}'
expectpart "$(curl -u wilma:bar $CURLOPTS -X PUT -H "Content-Type: application/yang-data+json" $RCPROTO://localhost/restconf/data/nacm-example:table/parameter=a/next/parameter=b -d '{"nacm-example:parameter":[{"name":"b","value":"92"}]}')" 0 "HTTP/$HVER 403"
# '{"ietf-restconf:errors":{"error":{"error-type":"application","error-tag":"access-denied","error-severity":"error","error-message":"access denied"}}}'
fi
new "delete object b"
if $testd; then
expectpart "$(curl -u wilma:bar $CURLOPTS -X DELETE $RCPROTO://localhost/restconf/data/nacm-example:table/parameter=a/next/parameter=b)" 0 "HTTP/$HVER 204"
else # XXX can vara olika
ret=$(curl -u wilma:bar $CURLOPTS -X DELETE $RCPROTO://localhost/restconf/data/nacm-example:table/parameter=a/next/parameter=b)
r=$?
if [ $r != 0 ]; then
err "retval: $r" "0"
fi
match1=$(echo "$ret" | grep --null -o "HTTP/$HVER 403")
r1=$?
match2=$(echo "$ret" | grep --null -o "HTTP/$HVER 409")
r2=$?
if [ $r1 != 0 -a $r2 != 0 ]; then
err "\"HTTP/$HVER 403\" or \"HTTP/$HVER 409\"" "$ret"
fi
# Ensure delete
new "ensure delete object b"
expectpart "$(curl -u andy:bar $CURLOPTS -X DELETE $RCPROTO://localhost/restconf/data/nacm-example:table/parameter=a/next/parameter=b)" 0 "HTTP/$HVER" # ignore error
ret=$(curl -u wilma:bar $CURLOPTS -X DELETE $RCPROTO://localhost/restconf/data/nacm-example:table/parameter=a/next/parameter=b)
r=$?
if [ $r != 0 ]; then
err "retval: $r" "0"
fi
match1=$(echo "$ret" | grep --null -o "HTTP/$HVER 403")
r1=$?
match2=$(echo "$ret" | grep --null -o "HTTP/$HVER 409")
r2=$?
if [ $r1 != 0 -a $r2 != 0 ]; then
err "\"HTTP/$HVER 403\" or \"HTTP/$HVER 409\"" "$ret"
fi
# Ensure delete
new "ensure delete object b"
expectpart "$(curl -u andy:bar $CURLOPTS -X DELETE $RCPROTO://localhost/restconf/data/nacm-example:table/parameter=a/next/parameter=b)" 0 "HTTP/$HVER" # ignore error
fi
} # testrun
@ -221,7 +221,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
err
fi
new "start backend -s init -f $cfg"
start_backend -s init -f $cfg
@ -289,7 +289,7 @@ if [ $BE -ne 0 ]; then # Bring your own backend
# Check if premature kill
pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then
err "backend already dead"
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg

View file

@ -44,7 +44,7 @@ module nacm-example{
namespace "urn:example:nacm";
prefix nex;
import ietf-netconf-acm {
prefix nacm;
prefix nacm;
}
leaf x{
type int32;
@ -74,13 +74,13 @@ function testrun(){
db=$8
NACM=$(cat <<EOF
<nacm xmlns="urn:ietf:params:xml:ns:yang:ietf-netconf-acm">
<enable-nacm>${enablenacm}</enable-nacm>
<read-default>${readdefault}</read-default>
<write-default>${writedefault}</write-default>
<exec-default>${execdefault}</exec-default>
<enable-external-groups>true</enable-external-groups>
</nacm>
<nacm xmlns="urn:ietf:params:xml:ns:yang:ietf-netconf-acm">
<enable-nacm>${enablenacm}</enable-nacm>
<read-default>${readdefault}</read-default>
<write-default>${writedefault}</write-default>
<exec-default>${execdefault}</exec-default>
<enable-external-groups>true</enable-external-groups>
</nacm>
EOF
)
# Initial data
@ -88,28 +88,28 @@ EOF
# Use startup or set values with POST (below)
if [ $db = startup ]; then
sudo echo "<${DATASTORE_TOP}>$NACM$XML</${DATASTORE_TOP}>" > $dir/startup_db
sudo echo "<${DATASTORE_TOP}>$NACM$XML</${DATASTORE_TOP}>" > $dir/startup_db
fi
if [ $BE -ne 0 ]; then # Bring your own backend
new "kill old backend"
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
fi
new "start backend -s $db -f $cfg"
start_backend -s $db -f $cfg
new "kill old backend"
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
fi
new "start backend -s $db -f $cfg"
start_backend -s $db -f $cfg
fi
new "wait backend"
wait_backend
if [ $RC -ne 0 ]; then # Bring your own restconf
new "kill old restconf daemon"
stop_restconf_pre
new "kill old restconf daemon"
stop_restconf_pre
new "start restconf daemon"
start_restconf -f $cfg
new "start restconf daemon"
start_restconf -f $cfg
fi
new "wait restconf"
@ -118,27 +118,27 @@ EOF
# Use POST (instead of startup)
# Note this only works because CLICON_NACM_DISABLED_ON_EMPTY is true
if [ $db = init ]; then
# Must set NACM first
new "Set NACM using PATCH"
expectpart "$(curl -u guest:bar $CURLOPTS -X PUT -H "Content-Type: application/yang-data+xml" -d "<data>$NACM$XML</data>" $RCPROTO://localhost/restconf/data)" 0 "HTTP/$HVER 201"
# Must set NACM first
new "Set NACM using PATCH"
expectpart "$(curl -u guest:bar $CURLOPTS -X PUT -H "Content-Type: application/yang-data+xml" -d "<data>$NACM$XML</data>" $RCPROTO://localhost/restconf/data)" 0 "HTTP/$HVER 201"
# new "Set Initial data using POST"
# expectpart "$(curl -u guest:bar $CURLOPTS -X POST -H "Content-Type: application/yang-data+xml" -d "$XML" $RCPROTO://localhost/restconf/data)" 0 "HTTP/$HVER 201"
# new "Set Initial data using POST"
# expectpart "$(curl -u guest:bar $CURLOPTS -X POST -H "Content-Type: application/yang-data+xml" -d "$XML" $RCPROTO://localhost/restconf/data)" 0 "HTTP/$HVER 201"
fi
#----------- First get
case "$ret1" in
0) ret='{"nacm-example:x":42}'
status="HTTP/$HVER 200"
;;
1) ret='{"ietf-restconf:errors":{"error":{"error-type":"application","error-tag":"access-denied","error-severity":"error","error-message":"default deny"}}}'
status="HTTP/$HVER 403"
;;
2) ret='{"ietf-restconf:errors":{"error":{"error-type":"application","error-tag":"invalid-value","error-severity":"error","error-message":"Instance does not exist"}}}'
status="HTTP/$HVER 404"
;;
0) ret='{"nacm-example:x":42}'
status="HTTP/$HVER 200"
;;
1) ret='{"ietf-restconf:errors":{"error":{"error-type":"application","error-tag":"access-denied","error-severity":"error","error-message":"default deny"}}}'
status="HTTP/$HVER 403"
;;
2) ret='{"ietf-restconf:errors":{"error":{"error-type":"application","error-tag":"invalid-value","error-severity":"error","error-message":"Instance does not exist"}}}'
status="HTTP/$HVER 404"
;;
esac
new "get startup 42"
@ -146,30 +146,30 @@ EOF
#----------- Then edit
case "$ret2" in
0) ret=''
status="HTTP/$HVER 204"
;;
1) ret='{"ietf-restconf:errors":{"error":{"error-type":"application","error-tag":"access-denied","error-severity":"error","error-message":"default deny"}}}'
status="HTTP/$HVER 403"
;;
0) ret=''
status="HTTP/$HVER 204"
;;
1) ret='{"ietf-restconf:errors":{"error":{"error-type":"application","error-tag":"access-denied","error-severity":"error","error-message":"default deny"}}}'
status="HTTP/$HVER 403"
;;
esac
new "edit new 99"
expectpart "$(curl -u guest:bar $CURLOPTS -X PUT -H "Content-Type: application/yang-data+json" -d '{"nacm-example:x": 99}' $RCPROTO://localhost/restconf/data/nacm-example:x)" 0 "$status" "$ret"
#----------- Then second get
case "$ret3" in
0) ret='{"nacm-example:x":99}'
status="HTTP/$HVER 200"
;;
1) ret='{"ietf-restconf:errors":{"error":{"error-type":"application","error-tag":"access-denied","error-severity":"error","error-message":"default deny"}}}'
status="HTTP/$HVER 403"
0) ret='{"nacm-example:x":99}'
status="HTTP/$HVER 200"
;;
2) ret='{"ietf-restconf:errors":{"error":{"error-type":"application","error-tag":"invalid-value","error-severity":"error","error-message":"Instance does not exist"}}}'
status="HTTP/$HVER 404"
;;
3) ret='{"nacm-example:x":42}'
status="HTTP/$HVER 200"
;;
1) ret='{"ietf-restconf:errors":{"error":{"error-type":"application","error-tag":"access-denied","error-severity":"error","error-message":"default deny"}}}'
status="HTTP/$HVER 403"
;;
2) ret='{"ietf-restconf:errors":{"error":{"error-type":"application","error-tag":"invalid-value","error-severity":"error","error-message":"Instance does not exist"}}}'
status="HTTP/$HVER 404"
;;
3) ret='{"nacm-example:x":42}'
status="HTTP/$HVER 200"
;;
esac
new "get 99"
@ -178,19 +178,19 @@ EOF
sleep $DEMSLEEP
if [ $RC -ne 0 ]; then # Bring your own restconf
new "Kill restconf daemon"
stop_restconf
new "Kill restconf daemon"
stop_restconf
fi
if [ $BE -ne 0 ]; then # Bring your own backend
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
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
} # testrun

View file

@ -48,28 +48,28 @@ module nacm-example{
namespace "urn:example:nacm";
prefix nacm;
import clixon-example {
prefix ex;
prefix ex;
}
container authentication {
presence "To keep this from auto-expanding";
description "Example code for enabling www basic auth and some example
users";
leaf basic_auth{
description "Basic user / password authentication as in HTTP basic auth";
type boolean;
default true;
description "Basic user / password authentication as in HTTP basic auth";
type boolean;
default true;
}
list auth {
description "user / password entries. Valid if basic_auth=true";
key user;
leaf user{
description "User name";
type string;
}
leaf password{
description "Password";
type string;
}
description "user / password entries. Valid if basic_auth=true";
key user;
leaf user{
description "User name";
type string;
}
leaf password{
description "Password";
type string;
}
}
}
leaf x{
@ -93,31 +93,31 @@ module clixon-example{
}
}
rpc example {
description "Some example input/output for testing RFC7950 7.14.
description "Some example input/output for testing RFC7950 7.14.
RPC simply echoes the input for debugging.";
input {
leaf x {
description
"If a leaf in the input tree has a 'mandatory' statement with
input {
leaf x {
description
"If a leaf in the input tree has a 'mandatory' statement with
the value 'true', the leaf MUST be present in an RPC invocation.";
type string;
mandatory true;
}
leaf y {
description
type string;
mandatory true;
}
leaf y {
description
"If a leaf in the input tree has a 'mandatory' statement with the
value 'true', the leaf MUST be present in an RPC invocation.";
type string;
default "42";
}
type string;
default "42";
}
}
output {
leaf x {
type string;
}
leaf y {
type string;
}
leaf x {
type string;
}
leaf y {
type string;
}
}
}
}
@ -183,7 +183,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend -zf $cfg "
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
err
fi
sleep 1
new "start backend -s init -f $cfg -- -s"
@ -266,7 +266,7 @@ if [ $BE -ne 0 ]; then
# Check if premature kill
pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then
err "backend already dead"
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg

View file

@ -48,10 +48,10 @@ module nacm-example{
namespace "urn:example:nacm";
prefix nex;
import clixon-example {
prefix ex;
prefix ex;
}
import ietf-netconf-acm {
prefix nacm;
prefix nacm;
}
leaf x{
type int32;
@ -66,14 +66,14 @@ module clixon-example{
namespace "urn:example:clixon";
prefix ex;
container table{
list parameter{
key name;
leaf name{
type string;
}
leaf value{
type string;
}
list parameter{
key name;
leaf name{
type string;
}
leaf value{
type string;
}
}
}
/* State data (not config) for the example application*/
@ -85,31 +85,31 @@ module clixon-example{
}
}
rpc example {
description "Some example input/output for testing RFC7950 7.14.
description "Some example input/output for testing RFC7950 7.14.
RPC simply echoes the input for debugging.";
input {
leaf x {
description
"If a leaf in the input tree has a 'mandatory' statement with
input {
leaf x {
description
"If a leaf in the input tree has a 'mandatory' statement with
the value 'true', the leaf MUST be present in an RPC invocation.";
type string;
mandatory true;
}
leaf y {
description
type string;
mandatory true;
}
leaf y {
description
"If a leaf in the input tree has a 'mandatory' statement with the
value 'true', the leaf MUST be present in an RPC invocation.";
type string;
default "42";
}
type string;
default "42";
}
}
output {
leaf x {
type string;
}
leaf y {
type string;
}
leaf x {
type string;
}
leaf y {
type string;
}
}
}
}
@ -178,7 +178,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
err
fi
new "start backend -s init -f $cfg -- -s"
start_backend -s init -f $cfg -- -s
@ -318,7 +318,7 @@ if [ $BE -ne 0 ]; then
# Check if premature kill
pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then
err "backend already dead"
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg

View file

@ -61,10 +61,10 @@ module nacm-example{
namespace "urn:example:nacm";
prefix nex;
import clixon-example {
prefix ex;
prefix ex;
}
import ietf-netconf-acm {
prefix nacm;
prefix nacm;
}
leaf x{
type int32;
@ -90,14 +90,14 @@ module clixon-example{
namespace "urn:example:clixon";
prefix ex;
container table{
list parameter{
key name;
leaf name{
type string;
}
leaf value{
type string;
}
list parameter{
key name;
leaf name{
type string;
}
leaf value{
type string;
}
}
}
/* State data (not config) for the example application*/
@ -169,7 +169,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
err
fi
new "start backend -s init -f $cfg"
start_backend -s init -f $cfg
@ -293,7 +293,7 @@ if [ $BE -ne 0 ]; then
# Check if premature kill
pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then
err "backend already dead"
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg

View file

@ -64,7 +64,7 @@ module nacm-example{
namespace "urn:example:nacm";
prefix nex;
import ietf-netconf-acm {
prefix nacm;
prefix nacm;
}
leaf x{
type int32;
@ -138,7 +138,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
err
fi
new "start backend -s init -f $cfg"
@ -228,7 +228,7 @@ if [ $BE -ne 0 ]; then
# Check if premature kill
pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then
err "backend already dead"
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg

View file

@ -29,7 +29,7 @@ module nacm-example{
namespace "urn:example:nacm";
prefix nex;
import ietf-netconf-acm {
prefix nacm;
prefix nacm;
}
leaf x{
type int32;
@ -61,9 +61,9 @@ function testrun()
putp=$6
if [ "$realuser" = "root" ]; then
prefix="sudo "
prefix="sudo "
else
prefix=""
prefix=""
fi
cat <<EOF > $cfg
@ -87,62 +87,62 @@ cat <<EOF > $cfg
</clixon-config>
EOF
if [ $BE -ne 0 ]; then
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
fi
new "start backend -s init -f $cfg"
start_backend -s init -f $cfg
sudo clixon_backend -zf $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
if [ $RC -ne 0 ]; then
new "kill old restconf daemon"
stop_restconf_pre
new "kill old restconf daemon"
stop_restconf_pre
new "start restconf daemon"
start_restconf -f $cfg
new "start restconf daemon"
start_restconf -f $cfg
fi
new "wait restconf"
wait_restconf
if $getp; then
# default is read allowed so this should always succeed.
new "get startup default ok"
expecteof_netconf "$prefix$clixon_netconf -qf $cfg -U $pseudo" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><get-config><source><candidate/></source></get-config></rpc>" "" "<rpc-reply $DEFAULTNS><data>$DEFAULT</data></rpc-reply>"
# This would normally not work except in recovery situations
# default is read allowed so this should always succeed.
new "get startup default ok"
expecteof_netconf "$prefix$clixon_netconf -qf $cfg -U $pseudo" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><get-config><source><candidate/></source></get-config></rpc>" "" "<rpc-reply $DEFAULTNS><data>$DEFAULT</data></rpc-reply>"
# This would normally not work except in recovery situations
else
new "get startup not ok"
expecteof_netconf "$prefix$clixon_netconf -qf $cfg -U $pseudo" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><get-config><source><candidate/></source></get-config></rpc>" "" "<rpc-reply $DEFAULTNS><rpc-error><error-type>application</error-type><error-tag>access-denied</error-tag><error-severity>error</error-severity><error-message>User $realuser credential not matching NACM user $pseudo</error-message></rpc-error></rpc-reply>"
new "get startup not ok"
expecteof_netconf "$prefix$clixon_netconf -qf $cfg -U $pseudo" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><get-config><source><candidate/></source></get-config></rpc>" "" "<rpc-reply $DEFAULTNS><rpc-error><error-type>application</error-type><error-tag>access-denied</error-tag><error-severity>error</error-severity><error-message>User $realuser credential not matching NACM user $pseudo</error-message></rpc-error></rpc-reply>"
fi
if $putp; then
new "put, expect ok"
expecteof_netconf "$prefix$clixon_netconf -qf $cfg -U $pseudo" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><edit-config><target><candidate/></target><config>$RULES</config></edit-config></rpc>" "" "<rpc-reply $DEFAULTNS><ok/></rpc-reply>"
new "put, expect ok"
expecteof_netconf "$prefix$clixon_netconf -qf $cfg -U $pseudo" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><edit-config><target><candidate/></target><config>$RULES</config></edit-config></rpc>" "" "<rpc-reply $DEFAULTNS><ok/></rpc-reply>"
new "get rules ok"
expecteof_netconf "$prefix$clixon_netconf -qf $cfg -U $pseudo" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><get-config><source><candidate/></source></get-config></rpc>" "" "<rpc-reply $DEFAULTNS><data>$RULES</data></rpc-reply>"
new "get rules ok"
expecteof_netconf "$prefix$clixon_netconf -qf $cfg -U $pseudo" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><get-config><source><candidate/></source></get-config></rpc>" "" "<rpc-reply $DEFAULTNS><data>$RULES</data></rpc-reply>"
else
new "put, expect fail"
expecteof_netconf "$prefix$clixon_netconf -qf $cfg -U $pseudo" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><edit-config><target><candidate/></target><config>$RULES</config></edit-config></rpc>" "<rpc-reply $DEFAULTNS><rpc-error><error-type>application</error-type><error-tag>access-denied</error-tag><error-severity>error</error-severity><error-message>" "" # default deny</error-message></rpc-error></rpc-reply>"
new "put, expect fail"
expecteof_netconf "$prefix$clixon_netconf -qf $cfg -U $pseudo" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><edit-config><target><candidate/></target><config>$RULES</config></edit-config></rpc>" "<rpc-reply $DEFAULTNS><rpc-error><error-type>application</error-type><error-tag>access-denied</error-tag><error-severity>error</error-severity><error-message>" "" # default deny</error-message></rpc-error></rpc-reply>"
fi
if [ $RC -ne 0 ]; then
new "Kill restconf daemon"
stop_restconf
new "Kill restconf daemon"
stop_restconf
fi
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
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
}

View file

@ -24,7 +24,7 @@ cat <<EOF > $cfg
<CLICON_YANG_DIR>$dir</CLICON_YANG_DIR>
<CLICON_YANG_DIR>${YANG_INSTALLDIR}</CLICON_YANG_DIR>
<CLICON_YANG_DIR>$IETFRFC</CLICON_YANG_DIR>
<CLICON_YANG_MAIN_FILE>$fyang</CLICON_YANG_MAIN_FILE>
<CLICON_YANG_MAIN_FILE>$fyang</CLICON_YANG_MAIN_FILE>
<CLICON_CLISPEC_DIR>/usr/local/lib/$APPNAME/clispec</CLICON_CLISPEC_DIR>
<CLICON_BACKEND_DIR>/usr/local/lib/$APPNAME/backend</CLICON_BACKEND_DIR>
<CLICON_BACKEND_REGEXP>example_backend.so$</CLICON_BACKEND_REGEXP>
@ -45,90 +45,90 @@ module clixon-example{
namespace "urn:example:clixon";
prefix ex;
import ietf-interfaces {
prefix if;
prefix if;
}
import ietf-ip {
prefix ip;
prefix ip;
}
/* Example interface type for tests, local callbacks, etc */
identity eth {
base if:interface-type;
base if:interface-type;
}
/* Generic config data */
container table{
list parameter{
key name;
leaf name{
type string;
}
}
list parameter{
key name;
leaf name{
type string;
}
}
}
/* State data (not config) for the example application*/
container state {
config false;
description "state data for the example application (must be here for example get operation)";
leaf-list op {
config false;
description "state data for the example application (must be here for example get operation)";
leaf-list op {
type string;
}
}
}
augment "/if:interfaces/if:interface" {
container my-status {
config false;
description "For testing augment+state";
leaf int {
type int32;
}
leaf str {
type string;
}
}
container my-status {
config false;
description "For testing augment+state";
leaf int {
type int32;
}
leaf str {
type string;
}
}
}
rpc client-rpc {
description "Example local client-side RPC that is processed by the
description "Example local client-side RPC that is processed by the
the netconf/restconf and not sent to the backend.
This is a clixon implementation detail: some rpc:s
are better processed by the client for API or perf reasons";
input {
leaf x {
type string;
}
}
output {
leaf x {
type string;
}
}
input {
leaf x {
type string;
}
}
output {
leaf x {
type string;
}
}
}
rpc empty {
description "Smallest possible RPC with no input or output sections";
description "Smallest possible RPC with no input or output sections";
}
rpc example {
description "Some example input/output for testing RFC7950 7.14.
description "Some example input/output for testing RFC7950 7.14.
RPC simply echoes the input for debugging.";
input {
leaf x {
description
"If a leaf in the input tree has a 'mandatory' statement with
input {
leaf x {
description
"If a leaf in the input tree has a 'mandatory' statement with
the value 'true', the leaf MUST be present in an RPC invocation.";
type string;
mandatory true;
}
leaf y {
description
"If a leaf in the input tree has a 'mandatory' statement with the
type string;
mandatory true;
}
leaf y {
description
"If a leaf in the input tree has a 'mandatory' statement with the
value 'true', the leaf MUST be present in an RPC invocation.";
type string;
default "42";
}
}
output {
leaf x {
type string;
}
leaf y {
type string;
}
}
type string;
default "42";
}
}
output {
leaf x {
type string;
}
leaf y {
type string;
}
}
}
}
@ -141,7 +141,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
err
fi
new "start backend -s init -f $cfg -- -s"
start_backend -s init -f $cfg -- -s
@ -439,7 +439,7 @@ if [ $BE -ne 0 ]; then
# Check if premature kill
pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then
err "backend already dead"
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg

View file

@ -50,7 +50,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
err
fi
new "start backend -s init -f $cfg"
start_backend -s init -f $cfg
@ -118,7 +118,7 @@ if [ $BE -ne 0 ]; then
# Check if premature kill
pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then
err "backend already dead"
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg

View file

@ -18,7 +18,7 @@ cat <<EOF > $cfg
<CLICON_FEATURE>ietf-netconf:startup</CLICON_FEATURE>
<CLICON_MODULE_SET_ID>42</CLICON_MODULE_SET_ID>
<CLICON_YANG_DIR>${YANG_INSTALLDIR}</CLICON_YANG_DIR>
<CLICON_YANG_MAIN_FILE>$fyang</CLICON_YANG_MAIN_FILE>
<CLICON_YANG_MAIN_FILE>$fyang</CLICON_YANG_MAIN_FILE>
<CLICON_CLISPEC_DIR>/usr/local/lib/$APPNAME/clispec</CLICON_CLISPEC_DIR>
<CLICON_BACKEND_DIR>/usr/local/lib/$APPNAME/backend</CLICON_BACKEND_DIR>
<CLICON_BACKEND_REGEXP>example_backend.so$</CLICON_BACKEND_REGEXP>
@ -42,13 +42,13 @@ module clixon-example{
/* Generic config data */
container table{
list parameter{
key name;
leaf name{
type string;
}
leaf value{
type string;
}
key name;
leaf name{
type string;
}
leaf value{
type string;
}
}
}
}
@ -61,7 +61,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
err
fi
new "start backend -s init -f $cfg -- -s"
start_backend -s init -f $cfg -- -s
@ -102,7 +102,7 @@ if [ $BE -ne 0 ]; then
# Check if premature kill
pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then
err "backend already dead"
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg

View file

@ -21,7 +21,7 @@ cat <<EOF > $cfg
<CLICON_FEATURE>ietf-netconf:startup</CLICON_FEATURE>
<CLICON_MODULE_SET_ID>42</CLICON_MODULE_SET_ID>
<CLICON_YANG_DIR>${YANG_INSTALLDIR}</CLICON_YANG_DIR>
<CLICON_YANG_MAIN_FILE>$fyang</CLICON_YANG_MAIN_FILE>
<CLICON_YANG_MAIN_FILE>$fyang</CLICON_YANG_MAIN_FILE>
<CLICON_CLISPEC_DIR>/usr/local/lib/$APPNAME/clispec</CLICON_CLISPEC_DIR>
<CLICON_BACKEND_DIR>/usr/local/lib/$APPNAME/backend</CLICON_BACKEND_DIR>
<CLICON_BACKEND_REGEXP>example_backend.so$</CLICON_BACKEND_REGEXP>
@ -52,7 +52,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
err
fi
new "start backend -s init -f $cfg -- -s"
start_backend -s init -f $cfg -- -s
@ -132,7 +132,7 @@ if [ $BE -ne 0 ]; then
# Check if premature kill
pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then
err "backend already dead"
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg

View file

@ -95,7 +95,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
err
fi
new "start backend -s init -f $cfg -- -n"
start_backend -s init -f $cfg -- -n # create example notification stream
@ -139,7 +139,7 @@ if [ $BE -ne 0 ]; then
# Check if premature kill
pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then
err "backend already dead"
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg

View file

@ -39,7 +39,7 @@ cat <<EOF > $cfg
<CLICON_CONFIGFILE>$cfg</CLICON_CONFIGFILE>
<CLICON_MODULE_SET_ID>42</CLICON_MODULE_SET_ID>
<CLICON_YANG_DIR>${YANG_INSTALLDIR}</CLICON_YANG_DIR>
<CLICON_YANG_MAIN_FILE>$fyang</CLICON_YANG_MAIN_FILE>
<CLICON_YANG_MAIN_FILE>$fyang</CLICON_YANG_MAIN_FILE>
<CLICON_CLISPEC_DIR>/usr/local/lib/$APPNAME/clispec</CLICON_CLISPEC_DIR>
<CLICON_BACKEND_DIR>/usr/local/lib/$APPNAME/backend</CLICON_BACKEND_DIR>
<CLICON_BACKEND_REGEXP>example_backend.so$</CLICON_BACKEND_REGEXP>
@ -97,7 +97,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
err
fi
new "start backend -s init -f $cfg"
start_backend -s init -f $cfg
@ -144,7 +144,7 @@ if [ $BE -ne 0 ]; then
# Check if premature kill
pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then
err "backend already dead"
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg

View file

@ -50,7 +50,7 @@ module whitespace{
type string;
}
container b{
presence true;
presence true;
}
}
}
@ -67,7 +67,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -zf $cfg -s startup
if [ $? -ne 0 ]; then
err
err
fi
new "start backend -s startup -f $cfg"
start_backend -s startup -f $cfg
@ -143,7 +143,7 @@ if [ $BE -ne 0 ]; then
# Check if premature kill
pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then
err "backend already dead"
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg

View file

@ -37,28 +37,28 @@ for f in $files; do
let m=0; # Nr of modules
let s=0; # Nr of modules
if [ -n "$(head -15 $f|grep '^[ ]*module')" ]; then
let m++;
let ms++;
let m++;
let ms++;
elif [ -n "$(head -15 $f|grep '^[ ]*submodule')" ]; then
let s++;
let ss++;
let s++;
let ss++;
else
echo "No module or submodule found $f"
exit
echo "No module or submodule found $f"
exit
fi
if [ $m -eq 1 -a $s -eq 1 ]; then
echo "Double match $f"
exit
echo "Double match $f"
exit
fi
done
new "Openconfig test: $clixon_cli -1f $cfg show version ($m modules)"
for f in $files; do
if [ -n "$(head -1 $f|grep '^module')" ]; then
modname=$(basename $f | awk -F "." '{print $1}')
# Generate autocli for these modules
AUTOCLI=$(autocli_config $modname kw-nokey false)
modname=$(basename $f | awk -F "." '{print $1}')
# Generate autocli for these modules
AUTOCLI=$(autocli_config $modname kw-nokey false)
cat <<EOF > $cfg
<clixon-config xmlns="http://clicon.org/config">
<CLICON_CONFIGFILE>$cfg</CLICON_CONFIGFILE>
@ -76,8 +76,8 @@ cat <<EOF > $cfg
</clixon-config>
EOF
new "$clixon_cli -D $DBG -1f $cfg -o CLICON_YANG_MAIN_FILE=$f show version"
expectpart "$($clixon_cli -D $DBG -1f $cfg -y $f show version)" 0 "${CLIXON_VERSION}"
new "$clixon_cli -D $DBG -1f $cfg -o CLICON_YANG_MAIN_FILE=$f show version"
expectpart "$($clixon_cli -D $DBG -1f $cfg -y $f show version)" 0 "${CLIXON_VERSION}"
fi
done

View file

@ -30,7 +30,7 @@ cat <<EOF > $cfg
<CLICON_YANG_DIR>${YANG_INSTALLDIR}</CLICON_YANG_DIR>
<CLICON_YANG_DIR>$IETFRFC</CLICON_YANG_DIR>
<CLICON_YANG_DIR>$OCDIR</CLICON_YANG_DIR>
<CLICON_YANG_MAIN_FILE>$fyang</CLICON_YANG_MAIN_FILE>
<CLICON_YANG_MAIN_FILE>$fyang</CLICON_YANG_MAIN_FILE>
<CLICON_CLISPEC_DIR>/usr/local/lib/$APPNAME/clispec</CLICON_CLISPEC_DIR>
<CLICON_CLI_DIR>/usr/local/lib/$APPNAME/cli</CLICON_CLI_DIR>
<CLICON_CLI_MODE>$APPNAME</CLICON_CLI_MODE>
@ -89,7 +89,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
err
fi
sudo pkill -f clixon_backend # to be sure
@ -111,18 +111,18 @@ expectpart "$($clixon_cli -1 -f $cfg show conf xml)" 0 "^<interfaces xmlns=\"htt
# XXX THIS REQUIRES PREFIX FOR IETF-INTERFACES
#new "cli set interfaces interface <tab> complete: e"
#expectpart "$(echo "set interfaces interface " | $clixon_cli -f $cfg)" 0 "interface e"
#expectpart "$(echo "set interfaces interface " | $clixon_cli -f $cfg)" 0 "interface e"
# XXX See https://github.com/clicon/clixon/issues/218
#new "cli set interfaces interface e <tab> complete: not ethernet"
#expectpart "$(echo "set interfaces interface e " | $clixon_cli -f $cfg)" 0 config hold-time subinterfaces --not-- ethernet
#expectpart "$(echo "set interfaces interface e " | $clixon_cli -f $cfg)" 0 config hold-time subinterfaces --not-- ethernet
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"
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg
@ -173,7 +173,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
err
fi
sudo pkill -f clixon_backend # to be sure
@ -192,7 +192,7 @@ if [ $BE -ne 0 ]; then
# Check if premature kill
pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then
err "backend already dead"
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg

View file

@ -27,7 +27,7 @@ cat <<EOF > $cfg
<CLICON_YANG_DIR>${YANG_INSTALLDIR}</CLICON_YANG_DIR>
<CLICON_YANG_DIR>$IETFRFC</CLICON_YANG_DIR>
<CLICON_YANG_DIR>$OCDIR</CLICON_YANG_DIR>
<CLICON_YANG_MAIN_FILE>$fyang</CLICON_YANG_MAIN_FILE>
<CLICON_YANG_MAIN_FILE>$fyang</CLICON_YANG_MAIN_FILE>
<CLICON_CLISPEC_DIR>$dir</CLICON_CLISPEC_DIR>
<CLICON_CLI_DIR>/usr/local/lib/$APPNAME/cli</CLICON_CLI_DIR>
<CLICON_CLI_MODE>$APPNAME</CLICON_CLI_MODE>
@ -112,7 +112,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
err
fi
sudo pkill -f clixon_backend # to be sure
@ -140,7 +140,7 @@ if [ $BE -ne 0 ]; then
# Check if premature kill
pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then
err "backend already dead"
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg

View file

@ -202,7 +202,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
err
fi
new "start backend"
start_backend -s running -f $cfg -- -s
@ -304,14 +304,14 @@ expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS
for s in int uint; do
for t in 8 16 32 64; do
type=$s$t
new "put leaf-list $type (10,2,1)"
expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><edit-config><target><candidate/></target><config><types xmlns=\"urn:example:order\">
type=$s$t
new "put leaf-list $type (10,2,1)"
expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><edit-config><target><candidate/></target><config><types xmlns=\"urn:example:order\">
<my$type>10</my$type><my$type>2</my$type><my$type>1</my$type>
</types></config></edit-config></rpc>" "" "<rpc-reply $DEFAULTNS><ok/></rpc-reply>"
new "check leaf-list $type order (1,2,10)"
expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><get-config><source><candidate/></source><filter type=\"xpath\" select=\"/exo:types/exo:my$type\" xmlns:exo=\"urn:example:order\"/></get-config></rpc>" "" "<rpc-reply $DEFAULTNS><data><types xmlns=\"urn:example:order\"><my$type>1</my$type><my$type>2</my$type><my$type>10</my$type></types></data></rpc-reply>"
new "check leaf-list $type order (1,2,10)"
expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><get-config><source><candidate/></source><filter type=\"xpath\" select=\"/exo:types/exo:my$type\" xmlns:exo=\"urn:example:order\"/></get-config></rpc>" "" "<rpc-reply $DEFAULTNS><data><types xmlns=\"urn:example:order\"><my$type>1</my$type><my$type>2</my$type><my$type>10</my$type></types></data></rpc-reply>"
done
done
@ -449,7 +449,7 @@ if [ $BE -ne 0 ]; then
# Check if premature kill
pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then
err "backend already dead"
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg

View file

@ -147,7 +147,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
err
fi
sudo pkill -f clixon_backend # to be sure
@ -170,7 +170,7 @@ if [ $BE -ne 0 ]; then
# Check if premature kill
pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then
err "backend already dead"
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg

View file

@ -168,7 +168,7 @@ cat<<EOF > $fstate
<member-id>alice</member-id>
<stats>
<joined>2020-07-08T12:38:32Z</joined>
<membership-level>admin</membership-level>
<membership-level>admin</membership-level>
<last-activity>2021-04-01T02:51:11Z</last-activity>
</stats>
</member>
@ -176,7 +176,7 @@ cat<<EOF > $fstate
<member-id>bob</member-id>
<stats>
<joined>2020-08-14T03:30:00Z</joined>
<membership-level>standard</membership-level>
<membership-level>standard</membership-level>
<last-activity>2020-08-14T03:34:30Z</last-activity>
</stats>
</member>
@ -184,7 +184,7 @@ cat<<EOF > $fstate
<member-id>eric</member-id>
<stats>
<joined>2020-09-17T19:38:32Z</joined>
<membership-level>pro</membership-level>
<membership-level>pro</membership-level>
<last-activity>2020-09-17T18:02:04Z</last-activity>
</stats>
</member>
@ -192,7 +192,7 @@ cat<<EOF > $fstate
<member-id>lin</member-id>
<stats>
<joined>2020-07-09T12:38:32Z</joined>
<membership-level>standard</membership-level>
<membership-level>standard</membership-level>
<last-activity>2021-04-01T02:51:11Z</last-activity>
</stats>
</member>
@ -200,7 +200,7 @@ cat<<EOF > $fstate
<member-id>joe</member-id>
<stats>
<joined>2020-10-08T12:38:32Z</joined>
<membership-level>pro</membership-level>
<membership-level>pro</membership-level>
<last-activity>2021-04-01T02:51:11Z</last-activity>
</stats>
</member>
@ -279,73 +279,73 @@ function testlimit()
let i=0
for li in $list; do
if [ $i = 0 ]; then
# Note: if REMAINING is enabled:
# if [ $limit == 0 ]; then
if true; then
el="<uint8-numbers>$li</uint8-numbers>"
el2="<uint8-numbers xmlns=\"http://example.com/ns/example-social\">$li</uint8-numbers>"
else
el="<uint8-numbers lp:remaining=\"$remaining\" xmlns:lp=\"urn:ietf:params:xml:ns:yang:ietf-list-pagination\">$li</uint8-numbers>"
el2="<uint8-numbers lp:remaining=\"$remaining\" xmlns:lp=\"urn:ietf:params:xml:ns:yang:ietf-list-pagination\" xmlns=\"http://example.com/ns/example-social\">$li</uint8-numbers>"
jsonmeta=",\"@example-social:uint8-numbers\":\[{\"ietf-list-pagination:remaining\":$remaining}\]"
fi
jsonlist="$li"
else
el="<uint8-numbers>$li</uint8-numbers>"
el2="<uint8-numbers xmlns=\"http://example.com/ns/example-social\">$li</uint8-numbers>" jsonlist="$jsonlist,$li"
fi
xmllist="$xmllist$el"
xmllist2="$xmllist2$el2"
let i++
if [ $i = 0 ]; then
# Note: if REMAINING is enabled:
# if [ $limit == 0 ]; then
if true; then
el="<uint8-numbers>$li</uint8-numbers>"
el2="<uint8-numbers xmlns=\"http://example.com/ns/example-social\">$li</uint8-numbers>"
else
el="<uint8-numbers lp:remaining=\"$remaining\" xmlns:lp=\"urn:ietf:params:xml:ns:yang:ietf-list-pagination\">$li</uint8-numbers>"
el2="<uint8-numbers lp:remaining=\"$remaining\" xmlns:lp=\"urn:ietf:params:xml:ns:yang:ietf-list-pagination\" xmlns=\"http://example.com/ns/example-social\">$li</uint8-numbers>"
jsonmeta=",\"@example-social:uint8-numbers\":\[{\"ietf-list-pagination:remaining\":$remaining}\]"
fi
jsonlist="$li"
else
el="<uint8-numbers>$li</uint8-numbers>"
el2="<uint8-numbers xmlns=\"http://example.com/ns/example-social\">$li</uint8-numbers>" jsonlist="$jsonlist,$li"
fi
xmllist="$xmllist$el"
xmllist2="$xmllist2$el2"
let i++
done
jsonstr=""
if [ $limit -eq 0 ]; then
limitxmlstr=""
limitxmlstr=""
else
limitxmlstr="<limit>$limit</limit>"
jsonstr="?limit=$limit"
limitxmlstr="<limit>$limit</limit>"
jsonstr="?limit=$limit"
fi
if [ $offset -eq 0 ]; then
offsetxmlstr=""
offsetxmlstr=""
else
offsetxmlstr="<offset>$offset</offset>"
if [ -z "$jsonstr" ]; then
jsonstr="?offset=$offset"
else
jsonstr="${jsonstr}&offset=$offset"
fi
offsetxmlstr="<offset>$offset</offset>"
if [ -z "$jsonstr" ]; then
jsonstr="?offset=$offset"
else
jsonstr="${jsonstr}&offset=$offset"
fi
fi
if [ -z "$list" ]; then
reply="<rpc-reply $DEFAULTNS><data/></rpc-reply>"
reply="<rpc-reply $DEFAULTNS><data/></rpc-reply>"
else
reply="<rpc-reply $DEFAULTNS><data><members xmlns=\"http://example.com/ns/example-social\"><member><member-id>alice</member-id><favorites>$xmllist</favorites></member></members></data></rpc-reply>"
reply="<rpc-reply $DEFAULTNS><data><members xmlns=\"http://example.com/ns/example-social\"><member><member-id>alice</member-id><favorites>$xmllist</favorites></member></members></data></rpc-reply>"
fi
new "limit=$limit offset=$offset NETCONF get-config"
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><get-config><source><running/></source><filter type=\"xpath\" select=\"/es:members/es:member[es:member-id='alice']/es:favorites/es:uint8-numbers\" xmlns:es=\"http://example.com/ns/example-social\"/><list-pagination xmlns=\"urn:ietf:params:xml:ns:yang:ietf-list-pagination-nc\">$limitxmlstr$offsetxmlstr</list-pagination></get-config></rpc>" "" "$reply"
if [ -z "$list" ]; then
reply="<rpc-reply $DEFAULTNS><data/></rpc-reply>"
reply="<rpc-reply $DEFAULTNS><data/></rpc-reply>"
else
reply="<rpc-reply $DEFAULTNS><data><members xmlns=\"http://example.com/ns/example-social\"><member><member-id>alice</member-id><favorites>$xmllist</favorites></member></members></data></rpc-reply>"
reply="<rpc-reply $DEFAULTNS><data><members xmlns=\"http://example.com/ns/example-social\"><member><member-id>alice</member-id><favorites>$xmllist</favorites></member></members></data></rpc-reply>"
fi
new "limit=$limit offset=$offset NETCONF get"
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><get><filter type=\"xpath\" select=\"/es:members/es:member[es:member-id='alice']/es:favorites/es:uint8-numbers\" xmlns:es=\"http://example.com/ns/example-social\"/><list-pagination xmlns=\"urn:ietf:params:xml:ns:yang:ietf-list-pagination-nc\">$limitxmlstr$offsetxmlstr</list-pagination></get></rpc>" "" "$reply"
if [ -z "$list" ]; then
reply="<xml-list xmlns=\"urn:ietf:params:xml:ns:yang:ietf-list-pagination\"/>"
reply="<xml-list xmlns=\"urn:ietf:params:xml:ns:yang:ietf-list-pagination\"/>"
else
reply="<xml-list xmlns=\"urn:ietf:params:xml:ns:yang:ietf-list-pagination\">$xmllist2</xml-list>"
reply="<xml-list xmlns=\"urn:ietf:params:xml:ns:yang:ietf-list-pagination\">$xmllist2</xml-list>"
fi
new "limit=$limit offset=$offset Parameter RESTCONF xml"
expectpart "$(curl $CURLOPTS -X GET -H "Accept: application/yang-data+xml-list" $RCPROTO://localhost/restconf/data/example-social:members/member=alice/favorites/uint8-numbers${jsonstr})" 0 "HTTP/$HVER 200" "Content-Type: application/yang-data+xml-list" "$reply"
if [ -z "$list" ]; then
# reply="{\"xml-list\":{}}"
reply="{}"
# reply="{\"xml-list\":{}}"
reply="{}"
else
reply="{\"example-social:uint8-numbers\":\[$jsonlist\]}"
reply="{\"example-social:uint8-numbers\":\[$jsonlist\]}"
fi
new "limit=$limit offset=$offset Parameter RESTCONF json"
expectpart "$(curl $CURLOPTS -X GET -H "Accept: application/yang-data+json" $RCPROTO://localhost/restconf/data/example-social:members/member=alice/favorites/uint8-numbers${jsonstr})" 0 "HTTP/$HVER 200" "Content-Type: application/yang-data+json" "$reply" --not-- "xml-list"
@ -357,7 +357,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
err
fi
sudo pkill -f clixon_backend # to be sure
@ -420,7 +420,7 @@ if [ $BE -ne 0 ]; then
# Check if premature kill
pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then
err "backend already dead"
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg

View file

@ -101,15 +101,15 @@ function testrun_start()
new "test params: -f $cfg -s init -- -siS $fstate -x $xpath"
if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
fi
sudo pkill -f clixon_backend # to be sure
new "start backend -s init -f $cfg -- -siS $fstate -x $xpath"
start_backend -s init -f $cfg -- -siS $fstate -x $xpath
new "kill old backend"
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
fi
sudo pkill -f clixon_backend # to be sure
new "start backend -s init -f $cfg -- -siS $fstate -x $xpath"
start_backend -s init -f $cfg -- -siS $fstate -x $xpath
fi
new "wait backend"
@ -119,14 +119,14 @@ function testrun_start()
function testrun_stop()
{
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
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
}
@ -166,7 +166,7 @@ if [ -n "$(type expect 2> /dev/null)" ]; then
new "CLI scroll test using expect"
expect ./test_pagination_expect.exp "$cfg" "$xpath" bob3 bob4
if [ $? -ne 0 ]; then
err1 "Failed: CLI show paginate state scroll using expect"
err1 "Failed: CLI show paginate state scroll using expect"
fi
testrun_stop

View file

@ -356,13 +356,13 @@ module pattern{
leaf p45 {
description "Recognizing a CDATA pattern";
type string {
pattern "<!\[CDATA\[.{1,10}\]\]>";
pattern "<!\[CDATA\[.{1,10}\]\]>";
}
}
leaf p46 {
description "opencoinfig types/openconfig-inet-types.yang ipv4-address";
type string {
pattern '^(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|' +
pattern '^(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|' +
'25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4]' +
'[0-9]|25[0-5])$';
}
@ -403,13 +403,13 @@ function testrun(){
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><edit-config><target><candidate/></target><config><c xmlns='urn:example:clixon'><$leaf>$str</$leaf></c></config></edit-config></rpc>" "" "<rpc-reply $DEFAULTNS><ok/></rpc-reply>"
if $mat; then
new "netconf validate expected match"
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><validate><source><candidate/></source></validate></rpc>" "" "<rpc-reply $DEFAULTNS><ok/></rpc-reply>"
new "netconf validate expected match"
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><validate><source><candidate/></source></validate></rpc>" "" "<rpc-reply $DEFAULTNS><ok/></rpc-reply>"
else
new "netconf validate expected fail"
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><validate><source><candidate/></source></validate></rpc>" "<rpc-reply $DEFAULTNS><rpc-error><error-type>application</error-type><error-tag>bad-element</error-tag><error-info><bad-element>$leaf</bad-element></error-info><error-severity>error</error-severity>" ""
new "netconf discard-changes"
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><discard-changes/></rpc>" "^<rpc-reply $DEFAULTNS><ok/></rpc-reply>"
new "netconf validate expected fail"
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><validate><source><candidate/></source></validate></rpc>" "<rpc-reply $DEFAULTNS><rpc-error><error-type>application</error-type><error-tag>bad-element</error-tag><error-info><bad-element>$leaf</bad-element></error-info><error-severity>error</error-severity>" ""
new "netconf discard-changes"
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><discard-changes/></rpc>" "^<rpc-reply $DEFAULTNS><ok/></rpc-reply>"
fi
}
@ -419,7 +419,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
err
fi
new "start backend -s init -f $cfg"
start_backend -s init -f $cfg
@ -824,7 +824,7 @@ if [ $BE -ne 0 ]; then
# Check if premature kill
pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then
err "backend already dead"
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg

View file

@ -76,7 +76,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
err
fi
new "start backend -s init -f $cfg -- -s"
@ -154,7 +154,7 @@ if [ $BE -ne 0 ]; then
# Check if premature kill
pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then
err "backend already dead"
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg

View file

@ -69,20 +69,20 @@ function testrun(){
new "test params: -f $cfg"
if [ $BE -ne 0 ]; then
new "generate config with $nr list entries"
echo -n "<${DATASTORE_TOP}><x xmlns=\"urn:example:clixon\">" > $dir/startup_db
for (( i=0; i<$nr; i++ )); do
echo -n "<y><a>$i</a><b>$i</b></y>" >> $dir/startup_db
done
echo "</x></${DATASTORE_TOP}>" >> $dir/startup_db
new "generate config with $nr list entries"
echo -n "<${DATASTORE_TOP}><x xmlns=\"urn:example:clixon\">" > $dir/startup_db
for (( i=0; i<$nr; i++ )); do
echo -n "<y><a>$i</a><b>$i</b></y>" >> $dir/startup_db
done
echo "</x></${DATASTORE_TOP}>" >> $dir/startup_db
new "kill old backend"
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
fi
new "start backend -s startup -f $cfg"
start_backend -s startup -f $cfg
new "kill old backend"
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
fi
new "start backend -s startup -f $cfg"
start_backend -s startup -f $cfg
fi
new "wait backend"
@ -97,7 +97,7 @@ function testrun(){
err0=$(echo "$res" | $clixon_util_xpath -p "/rpc-reply/rpc-error")
err=${err0#"nodeset:"}
if [ -n "$err" ]; then
err1 "<rpc-reply><global>" "$err"
err1 "<rpc-reply><global>" "$err"
fi
objects=$(echo "$res" | $clixon_util_xpath -p "/rpc-reply/global/xmlnr" | awk -F ">" '{print $2}' | awk -F "<" '{print $1}')
@ -106,42 +106,42 @@ function testrun(){
#
if [ -f /proc/$pid/statm ]; then # This only works on Linux
# cat /proc/$pid/statm
echo -n " /proc/$pid/statm: "
cat /proc/$pid/statm|awk '{print $1*4/1000 "M"}'
# cat /proc/$pid/statm
echo -n " /proc/$pid/statm: "
cat /proc/$pid/statm|awk '{print $1*4/1000 "M"}'
fi
for db in running candidate startup; do
echo "$db"
resdb0=$(echo "$res" | $clixon_util_xpath -p "/rpc-reply/datastore[name=\"$db\"]")
resdb=${resdb0#"nodeset:0:"}
if [ "$resdb0" = "$resdb" ]; then
err1 "nodeset:0:" "$resdb0"
fi
echo -n " objects: "
echo $resdb | $clixon_util_xpath -p "datastore/nr" | awk -F ">" '{print $2}' | awk -F "<" '{print $1}'
echo -n " mem: "
echo $resdb | $clixon_util_xpath -p "datastore/size" | awk -F ">" '{print $2}' | awk -F "<" '{print $1}' | awk '{print $1/1000000 "M"}'
echo "$db"
resdb0=$(echo "$res" | $clixon_util_xpath -p "/rpc-reply/datastore[name=\"$db\"]")
resdb=${resdb0#"nodeset:0:"}
if [ "$resdb0" = "$resdb" ]; then
err1 "nodeset:0:" "$resdb0"
fi
echo -n " objects: "
echo $resdb | $clixon_util_xpath -p "datastore/nr" | awk -F ">" '{print $2}' | awk -F "<" '{print $1}'
echo -n " mem: "
echo $resdb | $clixon_util_xpath -p "datastore/size" | awk -F ">" '{print $2}' | awk -F "<" '{print $1}' | awk '{print $1/1000000 "M"}'
done
for mod in clixon-config; do
echo "$mod"
resmod0=$(echo "$res" | $clixon_util_xpath -p "/rpc-reply/module[name=\"$mod\"]")
resmod=${resmod0#"nodeset:0:"}
echo -n " objects: "
echo $resmod | $clixon_util_xpath -p "module/nr" | awk -F ">" '{print $2}' | awk -F "<" '{print $1}'
echo -n " mem: "
echo $resmod | $clixon_util_xpath -p "module/size" | awk -F ">" '{print $2}' | awk -F "<" '{print $1}' | awk '{print $1/1000000 "M"}'
echo "$mod"
resmod0=$(echo "$res" | $clixon_util_xpath -p "/rpc-reply/module[name=\"$mod\"]")
resmod=${resmod0#"nodeset:0:"}
echo -n " objects: "
echo $resmod | $clixon_util_xpath -p "module/nr" | awk -F ">" '{print $2}' | awk -F "<" '{print $1}'
echo -n " mem: "
echo $resmod | $clixon_util_xpath -p "module/size" | awk -F ">" '{print $2}' | awk -F "<" '{print $1}' | awk '{print $1/1000000 "M"}'
done
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
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
new "Zap backend"
stop_backend -f $cfg
new "Zap backend"
stop_backend -f $cfg
fi
}

View file

@ -80,7 +80,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
err
fi
new "start backend -s init -f $cfg -- -s"
@ -135,7 +135,7 @@ echo "$(chunked_framing "$rpc")" >> $ftest
ret=$(diff $ftest $foutput)
if [ $? -ne 0 ]; then
err1 "Matching running-db with $fconfigonly"
fi
fi
# Now commit it again from candidate (validation takes time when
# comparing to existing)
@ -234,7 +234,7 @@ if [ $BE -ne 0 ]; then
# Check if premature kill
pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then
err "backend already dead"
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg

View file

@ -96,7 +96,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
err
fi
# sudo pkill clixon_backend # extra
@ -158,7 +158,7 @@ ret=$(diff -i $ftest $foutput)
if [ $? -ne 0 ]; then
echo "diff -i $ftest $foutput"
err1 "Matching running-db with $fdataxml"
fi
fi
# RESTCONF get
new "restconf get $perfreq small config 1 key index"
@ -235,7 +235,7 @@ if [ $BE -ne 0 ]; then
# Check if premature kill
pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then
err "backend already dead"
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg

View file

@ -112,7 +112,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
err
fi
# sudo pkill clixon_backend # extra
@ -172,7 +172,7 @@ ret=$(diff -i $ftest $foutput)
if [ $? -ne 0 ]; then
echo "diff -i $ftest $foutput"
err1 "Matching running-db with $fdataxml"
fi
fi
# RESTCONF get
new "restconf get $perfreq small config 1 key index"
@ -249,7 +249,7 @@ if [ $BE -ne 0 ]; then
# Check if premature kill
pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then
err "backend already dead"
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg

View file

@ -74,7 +74,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -zf $cfg -y $fyang
if [ $? -ne 0 ]; then
err
err
fi
fi
@ -105,10 +105,10 @@ cat<<EOF > $sxpp
<x>
EOF
for (( i=0; i<$perfnr; i++ )); do
echo " <y>" >> $sxpp
echo " <a>$i</a>" >> $sxpp
echo " <b>$i</b>" >> $sxpp
echo " </y>" >> $sxpp
echo " <y>" >> $sxpp
echo " <a>$i</a>" >> $sxpp
echo " <b>$i</b>" >> $sxpp
echo " </y>" >> $sxpp
done
cat<<EOF >> $sxpp
</x>
@ -123,9 +123,9 @@ new "generate pretty-printed json startup config ($sj) with $perfnr entries"
echo -n '{"config": {"scaling:x":{"y":[' > $sj
for (( i=0; i<$perfnr; i++ )); do
if [ $i -ne 0 ]; then
echo -n ",{\"a\":$i,\"b\":$i}" >> $sj
echo -n ",{\"a\":$i,\"b\":$i}" >> $sj
else
echo -n "{\"a\":$i,\"b\":$i}" >> $sj
echo -n "{\"a\":$i,\"b\":$i}" >> $sj
fi
done
@ -139,13 +139,13 @@ sdb=$dir/${mode}_db
for variant in prefix plain pretty; do
case $variant in
plain)
f=$sx
f=$sx
;;
pretty)
f=$sxpp
pretty)
f=$sxpp
;;
prefix)
f=$sxpre
prefix)
f=$sxpre
;;
esac

View file

@ -102,7 +102,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
err
fi
new "start backend -s init -f $cfg -- -sS $fstate"
@ -211,7 +211,7 @@ if [ $BE -ne 0 ]; then
# Check if premature kill
pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then
err "backend already dead"
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg

View file

@ -102,7 +102,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
err
fi
new "start backend -s init -f $cfg -- -sS $fstate"
@ -194,7 +194,7 @@ if [ $BE -ne 0 ]; then
# Check if premature kill
pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then
err "backend already dead"
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg

View file

@ -26,7 +26,7 @@ cat <<EOF > $cfg
<clixon-config xmlns="http://clicon.org/config">
<CLICON_CONFIGFILE>$cfg</CLICON_CONFIGFILE>
<CLICON_YANG_DIR>${YANG_INSTALLDIR}</CLICON_YANG_DIR>
<CLICON_YANG_MAIN_FILE>$fyang</CLICON_YANG_MAIN_FILE>
<CLICON_YANG_MAIN_FILE>$fyang</CLICON_YANG_MAIN_FILE>
<CLICON_SOCK>$dir/$APPNAME.sock</CLICON_SOCK>
<CLICON_BACKEND_PIDFILE>/var/tmp/$APPNAME.pidfile</CLICON_BACKEND_PIDFILE>
<CLICON_XMLDB_DIR>$dir</CLICON_XMLDB_DIR>
@ -68,7 +68,7 @@ function testrun(){
new "kill old backend"
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
err
fi
# Kill all backends regardless of user or pid files (we mess with them in this test)
sudo pkill -f clixon_backend
@ -78,42 +78,42 @@ function testrun(){
new "start backend -f $cfg -s init -D $DBG -o CLICON_BACKEND_PRIVILEGES=$priv_mode -o CLICON_BACKEND_USER=$beuser"
sudo -u $startuser $clixon_backend -f $cfg -s init -D $DBG -o CLICON_BACKEND_PRIVILEGES=$priv_mode -o CLICON_BACKEND_USER=$beuser
if [ $? -ne 0 ]; then
err
err
fi
sleep 1 # wait for backend to exit
pid=$(pgrep -f clixon_backend)
if [ $? -ne 0 ]; then
if [ $expecterr -eq 1 ]; then
return 0
fi
err
if [ $expecterr -eq 1 ]; then
return 0
fi
err
fi
new "Number of clixon_backend processes"
c=$(pgrep -c -f clixon_backend)
if [ $c -ne 1 ]; then
err 1 $c
err 1 $c
fi
new "wait backend"
wait_backend
if [ $expecterr -eq 1 ]; then
err "Expected error"
err "Expected error"
fi
# Get uid now, and compare with expected user (tail to skip hdr)
u=$(ps -p $pid -u | tail -1 | awk '{print $1}')
if [ $u != $expectuser ]; then
err "$expectuser but user is $u"
err "$expectuser but user is $u"
fi
new "Kill backend"
# Check if premature kill
pid=$(pgrep -f clixon_backend)
if [ -z "$pid" ]; then
err "backend already dead"
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg

View file

@ -42,20 +42,20 @@ module clixon-example {
mandatory true;
case local {
container local-definition {
presence true;
leaf dummy1{
presence true;
leaf dummy1{
type string;
default "foo1";
}
default "foo1";
}
}
}
case keystore {
container keystore-reference {
presence true;
leaf dummy2{
presence true;
leaf dummy2{
type string;
default "bar1";
}
default "bar1";
}
}
}
}
@ -64,11 +64,11 @@ module clixon-example {
description "See ietf-tls-server@2022-05-24.yang";
uses ex:mygrouping{
refine "mykeystore/local/local-definition/dummy1" {
default "foo2";
default "foo2";
}
refine "mykeystore/keystore/keystore-reference"
+ "/dummy2" {
default "bar2";
default "bar2";
}
}
}
@ -83,7 +83,7 @@ if [ $BE -ne 0 ]; then
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
err
fi
new "start backend -s init -f $cfg"
start_backend -s init -f $cfg
@ -109,7 +109,7 @@ if [ $BE -ne 0 ]; then
# Check if premature kill
pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then
err "backend already dead"
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg

View file

@ -119,135 +119,135 @@ module clixon-example {
namespace "urn:example:clixon";
prefix ex;
import ietf-interfaces {
/* is in yang/optional which means clixon must be installed using --opt-yang-installdir */
prefix if;
/* is in yang/optional which means clixon must be installed using --opt-yang-installdir */
prefix if;
}
import ietf-ip {
prefix ip;
prefix ip;
}
import iana-if-type {
prefix ianaift;
prefix ianaift;
}
import ietf-datastores {
prefix ds;
prefix ds;
}
import clixon-autocli{
prefix autocli;
prefix autocli;
}
description
"Clixon example used as a part of the Clixon test suite.
"Clixon example used as a part of the Clixon test suite.
It can be used as a basis for making new Clixon applications.
Note, may change without updating revision, just for testing current master.
";
/* Example interface type for tests, local callbacks, etc */
identity eth {
base if:interface-type;
base if:interface-type;
}
identity loopback {
base if:interface-type;
base if:interface-type;
}
/* Generic config data */
container table{
list parameter{
key name;
leaf name{
type string;
}
leaf value{
type string;
}
leaf hidden{
type string;
autocli:hide;
}
leaf stat{
description "Inline state data for example application";
config false;
type int32;
}
}
list parameter{
key name;
leaf name{
type string;
}
leaf value{
type string;
}
leaf hidden{
type string;
autocli:hide;
}
leaf stat{
description "Inline state data for example application";
config false;
type int32;
}
}
}
/* State data (not config) for the example application*/
container state {
config false;
description "state data for the example application (must be here for example get operation)";
leaf-list op {
config false;
description "state data for the example application (must be here for example get operation)";
leaf-list op {
type string;
}
}
}
augment "/if:interfaces/if:interface" {
container my-status {
config false;
description "For testing augment+state";
leaf int {
type int32;
}
leaf str {
type string;
}
}
container my-status {
config false;
description "For testing augment+state";
leaf int {
type int32;
}
leaf str {
type string;
}
}
}
/* yang extension implemented by the example backend code. */
extension e4 {
description
"The first child of the ex:e4 (unknown) statement is inserted into
the module as a regular data statement. This means that 'uses bar;'
in the ex:e4 statement below is a valid data node";
argument arg;
description
"The first child of the ex:e4 (unknown) statement is inserted into
the module as a regular data statement. This means that 'uses bar;'
in the ex:e4 statement below is a valid data node";
argument arg;
}
grouping bar {
leaf bar{
type string;
}
leaf bar{
type string;
}
}
ex:e4 arg1{
uses bar;
uses bar;
}
rpc client-rpc {
description "Example local client-side RPC that is processed by the
description "Example local client-side RPC that is processed by the
the netconf/restconf and not sent to the backend.
This is a clixon implementation detail: some rpc:s
are better processed by the client for API or perf reasons";
input {
leaf x {
type string;
}
}
output {
leaf x {
type string;
}
}
input {
leaf x {
type string;
}
}
output {
leaf x {
type string;
}
}
}
rpc empty {
description "Smallest possible RPC with no input or output sections";
description "Smallest possible RPC with no input or output sections";
}
rpc example {
description "Some example input/output for testing RFC7950 7.14.
description "Some example input/output for testing RFC7950 7.14.
RPC simply echoes the input for debugging.";
input {
leaf x {
description
"If a leaf in the input tree has a 'mandatory' statement with
input {
leaf x {
description
"If a leaf in the input tree has a 'mandatory' statement with
the value 'true', the leaf MUST be present in an RPC invocation.";
type string;
mandatory true;
}
leaf y {
description
"If a leaf in the input tree has a 'mandatory' statement with the
type string;
mandatory true;
}
leaf y {
description
"If a leaf in the input tree has a 'mandatory' statement with the
value 'true', the leaf MUST be present in an RPC invocation.";
type string;
default "42";
}
}
output {
leaf x {
type string;
}
leaf y {
type string;
}
type string;
default "42";
}
}
output {
leaf x {
type string;
}
leaf y {
type string;
}
}
}
}
@ -267,15 +267,15 @@ function testrun()
new "test params: -f $cfg -- -s"
if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
fi
sudo pkill -f clixon_backend # to be sure
new "kill old backend"
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
fi
sudo pkill -f clixon_backend # to be sure
new "start backend -s init -f $cfg -- -s"
start_backend -s init -f $cfg -- -s
new "start backend -s init -f $cfg -- -s"
start_backend -s init -f $cfg -- -s
fi
new "wait backend"
@ -288,160 +288,160 @@ function testrun()
expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><commit/></rpc>" "" "<rpc-reply $DEFAULTNS><ok/></rpc-reply>"
if [ $RC -ne 0 ]; then
new "kill old restconf daemon"
stop_restconf_pre
new "kill old restconf daemon"
stop_restconf_pre
new "start restconf daemon"
# inline of start_restconf, cant make quotes to work
echo "sudo -u $wwwstartuser -s $clixon_restconf $RCLOG -D $DBG -f $cfg -R $RESTCONFIG1"
sudo -u $wwwstartuser -s $clixon_restconf $RCLOG -D $DBG -f $cfg -R "$RESTCONFIG1" </dev/null &>/dev/null &
if [ $? -ne 0 ]; then
err1 "expected 0" "$?"
fi
new "start restconf daemon"
# inline of start_restconf, cant make quotes to work
echo "sudo -u $wwwstartuser -s $clixon_restconf $RCLOG -D $DBG -f $cfg -R $RESTCONFIG1"
sudo -u $wwwstartuser -s $clixon_restconf $RCLOG -D $DBG -f $cfg -R "$RESTCONFIG1" </dev/null &>/dev/null &
if [ $? -ne 0 ]; then
err1 "expected 0" "$?"
fi
fi
#------------------------------------------------------- HTTP/1 + HTTP/2
if [ ${HAVE_LIBNGHTTP2} = true -a ${HAVE_HTTP1} = true ]; then
if [ $proto = http ]; then # No plain http/2
HVER=1.1
else
HVER=2
fi
new "wait restconf"
wait_restconf
if [ $proto = http ]; then # No plain http/2
HVER=1.1
else
HVER=2
fi
new "wait restconf"
wait_restconf
new "restconf root discovery. RFC 8040 3.1 (xml+xrd)"
echo "curl $CURLOPTS -X GET $proto://$addr/.well-known/host-meta"
expectpart "$(curl $CURLOPTS -X GET $proto://$addr/.well-known/host-meta)" 0 "HTTP/$HVER 200" "<XRD xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0'>" "<Link rel='restconf' href='/restconf'/>" "</XRD>"
new "restconf root discovery. RFC 8040 3.1 (xml+xrd)"
echo "curl $CURLOPTS -X GET $proto://$addr/.well-known/host-meta"
expectpart "$(curl $CURLOPTS -X GET $proto://$addr/.well-known/host-meta)" 0 "HTTP/$HVER 200" "<XRD xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0'>" "<Link rel='restconf' href='/restconf'/>" "</XRD>"
echo "fcgi or native+http/1 or native+http/1+http/2"
if [ "${WITH_RESTCONF}" = "native" ]; then # XXX does not work with nginx
new "restconf GET http/1.0 - returns 1.0"
expectpart "$(curl $CURLOPTS --http1.0 -X GET $proto://$addr/.well-known/host-meta)" 0 'HTTP/1.0 200 OK' "<XRD xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0'>" "<Link rel='restconf' href='/restconf'/>" "</XRD>"
fi
new "restconf GET http/1.1"
expectpart "$(curl $CURLOPTS --http1.1 -X GET $proto://$addr/.well-known/host-meta)" 0 'HTTP/1.1 200 OK' "<XRD xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0'>" "<Link rel='restconf' href='/restconf'/>" "</XRD>"
echo "fcgi or native+http/1 or native+http/1+http/2"
if [ "${WITH_RESTCONF}" = "native" ]; then # XXX does not work with nginx
new "restconf GET http/1.0 - returns 1.0"
expectpart "$(curl $CURLOPTS --http1.0 -X GET $proto://$addr/.well-known/host-meta)" 0 'HTTP/1.0 200 OK' "<XRD xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0'>" "<Link rel='restconf' href='/restconf'/>" "</XRD>"
fi
new "restconf GET http/1.1"
expectpart "$(curl $CURLOPTS --http1.1 -X GET $proto://$addr/.well-known/host-meta)" 0 'HTTP/1.1 200 OK' "<XRD xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0'>" "<Link rel='restconf' href='/restconf'/>" "</XRD>"
new "restconf GET http/2 switch protocol"
if [ $proto = http ]; then # see (2) https to http port in restconf_main_native.c
expectpart "$(curl $CURLOPTS --http2 -X GET $proto://$addr/.well-known/host-meta)" 0 "" "HTTP/1.1 200" "<XRD xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0'>" "<Link rel='restconf' href='/restconf'/>" "</XRD>"
else
expectpart "$(curl $CURLOPTS --http2 -X GET $proto://$addr/.well-known/host-meta)" 0 "" "HTTP/2 200" "<XRD xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0'>" "<Link rel='restconf' href='/restconf'/>" "</XRD>" # Only if https: HTTP/1.1 101 Switching Protocols
fi
new "restconf GET http/2 switch protocol"
if [ $proto = http ]; then # see (2) https to http port in restconf_main_native.c
expectpart "$(curl $CURLOPTS --http2 -X GET $proto://$addr/.well-known/host-meta)" 0 "" "HTTP/1.1 200" "<XRD xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0'>" "<Link rel='restconf' href='/restconf'/>" "</XRD>"
else
expectpart "$(curl $CURLOPTS --http2 -X GET $proto://$addr/.well-known/host-meta)" 0 "" "HTTP/2 200" "<XRD xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0'>" "<Link rel='restconf' href='/restconf'/>" "</XRD>" # Only if https: HTTP/1.1 101 Switching Protocols
fi
# http2-prior knowledge
if [ $proto = http ]; then # see (2) https to http port in restconf_main_native.c
new "restconf GET http/2 prior-knowledge (http)"
expectpart "$(curl $CURLOPTS --http2-prior-knowledge -X GET $proto://$addr/.well-known/host-meta 2>&1)" "16 52 55" # "Error in the HTTP2 framing layer" "Connection reset by peer"
else
new "restconf GET https/2 prior-knowledge"
expectpart "$(curl $CURLOPTS --http2-prior-knowledge -X GET $proto://$addr/.well-known/host-meta)" 0 "HTTP/$HVER 200" "<XRD xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0'>" "<Link rel='restconf' href='/restconf'/>" "</XRD>"
fi
# Wrong protocol http when https or vice versa
if [ $proto = http ]; then # see (2) https to http port in restconf_main_native.c
new "Wrong proto=https on http port, expect err 35 wrong version number"
expectpart "$(curl $CURLOPTS -X GET https://$addr:80/.well-known/host-meta 2>&1)" 35 #"wrong version number" # dependent on curl version
else # see (1) http to https port in restconf_main_native.c
new "Wrong proto=http on https port, expect bad request http1+2"
# expectpart "$(curl $CURLOPTS -X GET http://$addr:443/.well-known/host-meta 2>&1)" 56 "Connection reset by peer"
expectpart "$(curl $CURLOPTS -X GET http://$addr:443/.well-known/host-meta)" 0 "HTTP/" "400"
# http2-prior knowledge
if [ $proto = http ]; then # see (2) https to http port in restconf_main_native.c
new "restconf GET http/2 prior-knowledge (http)"
expectpart "$(curl $CURLOPTS --http2-prior-knowledge -X GET $proto://$addr/.well-known/host-meta 2>&1)" "16 52 55" # "Error in the HTTP2 framing layer" "Connection reset by peer"
else
new "restconf GET https/2 prior-knowledge"
expectpart "$(curl $CURLOPTS --http2-prior-knowledge -X GET $proto://$addr/.well-known/host-meta)" 0 "HTTP/$HVER 200" "<XRD xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0'>" "<Link rel='restconf' href='/restconf'/>" "</XRD>"
fi
# Wrong protocol http when https or vice versa
if [ $proto = http ]; then # see (2) https to http port in restconf_main_native.c
new "Wrong proto=https on http port, expect err 35 wrong version number"
expectpart "$(curl $CURLOPTS -X GET https://$addr:80/.well-known/host-meta 2>&1)" 35 #"wrong version number" # dependent on curl version
else # see (1) http to https port in restconf_main_native.c
new "Wrong proto=http on https port, expect bad request http1+2"
# expectpart "$(curl $CURLOPTS -X GET http://$addr:443/.well-known/host-meta 2>&1)" 56 "Connection reset by peer"
expectpart "$(curl $CURLOPTS -X GET http://$addr:443/.well-known/host-meta)" 0 "HTTP/" "400"
fi
fi
#------------------------------------------------------- HTTP/2 ONLY
elif [ ${HAVE_LIBNGHTTP2} = true -a ${HAVE_HTTP1} = false ]; then
HVER=2
new "wait restconf"
wait_restconf
HVER=2
new "wait restconf"
wait_restconf
new "restconf root discovery. RFC 8040 3.1 (xml+xrd)"
echo "curl $CURLOPTS -X GET $proto://$addr/.well-known/host-meta"
expectpart "$(curl $CURLOPTS -X GET $proto://$addr/.well-known/host-meta)" 0 "HTTP/$HVER 200" "<XRD xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0'>" "<Link rel='restconf' href='/restconf'/>" "</XRD>"
new "restconf root discovery. RFC 8040 3.1 (xml+xrd)"
echo "curl $CURLOPTS -X GET $proto://$addr/.well-known/host-meta"
expectpart "$(curl $CURLOPTS -X GET $proto://$addr/.well-known/host-meta)" 0 "HTTP/$HVER 200" "<XRD xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0'>" "<Link rel='restconf' href='/restconf'/>" "</XRD>"
echo "native + http/2 only"
# Important here is robustness of restconf daemon, not a meaningful reply
if [ $proto = http ]; then # see (2) https to http port in restconf_main_native.c
# http protocol mismatch can just close the socket if assumed its http/2
# everything else would guess it is http/1 which is really wrong here
# The tr statement replaces null char to get rid of annoying message:
# ./test_restconf.sh: line 180: warning: command substitution: ignored null byte in input
new "restconf GET http/1.0 - close"
expectpart "$(curl $CURLOPTS --http1.0 -X GET $proto://$addr/.well-known/host-meta | tr '\0' '\n')" 0 "" --not-- 'HTTP'
else
new "restconf GET https/1.0 - close"
expectpart "$(curl $CURLOPTS --http1.0 -X GET $proto://$addr/.well-known/host-meta)" "52 56" "" --not-- 'HTTP'
echo "native + http/2 only"
# Important here is robustness of restconf daemon, not a meaningful reply
if [ $proto = http ]; then # see (2) https to http port in restconf_main_native.c
# http protocol mismatch can just close the socket if assumed its http/2
# everything else would guess it is http/1 which is really wrong here
# The tr statement replaces null char to get rid of annoying message:
# ./test_restconf.sh: line 180: warning: command substitution: ignored null byte in input
new "restconf GET http/1.0 - close"
expectpart "$(curl $CURLOPTS --http1.0 -X GET $proto://$addr/.well-known/host-meta | tr '\0' '\n')" 0 "" --not-- 'HTTP'
else
new "restconf GET https/1.0 - close"
expectpart "$(curl $CURLOPTS --http1.0 -X GET $proto://$addr/.well-known/host-meta)" "52 56" "" --not-- 'HTTP'
fi
fi
if [ $proto = http ]; then
new "restconf GET http/1.1 - close"
expectpart "$(curl $CURLOPTS --http1.1 -X GET $proto://$addr/.well-known/host-meta | tr '\0' '\n')" 0 --not-- 'HTTP'
else
new "restconf GET https/1.1 - close"
expectpart "$(curl $CURLOPTS --http1.1 -X GET $proto://$addr/.well-known/host-meta)" "52 56" --not-- 'HTTP'
fi
if [ $proto = http ]; then
new "restconf GET http/2 switch protocol"
expectpart "$(curl $CURLOPTS --http2 -X GET $proto://$addr/.well-known/host-meta | tr '\0' '\n')" 0 --not-- 'HTTP'
else
new "restconf GET https/2 alpn protocol"
expectpart "$(curl $CURLOPTS --http2 -X GET $proto://$addr/.well-known/host-meta)" 0 "HTTP/$HVER 200" "<XRD xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0'>" "<Link rel='restconf' href='/restconf'/>" "</XRD>"
fi
if [ $proto = http ]; then
new "restconf GET http/1.1 - close"
expectpart "$(curl $CURLOPTS --http1.1 -X GET $proto://$addr/.well-known/host-meta | tr '\0' '\n')" 0 --not-- 'HTTP'
else
new "restconf GET https/1.1 - close"
expectpart "$(curl $CURLOPTS --http1.1 -X GET $proto://$addr/.well-known/host-meta)" "52 56" --not-- 'HTTP'
fi
if [ $proto = http ]; then
new "restconf GET http/2 switch protocol"
expectpart "$(curl $CURLOPTS --http2 -X GET $proto://$addr/.well-known/host-meta | tr '\0' '\n')" 0 --not-- 'HTTP'
else
new "restconf GET https/2 alpn protocol"
expectpart "$(curl $CURLOPTS --http2 -X GET $proto://$addr/.well-known/host-meta)" 0 "HTTP/$HVER 200" "<XRD xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0'>" "<Link rel='restconf' href='/restconf'/>" "</XRD>"
fi
# Wrong protocol http when https or vice versa
if [ $proto = http ]; then # see (2) https to http port in restconf_main_native.c
new "Wrong proto=https on http port, expect err 35 wrong version number"
expectpart "$(curl $CURLOPTS -X GET https://$addr:80/.well-known/host-meta 2>&1)" 35 #"wrong version number" # dependent on curl version
else # see (1) http to https port in restconf_main_native.c
new "Wrong proto=http on https port, expect bad request http2-only"
expectpart "$(curl $CURLOPTS -X GET http://$addr:443/.well-known/host-meta)" "16 52 55 56" --not-- 'HTTP'
fi
# Wrong protocol http when https or vice versa
if [ $proto = http ]; then # see (2) https to http port in restconf_main_native.c
new "Wrong proto=https on http port, expect err 35 wrong version number"
expectpart "$(curl $CURLOPTS -X GET https://$addr:80/.well-known/host-meta 2>&1)" 35 #"wrong version number" # dependent on curl version
else # see (1) http to https port in restconf_main_native.c
new "Wrong proto=http on https port, expect bad request http2-only"
expectpart "$(curl $CURLOPTS -X GET http://$addr:443/.well-known/host-meta)" "16 52 55 56" --not-- 'HTTP'
fi
else #------------------------------------------------------- HTTP/1 only
HVER=1.1
HVER=1.1
new "wait restconf"
wait_restconf
new "wait restconf"
wait_restconf
new "restconf root discovery. RFC 8040 3.1 (xml+xrd)"
echo "curl $CURLOPTS -X GET $proto://$addr/.well-known/host-meta"
expectpart "$(curl $CURLOPTS -X GET $proto://$addr/.well-known/host-meta)" 0 "HTTP/$HVER 200" "<XRD xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0'>" "<Link rel='restconf' href='/restconf'/>" "</XRD>"
new "restconf root discovery. RFC 8040 3.1 (xml+xrd)"
echo "curl $CURLOPTS -X GET $proto://$addr/.well-known/host-meta"
expectpart "$(curl $CURLOPTS -X GET $proto://$addr/.well-known/host-meta)" 0 "HTTP/$HVER 200" "<XRD xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0'>" "<Link rel='restconf' href='/restconf'/>" "</XRD>"
echo "fcgi or native+http/1 or native+http/1+http/2"
if [ "${WITH_RESTCONF}" = "native" ]; then # XXX does not work with nginx
new "restconf GET http/1.0 - returns 1.0"
expectpart "$(curl $CURLOPTS --http1.0 -X GET $proto://$addr/.well-known/host-meta)" 0 'HTTP/1.0 200 OK' "<XRD xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0'>" "<Link rel='restconf' href='/restconf'/>" "</XRD>"
fi
new "restconf GET http/1.1"
expectpart "$(curl $CURLOPTS --http1.1 -X GET $proto://$addr/.well-known/host-meta)" 0 'HTTP/1.1 200 OK' "<XRD xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0'>" "<Link rel='restconf' href='/restconf'/>" "</XRD>"
echo "fcgi or native+http/1 or native+http/1+http/2"
if [ "${WITH_RESTCONF}" = "native" ]; then # XXX does not work with nginx
new "restconf GET http/1.0 - returns 1.0"
expectpart "$(curl $CURLOPTS --http1.0 -X GET $proto://$addr/.well-known/host-meta)" 0 'HTTP/1.0 200 OK' "<XRD xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0'>" "<Link rel='restconf' href='/restconf'/>" "</XRD>"
fi
new "restconf GET http/1.1"
expectpart "$(curl $CURLOPTS --http1.1 -X GET $proto://$addr/.well-known/host-meta)" 0 'HTTP/1.1 200 OK' "<XRD xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0'>" "<Link rel='restconf' href='/restconf'/>" "</XRD>"
# http/1 only Try http/2 - go back to http/1.1
new "restconf GET http/2 switch protocol"
expectpart "$(curl $CURLOPTS --http2 -X GET $proto://$addr/.well-known/host-meta)" 0 "HTTP/1.1 200 OK" "<XRD xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0'>" "<Link rel='restconf' href='/restconf'/>" "</XRD>"
# http2-prior knowledge
if [ $proto = http ]; then # see (2) https to http port in restconf_main_native.c
new "restconf GET http/2 prior-knowledge (http)"
expectpart "$(curl $CURLOPTS --http2-prior-knowledge -X GET $proto://$addr/.well-known/host-meta 2>&1)" "16 52 55" # "Error in the HTTP2 framing layer" "Connection reset by peer"
else
new "restconf GET https/2 prior-knowledge"
expectpart "$(curl $CURLOPTS --http2-prior-knowledge -X GET $proto://$addr/.well-known/host-meta)" 0 "HTTP/$HVER 200" "<XRD xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0'>" "<Link rel='restconf' href='/restconf'/>" "</XRD>"
fi
# Wrong protocol http when https or vice versa
if [ $proto = http ]; then # see (2) https to http port in restconf_main_native.c
new "Wrong proto=https on http port, expect err 35 wrong version number"
expectpart "$(curl $CURLOPTS -X GET https://$addr:80/.well-known/host-meta 2>&1)" 35 #"wrong version number" # dependent on curl version
else # see (1) http to https port in restconf_main_native.c
new "Wrong proto=http on https port, expect bad request http/1 only"
# expectpart "$(curl $CURLOPTS -X GET http://$addr:443/.well-known/host-meta 2>&1)" 56 "Connection reset by peer"
expectpart "$(curl $CURLOPTS -X GET http://$addr:443/.well-known/host-meta)" 0 "HTTP/" "400"
fi
# http/1 only Try http/2 - go back to http/1.1
new "restconf GET http/2 switch protocol"
expectpart "$(curl $CURLOPTS --http2 -X GET $proto://$addr/.well-known/host-meta)" 0 "HTTP/1.1 200 OK" "<XRD xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0'>" "<Link rel='restconf' href='/restconf'/>" "</XRD>"
# http2-prior knowledge
if [ $proto = http ]; then # see (2) https to http port in restconf_main_native.c
new "restconf GET http/2 prior-knowledge (http)"
expectpart "$(curl $CURLOPTS --http2-prior-knowledge -X GET $proto://$addr/.well-known/host-meta 2>&1)" "16 52 55" # "Error in the HTTP2 framing layer" "Connection reset by peer"
else
new "restconf GET https/2 prior-knowledge"
expectpart "$(curl $CURLOPTS --http2-prior-knowledge -X GET $proto://$addr/.well-known/host-meta)" 0 "HTTP/$HVER 200" "<XRD xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0'>" "<Link rel='restconf' href='/restconf'/>" "</XRD>"
fi
# Wrong protocol http when https or vice versa
if [ $proto = http ]; then # see (2) https to http port in restconf_main_native.c
new "Wrong proto=https on http port, expect err 35 wrong version number"
expectpart "$(curl $CURLOPTS -X GET https://$addr:80/.well-known/host-meta 2>&1)" 35 #"wrong version number" # dependent on curl version
else # see (1) http to https port in restconf_main_native.c
new "Wrong proto=http on https port, expect bad request http/1 only"
# expectpart "$(curl $CURLOPTS -X GET http://$addr:443/.well-known/host-meta 2>&1)" 56 "Connection reset by peer"
expectpart "$(curl $CURLOPTS -X GET http://$addr:443/.well-known/host-meta)" 0 "HTTP/" "400"
fi
fi # HTTP/2
# Exact match
@ -461,7 +461,7 @@ function testrun()
expect='<operations><client-rpc xmlns="urn:example:clixon"/><empty xmlns="urn:example:clixon"/>'
match=`echo $ret | grep --null -Eo "$expect"`
if [ -z "$match" ]; then
err "$expect" "$ret"
err "$expect" "$ret"
fi
new "restconf get restconf/yang-library-version. RFC8040 3.3.3"
@ -472,7 +472,7 @@ function testrun()
expect="<yang-library-version>2019-01-04</yang-library-version>"
match=`echo $ret | grep --null -Eo "$expect"`
if [ -z "$match" ]; then
err "$expect" "$ret"
err "$expect" "$ret"
fi
new "restconf schema resource, RFC 8040 sec 3.7 according to RFC 8525 (explicit resource)"
@ -520,7 +520,7 @@ function testrun()
expect='<state xmlns="urn:example:clixon"><op>41</op><op>42</op><op>43</op></state>'
match=`echo $ret | grep --null -Eo "$expect"`
if [ -z "$match" ]; then
err "$expect" "$ret"
err "$expect" "$ret"
fi
new "restconf get data type json"
@ -532,7 +532,7 @@ function testrun()
expect='<op xmlns="urn:example:clixon">42</op>'
match=`echo $ret | grep --null -Eo "$expect"`
if [ -z "$match" ]; then
err "$expect" "$ret"
err "$expect" "$ret"
fi
new "restconf get state operation type json"
@ -544,7 +544,7 @@ function testrun()
expect='<op xmlns="urn:example:clixon">42</op>'
match=`echo $ret | grep --null -Eo "$expect"`
if [ -z "$match" ]; then
err "$expect" "$ret"
err "$expect" "$ret"
fi
new "restconf GET datastore"
@ -616,8 +616,8 @@ function testrun()
expectpart "$(curl $CURLOPTS -X POST -H "Content-Type: application/yang-data+json" -d '{"clixon-example:input":{"x":42}}' $proto://$addr/restconf/operations/clixon-example:example)" 0 "HTTP/$HVER 200" '{"clixon-example:output":{"x":"42","y":"42"}}'
if ! $YANG_UNKNOWN_ANYDATA ; then
new "restconf rpc using POST json wrong"
expectpart "$(curl $CURLOPTS -X POST -H "Content-Type: application/yang-data+json" -d '{"clixon-example:input":{"wrongelement":"ipv4"}}' $proto://$addr/restconf/operations/clixon-example:example)" 0 "HTTP/$HVER 400" '{"ietf-restconf:errors":{"error":{"error-type":"application","error-tag":"unknown-element","error-info":{"bad-element":"wrongelement"},"error-severity":"error","error-message":"Failed to find YANG spec of XML node: wrongelement with parent: example in namespace: urn:example:clixon"}}}'
new "restconf rpc using POST json wrong"
expectpart "$(curl $CURLOPTS -X POST -H "Content-Type: application/yang-data+json" -d '{"clixon-example:input":{"wrongelement":"ipv4"}}' $proto://$addr/restconf/operations/clixon-example:example)" 0 "HTTP/$HVER 400" '{"ietf-restconf:errors":{"error":{"error-type":"application","error-tag":"unknown-element","error-info":{"bad-element":"wrongelement"},"error-severity":"error","error-message":"Failed to find YANG spec of XML node: wrongelement with parent: example in namespace: urn:example:clixon"}}}'
fi
new "restconf rpc non-existing rpc without namespace"
@ -637,7 +637,7 @@ function testrun()
expect='<output message-id="42" xmlns="urn:example:clixon"><x>42</x><y>42</y></output>'
match=`echo $ret | grep --null -Eo "$expect"`
if [ -z "$match" ]; then
err "$expect" "$ret"
err "$expect" "$ret"
fi
new "restconf rpc using wrong prefix"
@ -648,7 +648,7 @@ function testrun()
expect='<output xmlns="urn:example:clixon"><x>example</x></output>'
match=`echo $ret | grep --null -Eo "$expect"`
if [ -z "$match" ]; then
err "$expect" "$ret"
err "$expect" "$ret"
fi
new "restconf Add subtree without key (expected error)"
@ -658,19 +658,19 @@ function testrun()
expectpart "$(curl $CURLOPTS -X PUT -H "Content-Type: application/yang-data+json" -d '{"ietf-interfaces:interface":{"name":"eth/0/0","type":"clixon-example:eth","enabled":true}}' $proto://$addr/restconf/data/ietf-interfaces:interfaces/interface=a,b)" 0 "HTTP/$HVER 400" '{"ietf-restconf:errors":{"error":{"error-type":"rpc","error-tag":"malformed-message","error-severity":"error","error-message":"List key interface length mismatch"}}}'
if [ $RC -ne 0 ]; then
new "Kill restconf daemon"
stop_restconf
new "Kill restconf daemon"
stop_restconf
fi
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
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
}
@ -688,11 +688,11 @@ fi
for proto in $protos; do
addrs="127.0.0.1"
if $IPv6 ; then
addrs="$addrs \[::1\]"
addrs="$addrs \[::1\]"
fi
for addr in $addrs; do
new "restconf test: proto:$proto addr:$addr HVER:$HVER"
testrun $proto $addr
new "restconf test: proto:$proto addr:$addr HVER:$HVER"
testrun $proto $addr
done
done

View file

@ -68,12 +68,12 @@ module myexample{
namespace "urn:example:auth";
prefix ex;
import ietf-netconf-acm {
prefix nacm;
prefix nacm;
}
container top {
leaf anonymous{
type string;
}
}
leaf wilma {
type string;
}
@ -121,7 +121,7 @@ cat <<EOF > $dir/startup_db
<path xmlns:ex="urn:example:auth">/ex:top/ex:anonymous</path>
<action>permit</action>
</rule>
</rule-list>
</rule-list>
<rule-list>
<name>data-limited</name>
<group>limited</group>
@ -204,11 +204,11 @@ function testrun()
EOF
if [ $RC -ne 0 ]; then
new "kill old restconf daemon"
stop_restconf_pre
new "kill old restconf daemon"
stop_restconf_pre
new "start restconf daemon"
start_restconf -f $cfg
new "start restconf daemon"
start_restconf -f $cfg
fi
new "wait restconf"
@ -218,8 +218,8 @@ EOF
expectpart "$(curl $CURLOPTS $user -X GET $RCPROTO://localhost/restconf/data/myexample:top)" 0 $expectcode "$expectmsg"
if [ $RC -ne 0 ]; then
new "Kill restconf daemon"
stop_restconf
new "Kill restconf daemon"
stop_restconf
fi
}
@ -227,7 +227,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
err
fi
sudo pkill -f clixon_backend # to be sure
@ -281,7 +281,7 @@ if [ $BE -ne 0 ]; then
# Check if premature kill
pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then
err "backend already dead"
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg

View file

@ -63,7 +63,7 @@ cat <<EOF > $cfg
<CLICON_CONFIGFILE>$cfg</CLICON_CONFIGFILE>
<CLICON_FEATURE>ietf-netconf:startup</CLICON_FEATURE>
<CLICON_YANG_DIR>${YANG_INSTALLDIR}</CLICON_YANG_DIR>
<CLICON_YANG_MAIN_FILE>$fyang</CLICON_YANG_MAIN_FILE>
<CLICON_YANG_MAIN_FILE>$fyang</CLICON_YANG_MAIN_FILE>
<CLICON_BACKEND_DIR>/usr/local/lib/$APPNAME/backend</CLICON_BACKEND_DIR>
<CLICON_BACKEND_REGEXP>example_backend.so$</CLICON_BACKEND_REGEXP>
<CLICON_CLI_DIR>/usr/local/lib/$APPNAME/cli</CLICON_CLI_DIR>
@ -85,14 +85,14 @@ cat <<EOF > $cfg
<socket>
<description>callhome persistent</description>
<namespace>default</namespace>
<call-home>
<connection-type>
<persistent/>
</connection-type>
<reconnect-strategy>
<max-attempts>1</max-attempts>
</reconnect-strategy>
</call-home>
<call-home>
<connection-type>
<persistent/>
</connection-type>
<reconnect-strategy>
<max-attempts>1</max-attempts>
</reconnect-strategy>
</call-home>
<address>127.0.0.1</address>
<port>4336</port>
<ssl>true</ssl>
@ -100,23 +100,23 @@ cat <<EOF > $cfg
<socket>
<description>callhome periodic</description>
<namespace>default</namespace>
<call-home>
<connection-type>
<periodic>
<period>${PERIOD_S}</period>
<idle-timeout>${IDLE_TIMEOUT_S}</idle-timeout>
</periodic>
</connection-type>
<reconnect-strategy>
<max-attempts>3</max-attempts>
</reconnect-strategy>
</call-home>
<call-home>
<connection-type>
<periodic>
<period>${PERIOD_S}</period>
<idle-timeout>${IDLE_TIMEOUT_S}</idle-timeout>
</periodic>
</connection-type>
<reconnect-strategy>
<max-attempts>3</max-attempts>
</reconnect-strategy>
</call-home>
<address>127.0.0.1</address>
<port>8336</port>
<ssl>true</ssl>
</socket>
<socket>
<description>listen</description>
<description>listen</description>
<namespace>default</namespace>
<address>0.0.0.0</address>
<port>443</port>
@ -163,11 +163,11 @@ module clixon-example{
container table{
list parameter{
key name;
leaf name{
type string;
}
leaf value{
type string;
leaf name{
type string;
}
leaf value{
type string;
}
}
}
@ -220,11 +220,11 @@ commit("Commit the changes"), cli_commit();
quit("Quit"), cli_quit();
show("Show a particular state of the system"){
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);
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_show_auto_mode("running", "xml", false, true);
}
@ -282,7 +282,7 @@ if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
err
fi
new "start backend -s startup -f $cfg"
@ -373,7 +373,7 @@ if [ $BE -ne 0 ]; then
# Check if premature kill
pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then
err "backend already dead"
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg

Some files were not shown because too many files have changed in this diff Show more