Forum Discussion

Kirk_Bauer_1018's avatar
Kirk_Bauer_1018
Icon for Nimbostratus rankNimbostratus
Jan 18, 2007

Enhanced iRules templates suggestion

I was thinking that the templates in the iRules editor could be greatly expanded and be much more useful for customers with large collections of iRules.

 

 

My suggestion is to first store a version number in each iRule template file. Then allow input parameters to be defined. This could be accomplished by adding special comments in the first couple lines like:

 

 

iRule Template "Cookie Rename" Version 1.1

 

Parameter orig_name: the cookie name you want to rename

 

Parameter new_name: the name you want to rename the cookie to

 

when HTTP_REQUEST {

 

if { [HTTP::cookie exists "__orig_name__"] } {

 

set cookie_s [HTTP::cookie "__orig_name__"]

 

HTTP::cookie remove "__orig_name__"

 

set cookie_a [HTTP::header cookie]

 

HTTP::header replace "cookie" "$cookie_a; __new_name__=$cookie_s"

 

}

 

}

 

 

Now, when you create an iRule off of the template, it can ask you for values for each parameter. When the rule is created on the BIG-IP, it could be something like this:

 

 

rule cookie_rewrite_abc {

 

This rule was generated from the template "Cookie Rename" Version 1.1

 

Parameter orig_name="abc"

 

Parameter new_name="def"

 

MANUAL MODIFICATION IS NOT RECOMMENDED!!

 

when HTTP_REQUEST {

 

if { [HTTP::cookie exists "abc"] } {

 

set cookie_s [HTTP::cookie "abc"]

 

HTTP::cookie remove "abc"

 

set cookie_a [HTTP::header cookie]

 

HTTP::header replace "cookie" "$cookie_a; def=$cookie_s"

 

}

 

}

 

}

 

 

Now, whenever you change to a newer version of the template, a function could be provided to list all iRules based on that template and allow the user to selectively regenerate the rules with the newer template but the original parameter values.

 

 

Ideally the iRules editor might store the templates in a binary format to force changes to be done through the GUI so they could be tracked. This could mean that when I make a change to the template above, it could automatically be changed to version 1.2 and all iRules based on version 1.1 could be checked to make sure they have not been manually modified, and if not they could be automatically or mostly-automatically upgraded to the new version.

 

 

It gets complicated if you want to have multiple instances of the iRules editor with the same templates... then you'd have to store the templates file on a share drive or the like. These are just some initial thoughts, but it could allow somebody to deploy many similar iRules quickly and update those easily when changes are required.

2 Replies

  • Sounds fun. Interested in writing some code? If not, I'll add this to my feature list for the editor although I think this needs a bit of spec'ing out first as there are a bunch of potential "gotchas" I can think of.

     

     

    Thanks for the feedback!

     

     

    -Joe
  • I am a UNIX C/C++/Perl/Bash programmer, so I probably wouldn't be much help coding-wise. But I could certainly help spec it out further... I also made a similar suggestion to have something similar built into BIG-IP itself -- i.e. you could define iRules templates and instances of those within the bigip.conf directly. This might be the better solution if it is done -- but then the iRules editor should allow the creation and modification of those templates stores on the BIG-IP.