#!/usr/bin/env bash # Keep a vector of {xpath, namespace} pairs, match xpath in parsed XML and check if symbols belong to namespace # If not, set that namespace. # This is a primitive upgrade mechanism if th emore general upgrade mechanism can not be used # 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 fyangA=$dir/A.yang fyangB=$dir/B.yang # Create configuration cat < $cfg $cfg ietf-netconf:startup /usr/local/share/clixon $dir /usr/local/var/$APPNAME/$APPNAME.sock /usr/local/lib/example/backend /usr/local/var/$APPNAME/$APPNAME.pidfile $dir true /usr/local/lib/$APPNAME/clispec /usr/local/lib/$APPNAME/cli $APPNAME EOF # Yang module A (base) cat < $fyangA module A{ prefix a; revision 2020-02-11; namespace "urn:example:a"; container x { container y { } } } EOF # Yang module B (augments A) cat < $fyangB module B{ prefix b; revision 2020-02-11; namespace "urn:example:b"; import A { prefix "a"; } augment "/a:x/ngrt:y" { container z { leaf w { type string; } } } } EOF # permission kludges sudo touch $dir/startup_db sudo chmod 666 $dir/startup_db # Create startup db of "old" db with incorrect augment namespace tagging cat < $dir/startup_db foo EOF # This is how it should look after repair, using prefixes AFTER=$(cat <foo EOF ) # Or using default: # foo 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 startup -f $cfg" start_backend -s startup -f $cfg new "waiting" wait_backend fi new "netconf get config" expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^$AFTER]]>]]>$" 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