Forum Discussion
What is the proper way to redfine an iRule through iControl?
I am looking for a way to dynamically redefine iRules via the iControl API. By "redefine", I mean, rewriting the "Definition" (RuleDefinition).
I see that LocalLBRule::query_rule can be passed the name of the rule and retrieve the definition of the given rule.
I also see a LocalLBRule::create and an LocalLBRule::delete method, but no LocalLBRule::update or LocalLBRule::save.
I was hoping to be able to: 1. LocalLBRule::query_rule => to get the definition of a certain rule 2. Modify the rule in code 3. LocalLBRule::save or LocalLBRule::update => but no such method exists
So I ask: how can I do this?
4 Replies
- dihris_116090
Nimbostratus
I've been looking for the same type if iControl script. Did anyone find a solution?
- chub_zh_185747
Nimbostratus
// This is Groovy code; you may need to Java-ify it.
// Write the new definition of the iRule.
String newRule = "NEW_IRUL_DEF_HERE"
// Instantiate a new rule def, make sure to give it the same name as the one you want to modify.
LocalLBRuleRuleDefinition ruleDef = new LocalLBRuleRuleDefinition("NAME_OF_RULE", newRule)
LocalLBRuleRuleDefinition[] ruleDefs = new LocalLBRuleRuleDefinition[1]
ruleDefs[0] = ruleDef
// Tell F5 you wish to modify the iRule. It will look up the existing "Name of rule" and overwrite it with 'newRule'. f5Interface.getLocalLBRule().modify_rule(ruleDefs)
// I despise the iControl Java API and wish someone at F5 would provide a modern, non-mechanically generated, OO client access JAR for it.
- dihris_116090
Nimbostratus
Not very familiar with Java so I used SOAP:
$iRDefine = { rule_name => $iRName, rule_definition => $iRdata};
$soapResponse = $LocalLBRule->modify_rule(SOAP::Data->name(rules => [$iRDefine]
But getting the following error: primary_error_code: 16908390 (0x1020066) secondary_error_code: 0 error_string: 01020066:3: The requested iRule (/Common/test_iRule) already exists in partition Common.
Still battling to find what is the issue.
- dihris_116090
Nimbostratus
Fixed myself. Had to append "/Common/" to the iRule name in the script. Now works fine.
Recent Discussions
Related Content
* 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