Forum Discussion

geffryti_32102's avatar
geffryti_32102
Icon for Nimbostratus rankNimbostratus
Mar 17, 2010

how 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

 

}

 

}