Forum Discussion
Kent_Perrier_50
Mar 16, 2011Nimbostratus
Data Groups for dummies
Is there an article out there that I can use as a data groups for dummies guide?
Do to a bug in 10.2.0 irule array processing, I need to rewrite an irule to use data groups instead and I hav...
Kent_Perrier_50
Mar 30, 2011Nimbostratus
Posted By hoolio on 03/18/2011 08:47 AM
Hi Kent,
That looks like a great start. You don't actually have to iterate through the datagroup manually to do a starts_with comparison. You can use class search to do this:
when RULE_INIT {
Log debug to /var/log/ltm? 1=yes, 0=no
set static::debug 0
}
when CLIENT_ACCEPTED {
Save the VS default pool name before it's changed
set default_pool "defpool01"
set the data group name
set clname "AppVersion[virtual name]"
}
when HTTP_REQUEST {
if there isn't a data group with the above name, set the pool to default and exit
if {[class exists $clname]} {
Search the datagroup for a name that starts with the URI
set pool_name [class search -value $clname starts_with [HTTP::uri]]
if { $pool_name eq ""} {
we don't match the context roots in the data class
if { $static::debug } { log local0. "fell through to the default pool" }
pool $default_pool
} else {
if { $static::debug } { log local0. "Matched $app_pool" }
pool $app_pool
}
} else {
if { $static::debug } { log local0. "Data group $clame not found, using default_pool $default_pool" }
pool $default_pool
}
}
Aaron
I'm back. I am testing this iRule and it does not appear to work. The pool_name variable does not appear to be set if my URI is, as I put it on the command line, ends with a / For example, if my data group looks like:
/foo2_1 := foo21
/foo2_2 := foo22
and I try to hit the virtual server with curl like this, curl http://10.10.10.100/foo2_1/, pool_name does not get set, and I fall through to the default pool, but nothing happens and the connection gets reset by peer. FYI, this is running on LTMVE, 10.2.0. Now, I don't think the connection getting reset has anything to do with the iRule. Is there anyway to see inside the line "set pool_name [class search -value....]" to find out what it happening there? If I add the trailing slash to the data group, /foo2_1/ instead of /foo2_1, pool_name sets set.
Also, app_pool is not used anyplace but in the log statement and where you set the pool to $app_pool. I have changed that to $pool_name.
Again, thanks for your help!
Kent
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