Forum Discussion

alyubarov_3971's avatar
alyubarov_3971
Icon for Nimbostratus rankNimbostratus
May 19, 2014

can an irule call another irule

Hello, I have a setup where I'm required to maintain two almost identical irules for two separate VSs. I'm trying to find a way to write a simple wrapper irule that would add few conditions and exec the main irule if the conditions are true. Is it possible? Thanks in advance.

 

Alex

 

4 Replies

    • alyubarov_3971's avatar
      alyubarov_3971
      Icon for Nimbostratus rankNimbostratus
      Thanks, John. This sounds like procs could help, but is it available in v10.x? Sorry, I should have been more specific in my question - we are at 10.2.4? Switch to 11 probably won't happen until the next year with the h/w upgrade.
  • If I may add, procs would definitely be the way to go here. I might have also said that a sideband call might work, but that too requires v11. There still may be a way though, depending on how the main rule interacts with the VIPs, and at what (if any) event level it needs to fire. So lets say for example you have a main rule that gets triggered at HTTP_REQUEST, and your two almost identical iRules, which probably also trigger code at HTTP_REQUEST. You could add the main rule to each VIP and use a few conditions inside that iRule to determine when and what to run. For example:

     

    VIP iRule:

     

    when HTTP_REQUEST {
        ...doing something important here
    }  

    Main iRule:

     

    when HTTP_REQUEST priority 501 {
        switch [virtual] {
            "app1-vs" {
                 do something for app1
            }
            "app2-vs" {
                 do something for app2
            }
        }
    }

    In this way, you have a single main iRule that 1) gets triggered after your VIP-specific iRule, and 2) evaluates code based on the caller VIP.