Sake_Blok
Sep 30, 2005Nimbostratus
Dynamically selecting a class (based on poolname)
Hi,
Is it possible to dynamically select a class? I want to use one class per pool which lists a cookie per server and select that server based on the cookie. Using passive cookies is not an option since I cannot change the cookie-values on the server. Of course I can write an iRule per virtual server, but it would be nicer to have a general one that is able to select the appropriate class.
It would be something like this:
rule prefCookie-iRule {
when CLIENT_ACCEPTED {
set defpool [LB::server pool]
log local0. "defpool selected for -> $defpool"
}
when HTTP_REQUEST {
if { [HTTP::cookie exists "lbsid"] } {
set tmp [findclass [HTTP::cookie "lbsid"] ::$defpool " "]
if { $tmp ne "" } {
log local0. $tmp
node $tmp
} else {
log local0. "[HTTP::cookie "lbsid"] is not a valid cookie-value!"
pool $defpool
}
} else {
log local0. "No lbsid cookie found!"
pool $defpool
}
}
when LB_FAILED {
log local0. "LB failed, so chose a new member!"
pool $defpool
LB::reselect
}
}
The problem is that the line 'set tmp [findclass [HTTP::cookie "lbsid"] ::$defpool " "]' does not work, it looks like this line is interpreted __before__ $defpool is set. How can I solve this? I guess I need a command that has a class as output and a string as input, but is there anything capable of doing that?
Cheers, Sake