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!
- Michael_YatesNimbostratusI don't think that there are any wiki entries for Data Groups.
- JRahmAdminColin wrote one a while back: http://devcentral.f5.com/Tutorials/TechTips/tabid/63/articleType/ArticleView/articleId/138/iRules-101--08--Classes.aspx Click Here
- Kent_Perrier_50NimbostratusThanks! This information, the v10proxypass iRule, and some searching of devcentral has moved me forward!
when HTTP_REQUEST { set static::debug "1" set the data group name set clname "AppVersion[virtual name]" log local0. "clname is $clname" set the default pool set default_pool "pool999" log local0. "default_pool set to $default_pool" if there isn't a data group with the above name, set the pool to default and exit if {! [class exists $clname]} { if { $static::debug } { log local0. "Data group $clame not found, using default_pool $default_pool" } pool $default_pool return } iterate over the members of the data group, looking for a context root that matches the start of the URI set searchID [class startsearch $clname] log local0. "search ID is $searchID" while { [class anymore $clname $searchID] } { log local0. "inside the while loop" set list [class nextelement $clname $searchID ] log local0. "list is $list" set foo [split $list] set length [llength $foo] log local0. "foo is $foo" log local0. "length is $length" for {set x 0} {$x<= $length} {incr x} { set value [lindex $foo $x] log local0. "position $x of foo is $value" } set cxt_root [lindex $foo 0] set app_pool [lindex $foo 2] foreach { cxt_root junk app_pool } $foo { log local0. "inside the foreach loop" log local0. "values are cxt_root $cxt_root ; app_pool $app_pool" log local0. "URI is [HTTP::uri]" if the URI starts with the context root from the data class, set the pool if { [HTTP::uri] starts_with $cxt_root} { if { $static::debug } { log local0. "data group values: $cxt_root $app_pool" log local0. "setting pool to $app_pool" } pool $app_pool return } } } we don't match the context roots in the data class pool $default_pool }
- Kent_Perrier_50NimbostratusWell, I have found part of my problem. ;) When I created the data group I used quotes around the values. Once I removed those, the stopped appearing in the syslog debug info. The if statement is still not matching, so I have to figure that out.
- Kent_Perrier_50NimbostratusI finally got this working. It turns out one of the things I was beating my head against was the data group itself. I had created it with the data group editor inside of the iRule Editor. Looking at it from the web gui, it looked ok, but something was not right as I could not access the data the way I thought I should. After I deleted the existing entries from the gui and reentered them, every thing worked.
when HTTP_REQUEST { set static::debug "0" set the data group name set clname "AppVersion[virtual name]" set the default pool set default_pool "defpool01" if there isn't a data group with the above name, set the pool to default and exit if {! [class exists $clname]} { if { $static::debug } { log local0. "Data group $clame not found, using default_pool $default_pool" } pool $default_pool return } iterate over the members of the data group, looking for a context root that matches the start of the URI set searchID [class startsearch $clname] while { [class anymore $clname $searchID] } { set list [class nextelement $clname $searchID ] set foo [split $list] set cxt_root [lindex $foo 0] set app_pool [lindex $foo 1] if the URI starts with the context root from the data class, set the pool if { [HTTP::uri] starts_with "$cxt_root"} { if { $static::debug } { log local0. "data group values: $cxt_root $app_pool" log local0. "setting pool to $app_pool" } pool $app_pool return } } 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 }
- hoolioCirrostratusHi 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 } }
- Kent_Perrier_50NimbostratusThanks!
- Brian_ThompsonNimbostratusI will post a thread in the main but there are ZERO examples of using an external datagroup in the "address" format, there are lots of examples of the string format (key/value pair) but none that I can find of a 10.x compliant address format, and unfortunately I'm stuck with this error:
- JRahmAdminI've tried every incantation I can think of and I get the same result. Let me do some digging and I'll get back to you.
- JRahmAdminhoolio suggested I RTFM...sigh.
host 192.168.1.1, host 192.168.1.2 := "host2", network 192.168.2.0 mask 255.255.255.0, network 192.168.3.0 mask 255.255.255.0 := "network2", network 192.168.4.0/24 := "network3",
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