Forum Discussion
Is there a way for an iRule to read a default pool parameter from an unrelated, arbitrary virtual server?
Eddie,
It is possible to write data about a virtual server to the cache and retrieve it from other iRules, though it's a bit unorthodox. Perhaps it isn't the most optimized but here is an iRule I wrote that should cache the pool name of the virtual server given in the first item of the URI. For example, "https://example.com/testvip/uri" would log out the default pool member of the virtual server named "testvip".
when CLIENT_ACCEPTED
{
table set "[virtual name]" "[LB::server pool]" 864000
}
when HTTP_REQUEST
{
set vip_name "/Common/[lindex [split [HTTP::uri] "/"] 1]"
if {[table lookup $vip_name] eq "" }
{
log local0. "No records for this vip, try connecting to it first"
}
else
{
set pool_name [lindex [split [table lookup $vip_name] "/"] 2]
log local0. "Pool for $vip_name is $pool_name"
}
}
Do note that you must connect to the virtual server first so that it may cache its data, then you will be able to access that information from other virtual servers. I also set the cache lifetime to 10 days, so if a virtual server is not connected to for that amount of time, it will lose its cached data and you won't be able to access information about that virtual server from other virtual servers.
If you have any modification requests or questions, I am sure I can help.
Recent Discussions
Related Content
* 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