#!/bin/bash # Yang specifics: multi-keys and empty type APPNAME=example # include err() and new() functions and creates $dir . ./lib.sh cfg=$dir/conf_yang.xml fyang=$dir/example.yang fyang2=$dir/example2.yang # /usr/local/share/$APPNAME/yang cat < $cfg $cfg $dir /usr/local/share/$APPNAME/yang /usr/local/share/clixon /usr/local/lib/$APPNAME/clispec /usr/local/lib/$APPNAME/cli $APPNAME /usr/local/var/$APPNAME/$APPNAME.sock /usr/local/var/$APPNAME/$APPNAME.pidfile 1 /usr/local/var/$APPNAME /usr/local/lib/xmldb/text.so true EOF # For testing namespaces - # x.y is different type. Here it is string whereas in fyang it is list. # cat < $fyang2 module example2{ yang-version 1.1; prefix ex2; namespace "urn:example:clixon2"; container x { leaf y { type uint32; } } } EOF cat < $fyang module example{ yang-version 1.1; prefix ex; namespace "urn:example:clixon"; import ietf-routing { description "defines fib-route"; prefix rt; } leaf x{ type int32; } rpc client-rpc { 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 request { type string; } } output { leaf result{ type string; } } } } 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 new backend sudo $clixon_backend -s init -f $cfg -D $DBG if [ $? -ne 0 ]; then err fi fi new "netconf xmlns module ex" expecteof "$clixon_netconf -qf $cfg" 0 '42]]>]]>' '^]]>]]>$' new "netconf get config XXX xmlfn in return" expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^42]]>]]>$" new "netconf xmlns module ex2" expecteof "$clixon_netconf -qf $cfg" 0 '99]]>]]>' '^]]>]]>$' new "netconf get config XXX xmlns" expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^4299]]>]]>$" new "netconf discard-changes" expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^]]>]]>$" new "netconf xmlns:ex" expecteof "$clixon_netconf -qf $cfg" 0 '4422]]>]]>' '^]]>]]>$' new "netconf get config XXX xmlns:ex" expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^4422]]>]]>$" new "netconf xmlns:ex2" expecteof "$clixon_netconf -qf $cfg" 0 '9999]]>]]>' '^]]>]]>$' new "netconf get config XXX xmlns:ex2" expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^44229999]]>]]>$" # rpc if [ $BE -eq 0 ]; then exit # BE fi 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 sudo clixon_backend -z -f $cfg if [ $? -ne 0 ]; then err "kill backend" fi sudo pkill -u root -f clixon_backend rm -rf $dir