Forum Discussion

Michael_Koyfma1's avatar
Dec 12, 2007

Getting default pool associated with Virtual

There is a way to retrieve the default pool name that is associated with the VS using iRules. Below is an example of how this is done:

 

 

when CLIENT_ACCEPTED {

 

set default_pool [LB::server pool]

 

log local0. "default pool is $default_pool"

 

}

 

 

For the longest time, I was under misconception that LB::server pool would not be available until LB_SELECTED or LB_FAILED event, but apparently this is not the case - this iRule works, and can be used as a core generic rule that's applicable to several virtuals - nice little trick.

1 Reply

  • Unruley suggested this a few times starting a while back:

     

     

    http://devcentral.f5.com/Default.aspx?tabid=53&view=topic&forumid=5&postid=2066

     

     

    You can try the following modifications to your rule to save the default pool and reuse it, thus generalizing your rule to be used with many virtuals.

     

     

    rule cookie_lbsid {

     

    when CLIENT_ACCEPTED {

     

    set defpool [LB::server pool]

     

    }

     

    ...

     

     

     

     

    http://devcentral.f5.com/Default.aspx?tabid=53&view=topic&forumid=5&postid=7275

     

     

    1) 9.1 does support the [LB::server pool] command which will return the currently selected pool. You do not have to wait until LB_SELECTED to get the currently selected pool. Thus something like this will return the original default pool on the virtual server:

     

     

    when CLIENT_ACCEPTED {

     

    if {not [info exists default_pool]} {

     

    set default_pool [LB::server pool]

     

    }

     

    }

     

     

     

     

    I think a lot of people have been using it since then to get the default pool of the VIP before any changes to the pool have been made on the connection.

     

     

    Aaron