#!/usr/bin/env bash # Restconf RFC8040 Appendix A and B "jukebox" example # For pagination / scaling I-D activity # 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.xml fexample=$dir/example-module.yang fstate=$dir/mystate.xml # Define default restconfig config: RESTCONFIG RESTCONFIG=$(restconf_config none false) cat < $cfg $cfg ietf-netconf:startup clixon-restconf:allow-auth-none /usr/local/share/clixon $IETFRFC $dir false /usr/local/var/$APPNAME/$APPNAME.sock /usr/local/lib/$APPNAME/backend $dir/restconf.pidfile $dir true $APPNAME /usr/local/lib/$APPNAME/cli /usr/local/lib/$APPNAME/clispec $RESTCONFIG EOF cat <<'EOF' > $dir/startup_db Alice permit alice@example.com $0$1543 1 2 Customer Service 99 Problem Solving 90 Bob limited bob@example.com $0$2789 2 3 Conflict Resolution 93 Management 23 Organization 44 Problem Solving 98 Joe permit joe@example.com $0$6523 1 4 Management 96 Collaboration 92 Frank deny frank@example.com $0$4030 5 9 Organization 90 Negotiation 80 Tom permit tom@example.com $0$2376 2 5 Adaptability. 98 Active Listening 85 SvrA-http 92.0.2.0/24 forwarding SvrA-ftp 203.0.113.1/32 forwarding p2p p2p logging any any logging SvrA-tcp 80 forwarding 10.0.0.0/8 17 18 2000:1::/48 48 48 2000:2::/48 48 48 2000:3::/48 16 16 ::/0 0 128 EOF cat< $fstate Alice Available Bob Busy Joe Do Not Disturb Frank Offline Tom Do Not Disturb Cloud-IoT-Device-A 2020-07-08T12:38:32Z 2020-07-08T12:37:12Z Upload contains 6 datapoints Cloud-IoT-Device-B 2020-07-08T16:20:54Z 2020-07-08T16:20:14Z Upload successful Cloud-IoT-Device-C 2020-07-08T17:30:34Z 2020-07-08T17:30:12Z Receive a configuration update Cloud-IoT-Device-D 2020-07-08T18:40:13Z 2020-07-08T18:40:00Z Keep-alive ping sent to server Cloud-IoT-Device-E 2020-07-08T19:48:34Z 2020-07-08T19:48:00Z Uploading data to DataPoint 192.168.0.92 2020-11-01T06:47:59Z User-logged-out true 192.168.0.92 2020-11-01T06:49:03Z User-logged-in true 192.168.0.92 2020-11-01T06:51:34Z Patron-card-viewed false 192.168.0.92 2020-11-01T06:53:01Z User-logged-out true 192.168.0.92 2020-11-01T06:56:22Z User-logged-in false EOF # Common example-module spec (fexample must be set) . ./example_module.sh new "test params: -f $cfg -s startup -- -sS $fstate" if [ $BE -ne 0 ]; then new "kill old backend" sudo clixon_backend -zf $cfg if [ $? -ne 0 ]; then err fi sudo pkill -f clixon_backend # to be sure new "start backend -s startup -f $cfg -- -sS $mystate" start_backend -s startup -f $cfg -- -sS $fstate fi new "wait backend" wait_backend if [ $RC -ne 0 ]; then new "kill old restconf daemon" stop_restconf_pre new "start restconf daemon" start_restconf -f $cfg fi new "wait restconf" wait_restconf # draft-wwlh-netconf-list-pagination-nc-00.txt new "C.1. 'count' Parameter NETCONF" expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOds:running/exm:admins/exm:admin[exm:name='Bob']/exm:skill2]]>]]>" "Conflict Resolution93Management23]]>]]>$" new "C.2. 'skip' Parameter NETCONF" expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOds:running/exm:admins/exm:admin[exm:name='Bob']/exm:skill22]]>]]>" "Organization44Problem Solving98]]>]]>$" # CLI # XXX This relies on a very specific clispec command: need a more generic test new "cli show" echo "$clixon_cli -1 -f $cfg -l o show pagination" expectpart "$($clixon_cli -1 -f $cfg -l o show pagination)" 0 "" "Conflict Resolution" "93" "Management" "23" --not-- "Organization" "44" # draft-wwlh-netconf-list-pagination-rc-00.txt #new "A.1. 'count' Parameter RESTCONF" #expectpart "$(curl $CURLOPTS -X GET -H "Accept: application/yang.collection+xml" $RCPROTO://localhost/restconf/data/example-module:get-list-pagination/library/artist=Foo%20Fighters/album/?count=2)" 0 "HTTP/1.1 200 OK" "application/yang.collection+xml" 'Crime and Punishment1995One by One2002' if [ $RC -ne 0 ]; then new "Kill restconf daemon" stop_restconf fi 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 unset RESTCONFIG rm -rf $dir new "endtest" endtest