#!/bin/bash # Netconf with default capability See RFC 6243 # Test what clixon has # These are the modes defined in RFC 6243: # o report-all # (o report-all-tagged) # o trim # o explicit # Clixon supports explicit, bit the testcases define the other cases as well # in case others will be supported # Magic line must be first in script (see README.md) s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi APPNAME=example cfg=$dir/conf_yang.xml fyang=$dir/example-default.yang cat < $cfg $cfg ietf-netconf:startup 42 /usr/local/share/clixon $IETFRFC $fyang /usr/local/lib/$APPNAME/clispec /usr/local/lib/$APPNAME/backend example_backend.so$ /usr/local/lib/$APPNAME/netconf /usr/local/lib/$APPNAME/restconf /usr/local/lib/$APPNAME/cli $APPNAME $dir/$APPNAME.sock /usr/local/var/$APPNAME/$APPNAME.pidfile 1 /usr/local/var/$APPNAME EOF cat < $fyang module example-default { namespace "urn:example:default"; prefix "ex"; typedef dt { description "Just a base type with a default value of 42"; type int32; default 42; } container c{ list x { key k; leaf k{ type string; } leaf y { /* Three possible values: notset, default(42), other(eg 99) */ type dt; } } } } EOF new "test params: -f $cfg" # 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 init -f $cfg" start_backend -s init -f $cfg new "waiting" wait_backend fi # This is the base XML with thre values in the server: noset, default, other XML='default42notsetother99' # report-all: doe not consider any data node to be default data, # even schema default data. (noset is set to 42) REPORT_ALL='default42notsetother99' # report-all: doe not consider any data node to be default data, # even schema default data. (noset is set to 42) REPORT_ALL='default42notset42other99' # trim: MUST consider any data node set to its schema default value to be # default data (default is not set) TRIM='defaultnotsetother99' # explicit: MUST consider any data node that is not explicitly set data to # be default data. # (SAME AS Input XML) EXPLICIT='default42notsetother99' new "Set defaults" expecteof "$clixon_netconf -qf $cfg" 0 "$XML]]>]]>" "^]]>]]>$" new "Check config (Clixon supports explicit)" expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' "^$EXPLICIT]]>]]>$" 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 stop_backend -f $cfg rm -rf $dir