#!/usr/bin/env bash # Test for RFC8528 YANG Schema Mount # Only if compiled with YANG_SCHEMA_MOUNT # Magic line must be first in script (see README.md) s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi if [ -z "${CLIXON_YANG_SCHEMA_MOUNT}" ]; then echo "...skipped. To enable configure with: --enable-yang-schema-mount" rm -rf $dir if [ "$s" = $0 ]; then exit 0; else return 0; fi # skip fi APPNAME=example cfg=$dir/conf_mount.xml fyang=$dir/clixon-example.yang cat < $cfg $cfg ${YANG_INSTALLDIR} ${dir} $fyang true /usr/local/lib/$APPNAME/clispec /usr/local/lib/$APPNAME/cli $APPNAME /usr/local/var/$APPNAME/$APPNAME.sock /usr/local/lib/$APPNAME/backend /usr/local/var/$APPNAME/$APPNAME.pidfile $dir true true true EOF cat < $fyang module clixon-example{ yang-version 1.1; namespace "urn:example:clixon"; prefix ex; import ietf-yang-schema-mount { prefix yangmnt; } container top{ list mylist{ key name; leaf name{ type string; } container root{ presence "Otherwise root is not visible"; yangmnt:mount-point "myroot"{ description "Root for other yang models"; } } } } } 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 fi new "wait backend" wait_backend new "Add two mountpoints: x and y" expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "xy" "" "" new "netconf commit" expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "Retrieve schema-mounts with Operation" expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "clixon-exampletrue" new "get yang-lib at mountpoint" # XXX maybe too many yangs here, difficult to maintain expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" ">" "x defaultclixon-autocli2022-02-11http://clicon.org/autocliclixon-example2022-11-01urn:example:clixonietf-datastores2018-02-14urn:ietf:params:xml:ns:yang:ietf-datastoresietf-inet-types2021-02-22urn:ietf:params:xml:ns:yang:ietf-inet-typesietf-yang-library2019-01-04urn:ietf:params:xml:ns:yang:ietf-yang-libraryietf-yang-types2013-07-15urn:ietf:params:xml:ns:yang:ietf-yang-typesmount-pointydefaultclixon-autocli2022-02-11http://clicon.org/autocliclixon-example2022-11-01urn:example:clixonietf-datastores2018-02-14urn:ietf:params:xml:ns:yang:ietf-datastoresietf-inet-types2021-02-22urn:ietf:params:xml:ns:yang:ietf-inet-typesietf-yang-library2019-01-04urn:ietf:params:xml:ns:yang:ietf-yang-libraryietf-yang-types2013-07-15urn:ietf:params:xml:ns:yang:ietf-yang-typesmount-point" 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