Forum Discussion
Andy_Herrman_22
Nimbostratus
Jul 09, 2007Dynamic Pool Names
I'd like to be able to select which pool to use based on some data in the HTTP request, but I don't want to have to hard code the pools in the iRule. Is it possible to dynamically create the pool name (stored in a variable) and then select the pool using that?
The pool command seems to take the name as if it's a literal, not a variable, meaning you do:
pool my_pool1
instead of
pool "my_pool1"
Is it possible to use strings or variables as the pool name? For instance, could I do
something like:
when HTTP_REQUEST {
Pool number stored in pid query param
set poolID [findstr [HTTP:uri] "pid=" 4 "&"]
set poolName "my_pool$poolID"
pool $poolName
}
or maybe
when HTTP_REQUEST {
Pool number stored in pid query param
set poolID [findstr [HTTP:uri] "pid=" 4 "&"]
pool "my_pool$poolID"
}
(my code might not be quite right. I haven't written an iRule in about a year and my dev F5 box isn't working right now so I can't test it).
- Absolutely. The only issue you lose is load time validation. If you try to use a dynamic pool name that isn't defined in the configuration, you'll get a runtime error causing the connection to abort. You'll want to enclose your pool command with a "catch" statement to ensure that the runtime error doesn't occur and if it does either assign a default pool, redirect the user somewhere, or use an HTTP::respond to return status content directly to the client.
http://devcentral.f5.com/Default.aspx?tabid=53&view=topic&forumid=5&postid=10280
- No problem. Let us know how it goes for you.
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects