Forum Discussion
Chris_Phillips
Nimbostratus
Aug 03, 2006iRule as stored function or similar
Hi,
I have an iRule with a dozen lines or so and amd really hoping that there is some way to use this one single iRule as a stored function for instances of it. I mean, i will be using seper...
Deb_Allen_18
Aug 03, 2006Historic F5 Account
To re-use the same rule with different variable values for different virtuals without creating multiple instances, I've used this approach with good results:
First set up a class. Each row will begin with the configured name of each virtual server to which the rule will be applied, and will also contain the value of the variables required by each:
class cl_VSVars {
vs_VirtualServer1 valueA valueB valueC
vs_VirtualServer2 valueA valueB valueC
vs_VirtualServer3 valueA valueB valueC
}
Then you can include this code in your rule to extract the variable values based on the virtual upon which the traffic is processed (use in any event but RULE_INIT):set myVSVars [findclass [virtual name] cl_VSVars]
set myVar1 [getfield $myVSVars " " 1]
set myVar2 [getfield $myVSVars " " 2]
set myVar3 [getfield $myVSVars " " 3]
If you want to store the class name in a variable, you can do so like this:when RULE_INIT {
set ::variableClass ::VSVars
}
when CLIENT_ACCEPTED {
set myVSVars [findclass [virtual name] [set $::variableClass]]
...
}
HTH
/deb
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects