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 16, 2011Nimbostratus
Thanks! This information, the v10proxypass iRule, and some searching of devcentral has moved me forward!
I am having a problem that I am hoping I can get another hand with. I have figured out how to access the data group and iterate across it. (Which may or may not be the best way of trying to match a value inside the data group.) Unfortunately the values I get back from the the date group have quotes around them, like this "/foo". I am guessing this is why my code that sets the pool name based on the start of the URI is failing. How do I remove the quotes?
Here is my data group:
/foo := pool1
/bar := pool2
And here is my code:
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
}
I have left some of the code I have started with, but I think you can see where I am going with this. From the commented out for loop, I know that element 0 of the list foo is the URI and element 2 is the pool name, but the quotes around the entries is messing up my if block as /foo/stuff does not start with "/foo"
Any pointers?
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