Forum Discussion
geffryti_32102
Nimbostratus
Mar 17, 2010how to use data group
Requirements:
1. system for redirecting certain host+uri to a different server (no pools)
2. use data group file to maintain uri-to-server list, so I can keep using the same irule for other VS.
Questions:
1. how do I call a data group from an irule? (assuming I already created the class in GUI and the name is redlist) will $::redlist work? My redlist is a string type with three fields, and below is an example. (some only has two fields).
2. I want to be able to use the second field as the new HOST and the third field as the new URI, but I'm having problem with inserting them. Pls see my draft below and let me know what's wrong and if there's a better way of doing this. Thanks.
REDLIST
"10.6.254.10/dir3/ 172.16.254.115 "
"10.41.254.121/dir6/ 172.16.254.115 /dir60000/"
"10.8.224.44/dir32/ 172.16.254.115 /dir60000/"
DRAFT SCRIPT
when HTTP_REQUEST {
find a match using host+uri against the class and
returns the whole string (field1 field2 field3)then
set it as newURI variable.
set newURI "[findclass [[HTTP::host][HTTP::uri]] $::redlist]"
if { $newURI ne "" } {
pick 2nd field and set as variable (newhost)
set newhost "[getfield $newURI " " 2]"
pick 3rd field and set as variable (newuri)
set newuri "[getfield $newURI " " 3]"
change host and uri
HTTP::host $newhost
HTTP::uri $newuri
Clear the newURI variable
unset newURI
}
}
14 Replies
Sort By
- L4L7_53191
Nimbostratus
Oops. For got to explain the bracket thing. What specifically was going on was this: - geffryti_32102
Nimbostratus
You rock! - geffryti_32102
Nimbostratus
I want findclass to only print when a match is found against the datagroup, so I added -q option. But this doesn't seem to stop findclass.set newURI "[findclass -q [HTTP::host][HTTP::uri] $::redlist]"
- hoolio
Cirrostratus
Sorry for the typos. Thanks for the updates Matt.
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