Forum Discussion

Ashish_Gupta_15's avatar
Ashish_Gupta_15
Icon for Nimbostratus rankNimbostratus
Oct 19, 2016

static variable re-initialization on config reload

From: https://devcentral.f5.com/articles/the101-irules-101-variables

simply set up your static::varname variables, likely in RULE_INIT, since that special event only runs once at load time and static variables are global in scope, meaning they stay set until the configuration is reloaded.

I am overwriting the file with a new one from the GUI interface and then reloading the config using

tmsh load /sys config partitions-all

However, the static variable is not getting the new value from the file. Looks like It's value is never getting wiped out even after the reloading the config. What am I missing?

when RULE_INIT {
    if { [info exists static::key_value] and [string length static::key_value] }{
         Use existing key
    } else {
        set static::key_value [ifile get "/Common/key"]
    }

}