Forum Discussion
Yozzer
Nimbostratus
Jun 03, 2011Data Group List use in a switch
Hi
I have a Data Group list called allowed_urls that has a list of accepted urls which i want to use in an irule.
switch -glob [HTTP::uri] {
"*temp.txt" {
do stuff
}
"*users.txt" {
do stuff
How do i use Data Group lists in the example above?
Thanks
21 Replies
- Yozzer
Nimbostratus
if [HTTP::uri] contains allowed_urls
set value "allowed"
}
I just want to know if the syntax is correct for the call to the data group list. Im assuming i only need to define the list in the data list group tab and not in the code.
Thanks - hoolio
Cirrostratus
You can use the class command to look up the URI to see if it's in the datagroup like Colin's example:when HTTP_REQUEST { set action [class match -value [string tolower [HTTP::path]] equals allowed_urls] if {$action ne ""} do stuff } }
Aaron - Yozzer
Nimbostratus
Hi Aaron
Colins example doesnt compile:
line 3: [undefined procedure: class] [class match -value [string tolower [HTTP::path]] equals blocked_list]
line 4: [missing a script after "if"] []
line 7: [command is not valid in the current scope] [}]
I don't want to define the list in the code but in the Data Group List tab (in the GUI under Local Traffic >> iRules >> Data Group List). Is this why its not updating?
Looking a again at Colins example, i want the same action to be performed for all strings in the Data Group List so i dont need to define the action until its found that the any of the strings in the list are in the url.
when HTTP_REQUEST {
set action [class match -value [string tolower [HTTP::path]] equals Portal_blocker_list]
if {$action ne ""}
do stuff
else set value "found"
}
} - hoolio
Cirrostratus
The datagroup is always defined outside the iRule. You cannot define a datagroup within an iRule.
Which LTM version are you running? The class command was added in 10.0.0. If you're on v9.4.4, you can use this instead:when HTTP_REQUEST { if {[matchclass [string tolower [HTTP::path]] equals allowed_urls]} do stuff } }
For pre-9.4.4 add a $:: prefix to the datagroup name reference in the iRule.
Aaron - Yozzer
Nimbostratus
using 9.4.8
when HTTP_REQUEST {
if {[matchclass [string tolower [HTTP::path]] equals blocker_list]}
do stuff
}
gives:
line 3: [missing a script after "if"] []
whats missing?
Thanks - nitass
Employee
can u try this?
when HTTP_REQUEST {
if {[matchclass [string tolower [HTTP::path]] equals $::blocker_list]} {
do stuff
}
matchclass wiki
http://devcentral.f5.com/wiki/default.aspx/iRules/matchclass.html - Yozzer
Nimbostratus
Thanks nitass
That updates if i add another } at the end. - nitass
Employee
oh yes, i missed the last }. - Yozzer
Nimbostratus
That all works fine apart from the contents of the lists.
I noticed that if 72D0C6D25 is in the list that it doesn't recognize it in the uri for the irule to pick it up. Which is strange as numbers and letters are ok if they are separately defined in a list but together it doesn't recognize them. Which list type should alphanumeric be included in and what is the size limit of the individual list types? Can they have special characters also?
Thanks - Yozzer
Nimbostratus
i think its the upper case letters it doesnt like as abc12-d34ef-ghj-kjn-fds is fine. Does anyone know what the number of values can be in a data group list?
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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
