atatps_250754
Mar 16, 2017Altocumulus
iRule breaking iApp Template?
Gents,
Armed with this how-to article on DevCentral, I built an iApp template to automate app creation. However, the template only deploys properly when the iRule section is omitted otherwise it will throw this error:
01070151:3: Rule [/Common/IAPPTEST-irule.app/IAPPTEST-Homepage-http] error: /Common/IAPPTEST-irule.app/IAPPTEST-Homepage-http:2: error: [parse error: PARSE syntax 25 {syntax error in expression " \[string tolower \[HTTP::path\]\] starts_with \"/homepage/\...": character not legal in expressions}][{ \[string tolower \[HTTP::path\]\] starts_with \"/homepage/\" }]
This is the iRule portion that's breaking the template:
tmsh::create {
ltm rule IAPPTEST-Homepage-http
when HTTP_REQUEST {
if { \[string tolower \[HTTP::path\]\] starts_with \"/homepage/\" } {
pool IAPPTEST-ebiz-http member 10.1.10.101
} else {
pool IAPPTEST-ebiz-http
}
}
}
tmsh::create {
ltm rule IAPPTEST-Homepage-https
when HTTP_REQUEST {
if { \[string tolower \[HTTP::path\]\] starts_with \"/homepage/\" } {
pool IAPPTEST-ebiz-https member 10.1.10.101
} else {
pool IAPPTEST-ebiz-https
}
}
}
Anything wrong with the syntax? I'm happy to provide the whole template code if that's helpful. Device info: LTM, 12.1.2
Was able to get help from Support. The solution, contrary to the article, was to remove the backslashes so it should be:
tmsh::create { ltm rule IAPPTEST-Homepage-http when HTTP_REQUEST { if { [string tolower [HTTP::path]] starts_with "/homepage"}{ pool IAPPTEST-ebiz-http member 10.1.10.101 } else { pool IAPPTEST-ebiz-http } } }
As opposed to:
tmsh::create { ltm rule IAPPTEST-Homepage-http when HTTP_REQUEST { if { \[string tolower \[HTTP::path\]\] starts_with \"/homepage/\" } { pool IAPPTEST-ebiz-http member 10.1.10.101 } else { pool IAPPTEST-ebiz-http } } }