Forum Discussion
Vladimir_Akhmarov
Apr 26, 2020Cirrus
Hello all!
Recently deployed such a solution:
- Created iCall script with session termination logic (thanks Yann)
- Created iCall handler with type perpetual
- Used iControlREST to execute iCall handler
See Yann's article
Create your own iCall script and handler:
sys icall script ApmSessionPurge_script { ... }
sys icall handler perpetual ApmSessionPurge_handler { script ApmSessionPurge_script }
In the end of "definition" section of your iCall script add below commands. This command must be used because once perpetual handler will be started someone must stop it.
# Stop iCall handler after execution
catch {[exec -- /bin/tmsh stop sys icall handler perpetual ApmSessionPurge_handler]}
Shell example to use iControlREST:
BIGIP_ADDR='192.0.2.1'
BIGIP_USER='admin'
BIGIP_PSWD='admin123'
BIGIP_HDLR='ApmSessionPurge_handler'
BIGIP_AUTH=$(curl -sk -H 'Content-Type: application/json' -X POST -d "{'username':'"$BIGIP_USER"', 'password':'"$BIGIP_PSWD"', 'loginProviderName':'tmos'}" https://${BIGIP_ADDR}/mgmt/shared/authn/login)
# Use sed -nE below for regular Linux/MacOS
BIGIP_TOKEN=$(echo $BIGIP_AUTH | sed -nr 's/.*\"token\":\"([A-Z0-9]+)\".*/\1/p')
curl -sk -H 'Content-Type: application/json' -H "X-F5-Auth-Token: $BIGIP_TOKEN" -X POST -d "{\"command\":\"start\", \"name\":\"$BIGIP_HDLR\"}" https://${BIGIP_ADDR}/mgmt/tm/sys/icall/handler/perpetual