Forum Discussion

trx's avatar
Jun 16, 2011

Are there functions or methods we can create using IRules?

Hello Community,

I have multiple IRules associated to a VS and was wondering if there can be IRules or methods/functions that we can create and call them ONLY when we want? Or does all the IRules MUST be executed in a top down fashion?

 

 

 

Example of IRule order used by a VS:

 

IRule 1

 

IRule 2

 

IRule 3

 

IRule 4

 

 

 

 

 

Is there way to call IRule 3 and skip IRule 2 from IRule 1?

 

Or just call a method/function from IRule 4 from IRule 1 then end the session?

 

 

 

Regards,

 

TRX

 

  • Hi TRX,

     

     

    You can disable events using 'event < name > disable' but that affects all iRules on the virtual server which reference that event. I think the best solution is to use one or more local variables to track which code you want to run. A local variable is accessible across all iRules on the same virtual server on a per connection basis. So you can use something like:

     

     

    rule1 - set run_rule3 1

     

    rule2 - set run_rule3 0

     

    rule3 - if {$run_rule3 == 1}{ do something}

     

     

    Aaron