Forum Discussion
libraries and procs
Hello All,
I am new to iRules and have been doing a lot of reading on DevCentral. I see a couple of excellent examples of using libraries and procedures (proc). However, I am struggling to use them as I receiving errors when trying to save the iRule. Simple code in its own iRule -- not in an event:
rule library {
proc foo { someInputVar } {
Do some stuff here and then return a value
return $bar
}
}Then I would call that from another iRule as such:
when CLIENT_ACCEPTED {
set fooBar [call library::foo "bar"]
}Seems simple and straight forward. However, I am experiencing a few issues: - When I am typing out the word "proc" in the iRules editor, the word disappears until I hit return, then is shows up in red highlight. I am taking that as a bad thing. - When I go to save, I am receiving an error:
Exception caught in LocalLB::urn:iControl:LocalLB/Rule::create() Exception: Common::OperationFailed primary_error_code : 17236305 (0x01070151) secondary_error_code : 0 error_string : 01070151:3: Rule [/Common/iRuleLibrary] error: /Common/iRuleLibrary:1: error: [undefined procedure: rule][rule library { proc isDst {foo} { return 1 } }]
This is patterned after an example I saw in DevCentral. Could be I need to set up something ahead of time. This is 11.4.1.
Any ideas?
Cheers in advance!
2 Replies
- Kevin_Stewart
Employee
Two things:
-
The red and disappearing "proc" in the iRule editor is an anomalous behavior. I imagine it's a relic of the iRule editor thinking Proc isn't supported.
-
Your iRule shouldn't start with "rule library". That's how it's described in the config and is created when you create the iRule.
An iRule named "library":
proc foo { someInputVar } { return $someInputVar }Test iRule:
when RULE_INIT { set foobar [call library::foo "test1234"] log local0. $foobar } -
- Heisenberg_1452Historic F5 Account
Feel somewhat dumb, but if I recall the example, it had {} after "rule library" so I thought it was required syntax.
Anyway, cheers, really appreciate it.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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