Forum Discussion

dihris_116090's avatar
dihris_116090
Icon for Nimbostratus rankNimbostratus
Feb 09, 2015

Perl Local Lb Rule iControl script to manage iRules

Hello Guys,

 

I've been trying to find an iControl script that I can use to modify iRules.

 

So I found the one from the F5 wiki (link provided bellow) that handles the job quite good with one exception, I cannot modify existing iRules on the F5 BigIP LTM. I can list, add or delete iRules but what is import for me is to be able to change the default pool within an existng iRule itself. When I try doing this with the script bellow I get the following error: The requested iRule (/Common/test_iRule) already exists in partition Common.

 

My syntax is: LocalLBRule.pl host uid pwd load test_iRule Where the test_iRule is save locally with modified default pool and the same iRule is presented on the F5 with default pool different than the one saved locally.

 

I would appreciate any help with this script or any other script that could do the same job.

 

https://devcentral.f5.com/wiki/iControl.PerlLocalLbRule.ashx

 

2 Replies

  • Most likely the issue is that in the "doesiRuleExist()" function when it pulls down the iRules to check for if it's already defined, the returned value may be path delimited (ie. /Common/irule_name). If you are comparing that against "irule_name" that will fail. I'd add in some debug printing in the script to see if that's the case. If it is, you can do something like

    ...
    $rule_name = $RuleDefinition->{"rule_name"};
    if ( ($rule_name eq $name) || ($rule_name =~ /.*\/$rule_name/) ) {
    ...
    

    That would check to see if the iRule name is the same or that it ends with "/$rule_name" meaning that it's prefixed with a partition. Now, this still may cause problems if you are trying to save to a different partition/folder. If you are working on /Common than this should be fine.

    -Joe

  • Indeed that was the issue. To check if that was the problem I actually appended '/Common' to my file and the script worked. Your solution of-course is way more clean :)

     

    I still need to test what would be the behaviour (connections wise) when overwriting the default pool in the iRule assigned to the Virtual.

     

    Thank You for your help Joe!