Forum Discussion

Vasile_Balan_95's avatar
Vasile_Balan_95
Icon for Nimbostratus rankNimbostratus
Oct 11, 2006

node selection string from v 4.x to v 9.x

Hi,

 

 

I need help with converting the node selection string

 

 

node(findstr(http_uri, "?ip=", 4, '/') + ":80")

 

 

from the persistence tab on v 4.x to v 9.x. i know there is no selection in v 9.x, so i guees an iRule should be written. i have a problem with the last statement that would use the node provided in ?ip=.

 

 

Thanks,

 

 

Vasile
  • Deb_Allen_18's avatar
    Deb_Allen_18
    Historic F5 Account
    Hi Vasile -

    Something like this should work in 9.2 (replacing POOL with the name of the default pool):
    when HTTP_REQUEST {
       set myNode [findstr [string tolower [HTTP::uri]] "?ip=" 4 "/"]
       if { ($myNodeIP ne "") and ([LB::status pool POOL member $myNodeIP 80] ne "down") } {
          pool POOL $myNodeIP 80
       }
    }

    For the condition using LB::status, you will need to be running at least 9.2. In older 9.x versions, you can instead add an LB_FAILED event to catch that condition and load balance in the default pool instead:
    when HTTP_REQUEST {
       set myNode [findstr [string tolower [HTTP::uri]] "?ip=" 4 "/"]
       if { $myNodeIP ne "" } {
          pool POOL $myNodeIP 80
       }
    }
    when LB_FAILED {
       LB::reselect
    }

    HTH

    /deb

  • Hi deb,

     

     

    i have 9.1.2 installed. i've tried to use the following:

     

     

    when HTTP_REQUEST {

     

    set myNode [findstr [string tolower [HTTP::uri]] "?ip=" 4 "/"]

     

    if { $myNodeIP ne "" } {

     

    pool POOL $myNodeIP 80

     

    }

     

     

    but it doesn't work.

     

     

    thanks,

     

     

    vasile
  • hoolio's avatar
    hoolio
    Icon for Cirrostratus rankCirrostratus

    Hello Vasile,

    It would be helpful to get more detail on what wasn't working and what errors you saw. You could provide any relevant errors from /var/log/ltm using the current rule, or add log statements to the rule to get additional debug information.

    I believe there are a couple of minor typos in the rule which may have prevented it from working as expected. There was a missing close parenthesis and myNodeIP was originally set as myNode. Try this and see what the results are:

    
    when HTTP_REQUEST {
       log local0. "starting..."
       set myNodeIP [findstr [string tolower [HTTP::uri]] "?ip=" 4 "/"]
       if { $myNodeIP ne "" } {
          log local0. "myNodeIP: $myNodeIP"
          pool http_pool $myNodeIP 80
       }
       else {
          log local0. "myNodeIP was empty: (myNodeIP: $myNodeIP)"
       }
    }
    when LB_FAILED {
       log local0. "LB failed!"
       LB::reselect
    }

    Aaron