#!/usr/bin/env bash # yang augment and default values # See https://github.com/clicon/clixon/issues/354 # # 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/augment.yang fyang2=$dir/example.yang cat < $cfg $cfg ietf-netconf:startup $dir ${YANG_INSTALLDIR} $fyang /usr/local/lib/$APPNAME/clispec /usr/local/lib/$APPNAME/cli $APPNAME /usr/local/var/$APPNAME/$APPNAME.sock /usr/local/var/$APPNAME/$APPNAME.pidfile $dir true EOF cat < $fyang2 module example { yang-version 1.1; namespace "urn:example:clixon"; prefix ex; revision "2019-03-04"; container table{ } } EOF cat < $fyang module augment { yang-version 1.1; namespace "urn:example:augment"; prefix aug; import example { prefix ex; } revision "2019-03-04"; augment "/ex:table" { container map{ leaf name{ type string; } leaf enable { type boolean; default true; } } } } EOF cat < $dir/startup_db <${DATASTORE_TOP}> me
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 startup -f $cfg" start_backend -s startup -f $cfg fi new "wait backend" wait_backend new "cli show config startup" expectpart "$($clixon_cli -1 -f $cfg -l o show config xml default report-all)" 0 '' '' 'true' new "cli delete map name" expectpart "$($clixon_cli -1 -f $cfg -l o delete table map name me)" 0 "" new "cli show config deleted" expectpart "$($clixon_cli -1 -f $cfg -l o show config xml default report-all)" 0 '
' '' 'true' new "cli set map name" expectpart "$($clixon_cli -1 -f $cfg -l o set table map name x)" 0 "" new "cli show config set" expectpart "$($clixon_cli -1 -f $cfg -l o show config xml default report-all)" 0 '
' '' 'true' 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 fi rm -rf $dir new "endtest" endtest