Forum Discussion

Jeff_41411's avatar
Jeff_41411
Icon for Altocumulus rankAltocumulus
Aug 24, 2010

Determine pools defined for WideIP

Hi,

 

 

Is there a way with an iRule (attached to a WideIP) to determine:

 

 

1) the list of pools defined (all pools, regardless of state) for that WideIP, in the same order they are defined (for global availability) - or if the order number is another property that's fine.

 

 

2) in order to to determine 1, I think I may also need to know which WideIP it is

 

 

I'd like to write this rule in a way that it can be used across a number of WideIP's, without hard coding an iRule for each one. It seems these things would be some sort of global variable or something like that - but I'm not finding what I need in my searches.

 

 

Thanks in advance for any help!

 

 

Jeff

 

  • I'm not sure order is possible, but you can return the pools belonging to a wideIP:

     

     

    when DNS_REQUEST {

     

    log local0. "WideIP: [wideip name], Configured Pools: [pools -list]"

     

    }

     

     

    With the GTM pools command, you can also return the pools with a particular status (blue, green, etc)

     

     

    http://devcentral.f5.com/wiki/default.aspx/iRules/pools.html Click Here
  • Colin_Walker_12's avatar
    Colin_Walker_12
    Historic F5 Account
    If you REALLY need order, I'm positive you could hack together some custom logic to order them somehow, it's just a matter of whether or not it's worth your time/effort and the cycles it will take in the iRule to execute all the custom logic each time the iRule is executed.

     

     

    Colin
  • Thanks for the response! I had found the 'wideip name' variable.

     

     

    I thought the pools -list returned 'all' pools, I'll try it in this context and see if it just returns those pools in the WideIP the rule is attached to.

     

     

    I was looking at "GlobalLB::WideIP::WideIPPool" as a possible solution - but I'm not clear on the syntax to use.

     

     

    Thanks,

     

    Jeff
  • Test to be sure, but the description in the wiki indicates it will return only the pools attached to the wideip.

     

     

    The GlobalLB::WideIP::WideIPPool method is for iControl, not iRules, and will have to be called externally from a dns request.
  • Thanks to everyone for the help - I did get this working with the following (rather simple) code:

     

     

    when DNS_REQUEST {

     

    set wip [wideip name]

     

    set pl [pools -list]

     

    set counter 1

     

     

    foreach p $pl {

     

    set pname($counter) $p

     

    incr counter

     

    }

     

     

    log local0. "WIP: $wip, pool1: $pname(1), pool2: $pname(2), client: [IP::client_addr]"

     

     

    If the Client IP (DNS server) is from the DR subnet, send

     

    the request to the DR pool (2)

     

     

    if { [IP::addr [IP::client_addr]/16 equals "xx.xx.xx.xx"] }

     

    {

     

    pool $pname(2)

     

    } else {

     

    pool $pname(1)

     

    }

     

    }

     

     

    One thing to note about the 'pools -list' command, if there is a 'Last Resort Pool' defined in the WideIP - and the pools are not in a 'green' state - only the Last Resort Pool is returned by the command. Seems a little strange . . .

     

     

    Thanks again,

     

    Jeff
  •  

    Why do you think the later is strange? When would you want the 'pools -list' command to return an unavailable/disabled pool?
  • According to the documentation:

     

     

    pools -list

     

    * Returns a list of pools in the wideIP.

     

    pools [blue|green|yellow|red|gray]

     

    * Returns the number of pools in the wideIP in the specified state.

     

    pools -list [blue|green|yellow|red|gray]

     

    * Returns a list of pools in the wideIP in the specified state.

     

     

    It looks like -list flag should list all pools regardless of state, since I can then qualify it to only see pools of a specific state if I want to.

     

     

    I was also pointing out that the results of the command are different if I have a 'Last Resort Pool' defined in the WideIP - from when I don't. I still think it's a bit strange ;-)

     

     

    Also - there are times (in our environment anyway) where I need to get DNS (WideIP's) setup before the hosts are actually available. In this case - they are DR servers that I need to setup DNS for, but the servers aren't yet available for monitoring to succeed. And I don't always rely on the GTM to determine health - I want it to give out the correct IP's. We have other devices (load balancing) that can route based on health status.

     

     

    So . . . I am looking for the command to return all pools in this case - regardless of state . . .

     

     

    Jeff