Forum Discussion

Bryan_38320's avatar
Bryan_38320
Icon for Nimbostratus rankNimbostratus
Jun 11, 2010

access irule name from inside the irule

I have the need to use the name of an irule in the rule itself.

 

 

For example:

 

 

if { irule_name contains "bob" }

 

log local0. " bob's rule"

 

}

 

 

(I realize there is probably a better way to do the above, just trying to illustrate an example of what I'm trying to do)

 

  • spark_86682's avatar
    spark_86682
    Historic F5 Account
    There's no way to do this currently, unfortunately. You'll have to do something like have a RULE_INIT for each iRule to set the name in a global/static variable. However, we are considering adding this feature in an upcoming release. If you could elaborate on your use-case, that would be a great help to us.
  • hoolio's avatar
    hoolio
    Icon for Cirrostratus rankCirrostratus
    Just to add to Spark's suggestion: you'd want to use a uniquely named global variable set in RULE_INIT as all variables declared in this event are global.

     

     

    Aaron
  • I have a customer that has a number of URL's that all essentially serve the same site but with different content based on the url. They have asked to have 4 virtual servers and a unique pool for each site. I would have preferred to do the pool selection in a single irule, but they require a unique irule per site.

     

     

    My idea was to include the site name as part of the irule name and use that to make the pool selection, just copying the irule N number of times changing the name instead of coding the site name into 40 different irules.

     

     

    Thanks very much for the input.

     

  • hoolio's avatar
    hoolio
    Icon for Cirrostratus rankCirrostratus
    If you could use the virtual server name instead of the iRule name to determine the site, you could get this with [virtual name].

     

     

    http://devcentral.f5.com/wiki/default.aspx/iRules/virtual

     

     

    Aaron
  • Unfortunately, I can't use the virtual server name. There will be 4 virtual servers and lets say 40 pools. The appropriate pool will be selected based on an irule looking at the url requested by the client. Because of some other requirements, each site will have a unique rule, which is why I was hoping to use the rule name in the rule itself.