Forum Discussion

Lerna_Ekmekciog's avatar
Lerna_Ekmekciog
Icon for Nimbostratus rankNimbostratus
Aug 11, 2005

which iRules reference this pool

Hello,

 

 

I'm using iControl sdk 9.0. I'm working on a Java program that pushes a given config of a load balancer obtained from a database to the local box.

 

 

Is there a programatically easy way to check which iRules a pool is referenced by? I can see query_rule method but this requires a parse of the rule_definition.

 

 

RuleDefinition[] query_rule(

 

in String[] rule_names

 

);

 

 

where RuleDefinition is a struct with following fields

 

 

rule_name String The rule name.

 

rule_definition String The rule text/definition.

 

 

 

 

 

 

3 Replies

  • I think you meant to check which iRules a virtual server is reference by. Pools and Rules are both resources applied to a virtual server.

     

     

    With that being said, there really isn't an easy way to do this search given a rule, to find which virtuals it is associated with. Our API's are defined top-down, meaning that you need to go to a containing object to get information about it's contained members.

     

     

    What you'll have to do is the following:

     

     

    Feed the string array returned from LocalLB::VirtualServer::get_list() into LocalLB::VirtualServer::get_rule().

     

     

    You can then loop through all the rules and when you find a match lookup that associated entry in the virtual list.

     

     

    This is the second question of this sort we've gotten this week - the last one was asking if you could lookup which virtuals a pool belongs to in a single call. The answer there was the same procedure as I described above for rules. I'll create a change request to add this feature in an upcoming release.

     

     

    -Joe
  • Joe,

     

     

    Thanks for the quick reply. However I was asking a different question than the one you answered. Let me explain better what I mean.

     

     

    Given a pool I want to find out which iRules include a reference to this pool in their definition.

     

     

    For ex:

     

    iRule1's definition is the following:

     

    when CLIENT_ACCEPTED {

     

    pool pool1

     

    }

     

     

    and iRule2's definition is as follows:

     

     

    when HTTP_REQUEST {

     

    if {[HTTP::uri] ends_with "foo"} {

     

    pool pool1

     

    }

     

    }

     

     

    Now given a pool such as pool1 I want to find the list of iRules (that is iRule1 and iRule2) that includes that pool in their definition. Is this possible?

     

     

    Lerna
  • No problem. Since rules are just stored as text internally and processed at runtime there are now ways to speed up the lookup aside from searching through the text of a rule and searching for the given pool name.

    What makes things a bit more compilcated is when you are using variables for pool names

    when HTTP_REQUEST {
      set pool_to_use "pool1"
      if { [HTTP::uri] ends_with "foo"} {
        pool $pool_to_use
      }

    Customers are doing this when they want to create a pool of pools and dynamically assign connections to that pool based on some external criteria (incoming ip, portion of uri, etc).

    Since this isn't your case, then doing a string search for the string "pool pool1" should work (as long as you don't add extra spaces in between "pool" and "pool1".

    This looks like a great contribution to CodeShare! If you supply it I'd even be inclined to get it in an upcoming SDK!

    -Joe