Forum Discussion

atatps_250754's avatar
atatps_250754
Icon for Altocumulus rankAltocumulus
Mar 16, 2017
Solved

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
         }
        }
        }
    

     

4 Replies

  • Here's the full template if that helps:

     

    tmsh::create {
    ltm node 10.1.10.101
        address 10.1.10.101
    }
    tmsh::create {
    ltm node 10.1.10.102
        address 10.1.10.102
    }
    tmsh::create {
    ltm node 10.1.10.103
        address 10.1.10.103
    }
    tmsh::create {
    ltm node 10.1.10.104
        address 10.1.10.104
    }
    tmsh::create {
    ltm node 10.1.10.105
        address 10.1.10.105
    }
    tmsh::create {
    ltm node 10.1.10.106
        address 10.1.10.106
    }
    
    
    tmsh::create {
    ltm pool IAPPTEST-app
        members replace-all-with {
            10.1.10.104:9001 {
                address 10.1.10.104
            }
            10.1.10.105:9001 {
                address 10.1.10.105
            }
        }
        monitor tcp 
    }
    
    tmsh::create {
    ltm pool IAPPTEST-boe
        members replace-all-with {
            10.1.10.106:8080 {
                address 10.1.10.106
            }
        }
    }
    
    tmsh::create {
    ltm pool IAPPTEST-ebiz-http
        members replace-all-with {
            10.1.10.101:80 {
                address 10.1.10.101
            }
            10.1.10.102:80 {
                address 10.1.10.102
            }
            10.1.10.103:80 {
                address 10.1.10.103
            }
        }
        monitor http 
    }
    
    tmsh::create {
    ltm pool IAPPTEST-ebiz-https
        members replace-all-with {
            10.1.10.101:443 {
                address 10.1.10.101
            }
            10.1.10.102:443 {
                address 10.1.10.102
            }
            10.1.10.103:443 {
                address 10.1.10.103
            }
        }
        monitor https 
    }
    
    
    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
     }
    }
    }
    
    
    tmsh::create {
    ltm virtual IAPPTEST-app
        destination 10.100.100.100:9001
        ip-protocol tcp
        mask 255.255.255.255
        pool IAPPTEST-app
        profiles replace-all-with {
            fastL4 { }
        }
        source 0.0.0.0/0
        source-address-translation {
            type automap
        }
        translate-address enabled
        translate-port enabled
    }
    
    tmsh::create {  
    ltm virtual IAPPTEST-boe
        destination 10.100.100.100:8080
        ip-protocol tcp
        mask 255.255.255.255
        pool IAPPTEST-boe
        profiles replace-all-with {
            fastL4 { }
        }
        source 0.0.0.0/0
        source-address-translation {
            type automap
        }
        translate-address enabled
        translate-port enabled
    }
    
    tmsh::create {  
    ltm virtual IAPPTEST-ebiz-http
        destination 10.100.100.100:80
        ip-protocol tcp
        mask 255.255.255.255
        pool IAPPTEST-ebiz-http
        profiles replace-all-with {
            http-with-xforward { }
            tcp { }
        }
        rules {
            IAPPTEST-Homepage-http
        }
        source 0.0.0.0/0
        source-address-translation {
            type automap
        }
        translate-address enabled
        translate-port enabled
    }
    
    tmsh::create {  
    ltm virtual IAPPTEST-ebiz-https
        destination 10.100.100.100:443
        ip-protocol tcp
        mask 255.255.255.255
        pool IAPPTEST-ebiz-https
        profiles replace-all-with {
            http-with-xforward { }
            tcp-lan-optimized {
                context serverside
            }
            tcp-mobile-optimized {
                context clientside
            }
        }
        rules {
            IAPPTEST-Homepage-https
        }
        source 0.0.0.0/0
        source-address-translation {
            type automap
        }
        translate-address enabled
        translate-port enabled
    }
    

     

  • if you wrap your iRule config like this:

     

    tmsh::create "irule config" 

    does that help?

     

  • Hi Jason - When replacing the {} with "" I receive this error:

    Original syntax:

     

        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
         }
        }
        }
    

     

    Suggested change:

     

        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
         }
        }
        "
    

     

    Any other suggestions?

  • 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
         }
        }
        }