Forum Discussion
findclass to class iRule help request
We had a v9.x iRule that called an internal datagroup (xxx_direct) via findclass and logged connections. I'm mostly concerned about proper use of class command to call datagroup. We are upgrading to v11.6; any suggestions for iRule improvement are greatly appreciated.
when HTTP_REQUEST {
set url [HTTP::header Host][HTTP::uri]
set host_org [ substr [HTTP::header Host] 0 "." ]
set host_org [ string tolower $host_org ]
set host [ substr $host_org 0 "_" ]
set org [ substr $host_org 7 "-" ]
set host_header_value $org.bla.blah.edu
HTTP::header replace Host $host_header_value
set direct [ findclass $host $::xxx_direct " " ]
pool xxx member $direct:80
}
when HTTP_RESPONSE {
set client [IP::client_addr]
set server [IP::server_addr]
log local0. "xxx_direct: url:$url client:$client server:$server
host_header:$host_header_value"
3 Replies
- Kevin_Davies_40
Nacreous
In v9 there were string data groups but no key value pair as there is in v10. Take the $::xxx_direct data group, create it with the same name xxx_direct but seperate each string on the first space into key and value pairs. Before the space is the key. The rest after the space is the value. Then your comand will be
set direct [class match -value $host equals xxx_direct]Another command you could update would be the two for setting host_org and collapse them into this.
set host_org [string tolower [getfield [HTTP::header "Host"] "." 1]]- Thanks! We will start testing in the newer code soon. Why does original set host_org change from 0 "." to "." 1 in your example?
- Kevin_Davies_40
Nacreous
findclass starts at 0, getfield starts at 1
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* 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