Forum Discussion
Ken_McEwen_5009
Nimbostratus
Jan 18, 2006Translating 4.5 i-rules to Ver 9
Help,
I have a some units on 4.5 that load balance by rules. I have to issues when I translate this to version 9.2
The first is as follows: -
elseif { [HTTP::payload length] < 20 } {
log "accumulating..."
Accumulate
}
the problem is that during programing this is accepted but when running the unit throws up an error saying does not reconise command accumulate. Does any one have any idea what this should be with the new syntax.
The second is to do with the regular expression syntax. The old syntax translates as follows (in theroy).
else {
if { [HTTP::header "X-WSB-msisdn"] matches_regex "[01234]$" } {
use pool mmsny1_pool
log "mms: 01234: NY"
}
elseif { [HTTP::header "X-WSB-msisdn"] matches_regex "[56789]$" } {
use pool mmsbe1_pool
log "mms: 56789: BE1"
}
else {
use pool mmsbe1_pool
log "mms: missed msisdn"
}
}
Problem is with the regular expression in the square brackets as per 4.5 the UIE rejects the script as it thinks this is a function. Removal of the square brackets prevents the script from compareing the regular expression. Any ideas on what replaces the square brackets.
- For the accumulate question, you'll need to use the HTTP::collect method (if you are in an HTTP event which it looks like you are. For a HTTP request, here's is something that you could use to collect the payload:
when HTTP_REQUEST { if { [HTTP::header exists "Content-Length"] } { set content_length [HTTP::header "Content-Length"] } else { set content_length 4294967295 } if { $content_length > 0 } { HTTP::collect $content_length } } when HTTP_REQUEST_DATA { HTTP::payload will now contain the content }
else { if { [HTTP::header "X-WSB-msisdn"] matches_regex {[01234]$} } { use pool mmsny1_pool log "mms: 01234: NY" } elseif { [HTTP::header "X-WSB-msisdn"] matches_regex {[56789]$} } { use pool mmsbe1_pool log "mms: 56789: BE1" } else { use pool mmsbe1_pool log "mms: missed msisdn" } }
else { if { [regexp {[01234]$} [HTTP::header "X-WSB-msisdn"]] } { use pool mmsny1_pool log "mms: 01234: NY" } elseif { [regexp {[56789]$} [HTTP::header "X-WSB-msisdn"] ] } { use pool mmsbe1_pool log "mms: 56789: BE1" } else { use pool mmsbe1_pool log "mms: missed msisdn" } }
else { extract last character in header set last [string last [HTTP::header "X-WSB-msisdn" end] if { ($last >= 0) && ($last <= 4) } { use pool mmsny1_pool log "mms: 01234: NY" } elseif { ($last >= 5) && ($last <= 9) } { use pool mmsbe1_pool log "mms: 56789: BE1" } else { use pool mmsbe1_pool log "mms: missed msisdn" } }
else { extract last character in header set last [string last [HTTP::header "X-WSB-msisdn" end] switch $last { 0 - 1 - 2 - 3 - 4 { use pool mmsny1_pool log "mms: 01234: NY" } 5 - 6 - 7 - 8 - 9 { use pool mmsbe1_pool log "mms: 56789: BE1" } default { use pool mmsbe1_pool log "mms: missed msisdn" } } }
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