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 have no idea how.
Thanks!
- JRahmAdminadding this example to the class command page for future reference.
- JRahmAdminI also wrote up a tech tip on this to clarify all the formats:
- Kent_Perrier_50NimbostratusPosted By hoolio on 03/18/2011 08:47 AM Hi Kent,
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 } }
/foo2_1 := foo21 /foo2_2 := foo22
- hooleylistCirrostratusCan you try this instead:
- Kent_Perrier_50NimbostratusI am assuming that you swapped the [HTTP::uri] and $clname by accident.
- hooleylistCirrostratusNo, it's not particularly intuitive, but the class match command will work:
Datagroup class uri_prefixes_class { { "/foo1" { "pool1" } "/foo2" { "pool2" } } } iRule example when RULE_INIT { log local0. "\[class search -value uri_prefixes_class starts_with \"/foo123\"\]: [class search -value uri_prefixes_class starts_with "/foo123"]" log local0. "\[class match -value \"/foo123\" starts_with uri_prefixes_class\]: [class match -value "/foo123" starts_with uri_prefixes_class]" } /var/log/ltm output: < RULE_INIT >: [class search -value uri_prefixes_class starts_with "/foo123"]: < RULE_INIT >: [class match -value "/foo123" starts_with uri_prefixes_class]: pool1
- Colin_Walker_12Historic F5 AccountI believe the issue Aaron's outlining above, whether intentionally or not, is one major way in which class match and class search differ: order of operands.
* Example:class match [< options >] < item > < operator > < class >class search [< options >] < class > < operator > < item >Note that in the above the and positions are switched. This indicates an implicit difference in the way the lookup is performed. This is further outlined in the examples in the wiki:
- hooleylistCirrostratus...
- Kent_Perrier_50NimbostratusAh. I guess its too much effort to be consistent in the placement of arguments for different options of the same higher level command? Or is this the case where developer A worked on class match and developer B worked on class search, and they didn't talk to each other?
- Colin_Walker_12Historic F5 AccountI actually think this is a desired (albeit sometimes confusing) difference. These are semantically very different things and being able to achieve either as desired is a good thing. That's just my hunch, though, I don't have the official answer as to why they're different. Just trying to fill folks in. ;)
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