I am trying to re-write some iRules for CMP by removing the global variables however I’d like to know why I am getting this error. I’m not a complete TCL expert so some assistance is appreciated.
Oct 31 10:42:27 local/tmm err tmm[4996]: 01220001:3: TCL error: devdrmssi.dr.com - can’t read “org”: no such variable while executing "if { ([matchclass $subject_dn contains devdrmssi_trusted_certs]) and ($subject_dn contains $org) } { log “Http Request for devdrmssi accepted from…”
Moving the variable to after the HTTP_REQUEST worked … I guess that only Global Variables can be set in the RULE_INIT section … Now it makes some sense by moving it into the iRule itself so it can be processed as a local variable and I’m truly not going mad.
i understand variable which is defined in RULE_INIT will be treated as global variable. so, we have to use $:: when referencing. what Steve suggested is totally right.
[root@ve10:Active] config b rule myrule list
rule myrule {
when RULE_INIT {
set org "test"
}
when HTTP_REQUEST {
log local0. "\$::org is $::org"
}
}
[root@ve10:Active] config cat /var/log/ltm
Oct 31 21:23:59 local/tmm info tmm[7926]: Rule myrule : $::org is test