Hello. I want to operate multiple stage environments(development, staging, production) in a partition. For those environments, I want to use same aflex policies as many as possible. I had looked for use following aflex policies. staging_env.tcl
when RULE_INIT {
set ::global::target_service = "staging_service_80"
}
production_env.tcl
when RULE_INIT {
set ::global::target_service = "production_service_80"
}
http_location.tcl
when HTTP_REQUEST {
pool ::global::target_service
}
But ::global:: variables seem really global on the whole AX device. So I think the variable for the staging effects to the production. I want to use variables can be applied to one virtual service or one request. Do we have any solutions?
Mischa, Thank you for your response. I have just tried but result is NG. :: variable can not be read by other policies. I want to use separated policies to keep maintainability. config for a virtual service
port 80 http
name test
service-group pl_test
aflex test-env
aflex test-access
aflex test-env
when RULE_INIT {
set ::global::test_target_service "global"
set ::test_target_service "noglobal"
}
aflex test-access
when HTTP_REQUEST {
log "::global::test_target_service $::global::test_target_service"
log "::test_target_service $::test_target_service"
}
log(result) : logged only for the global variable
Mar 11 2014 01:05:22 Info [AFLEX]:::global::test_target_service global
I rechecked the manual ‘aFleX Scripting Language Reference’ and some descriptions there.
Prefix :: Scope Applies only to the current aFleX policy. This variable cannot be set or read by any other aFleX policies. Once the variable is defined, it can be removed only by an unset command. Prefix ::global:: Scope Applies to all aFleX policies. This variable can be set or read by all aFleX policies on the AX device.
Yes, you are correct the ::VAR can not be used by other scripts. I have been wrecking my brain but there isn’t a way to do what you want to do today.
Using tables for example will give you the same result as ::global::.
The only alternative would be to include the RULE_INIT in the actual script.