Jason_Hook_4092
Dec 03, 2009Nimbostratus
Looking for peer review on a "simple" iRule
We have a need to direct traffic to different pools based on a header value.
We have a string data group called SysPools with the following entries (here's a couple for example):
001 TTSHE-SysG
013 TTSHE-SysO
015 TTSHE-SysO
030 TTSHE-SysB
This is the iRule on the VIP:
when HTTP_REQUEST {
Set the default target pool
set defaultTarget "TTSHE-SysD"
if {[HTTP::header exists "BETAFirm"]} {
Set $firm to the value of the header
set firm [HTTP::header "BETAFirm"]
log local0.info "Set Firm to $firm"
Set $target to the pool name from the lookup table
set target [findclass $firm $::SysPools " "]
log local0.info "Set Target to $target"
check for a mismatch resulting in a blank pool name and set to default if blank
if { $target eq "" }{
log local0.info "Setting Target to default $defaultTarget"
set target $::defaultTarget
}
Forward request to the set pool
log local0.info "Forwarding request to pool $target"
pool $target
} else {
No Header found...send to default pool
log local0.info "No Header...Forwarding to default pool $defaultTarget"
pool $defaultTarget
}
}
Comments? I'm looking for a few comments to find out if this is the "best" way to accomplish what I'm trying to do. Is this efficient? Is there a different/better way?
Any/all comments are welcome.
Thank you!
Jason