Forum Discussion

Mike_Blue_30573's avatar
Mike_Blue_30573
Icon for Nimbostratus rankNimbostratus
Feb 04, 2005

IRule V4.x to 9.x conversion problem

I have tried over and over to convert this rule to V9. I get an

 

error saying that "Wrong of args". I am no irules expert obviusly.

 

I have been trying to walk through the TCL and Irule supplement pdf

 

but I am still messing something up.

 

 

Any help would be greatly appreciated.

 

 

if (domain(http_host, 3) == "stage.test.com") {

 

use pool test_http

 

}

 

else {

 

if (domain(http_host, 3) == "stage1.test.com") {

 

use pool test_svra

 

}

 

else {

 

if (domain(http_host, 3) == "stage2.test.com") {

 

use pool test_svrb

 

}

 

else {

 

discard

 

}

 

}

 

}

 

 

 

Thanks

 

Freakingenius "ok maybe not with irules".
  • Mark_Crosland_1's avatar
    Mark_Crosland_1
    Historic F5 Account
    Try the following (I assume http_host was a variable assigned elsewhere?).

         if { [domain $http_host 3] == "stage.test.com" } { 
             use pool test_http 
         } else { 
             if { [domain $http_host 3] == "stage1.test.com" } { 
                 use pool test_svra 
             } else { 
                 if { [domain $http_host 3] == "stage2.test.com" } { 
                     use pool test_svrb 
                 } else { 
                     discard 
                 } 
             } 
         } 
     
  • rapmaster_c_127's avatar
    rapmaster_c_127
    Historic F5 Account
    Posted By gus on 2/4/2005 10:09:10 AM

    Try the following (I assume http_host was a variable assigned elsewhere?).

         if { [domain $http_host 3] == "stage.test.com" } {  
              use pool test_http  
          } else {  
              if { [domain $http_host 3] == "stage1.test.com" } {  
                  use pool test_svra  
              } else {  
                  if { [domain $http_host 3] == "stage2.test.com" } {  
                      use pool test_svrb  
                  } else {  
                      discard  
                  }  
              }  
          }  
      

    (Or if http_host was not a variable assigned somewhere, use
    [HTTP::host]
    instead.)
  • unRuleY_95363's avatar
    unRuleY_95363
    Historic F5 Account
    Cleaned up a little it would look like this:

     
     when HTTP_REQUEST { 
        if { [domain [HTTP::host] 3] eq "stage.test.com" } { 
           pool test_http 
        } elseif { [domain [HTTP::host] 3] eq "stage1.test.com" } { 
           pool test_svra 
        } elseif { [domain [HTTP::host] 3] eq "stage2.test.com" } { 
           pool test_svrb 
        } else { 
           discard 
        } 
     } 
     

    Or using a Tcl switch statement you could do:

     
     when HTTP_REQUEST { 
        switch [domain [HTTP::host] 3] { 
           stage.test.com { pool test_http } 
           stage1.test.com { pool test_svra } 
           stage2.test.com { pool test_svrb } 
           default { discard } 
        } 
     } 
     
  • Thanks for the Feedback you guys. That TCL switch rocks.

     

    Is there any other resources available for TCL command

     

    structures?

     

     

     

    Thanks

     

  • You can always refer to the Tcl Reference Manual

     

     

    http://tmml.sourceforge.net/doc/tcl/

     

     

    Keep in mind that we do not support the full feature set of the language such as the I/O routines but you should be fairly safe in using any of the control, string and list features.

     

     

    Also, we've added our own extensions to help with certain common operations (findstr, substr, getfield, etc). You can check these out in the BIG-IP product documentation or in the Docs and Tips section of DevCentral.

     

     

    -Joe