ltm rule command call
iRule(1) BIG-IP TMSH Manual iRule(1)
call
Calls an iRule procedure.
SYNOPSIS
call ('-debug')? PROC_NAME (PROC_ARGUMENT)*
DESCRIPTION
iRule procedures:
- Are similar to procedures, functions, subroutines from other languages
- Allow for reuse of common code
- Reference the same code from multiple locations, but only define it in one place
- Simplifies code maintenance
- Allow you to augment the predefined iRule commands
Procedures are defined with the proc statement. This must be done outside of any event. Procedures can be defined within an
iRule assigned to a virtual server or in a separate iRule not assigned to any virtual server.
You can call a local proc (one defined in the same iRule) without a namespace prefix:
call my_proc $args To reference a proc defined in another iRule in the same partition, prefix the proc name with the
iRule name where the proc is defined
call other_rule::my_proc $args To reference a proc defined in another iRule in a different partition, prefix the proc
name with the partition and iRule name where the proc is defined
call /other_partition/other_rule::procname args
Note: Calling a proc in another iRule and/or partition does not affect CMP
RETURN VALUE
Returns the value that returns (if any).
VALID DURING
RULE_INIT
EXAMPLES
# Define one or more procs in an iRule outside of any event. This iRule does not need to be assigned to any virtual server.
rule proc_rule {
proc printArguments args {
foreach arg $args {
log local0. "$arg"
}
}
proc returnArguments args {
log local0. "returning $args"
return $args
}
}
# Call the proc(s) from the same or another iRule. If you reference the proc from another iRule prefix it with the iRule name where the proc is defined. The prefix can contain an absolute folder path.
when RULE_INIT {
# Call a proc which returns no values
call proc_rule::printArguments one two three
# Save the return value of a proc
set return_values [call proc_rule::returnArguments one two three]
}
# Proc which accepts no parameters:
proc noargs {} {
log local0. "Expected and received no arguments"
}
# Proc which accepts a variable number of arguments:
proc any_number_args args {
log local0. "Received [llength $args] args: $args"
}
# Proc which accepts an explicit number of arguments
proc explicit_args {arg1 arg2} {
log local0. "Received two args: $arg1 and $arg2"
}
# Proc which sets default values for arguments if they aren't specified in the call statement:
proc default_value_for_args {{arg1 default1} {arg2 default2}} {
log local0. "Current values \$arg1: $arg1, \$arg2: $arg2"
}
call default_value_for_args ; # arg1 is set to "default1", arg2 is set to "default"
call default_value_for_args "a" ; # arg1 is set to "a", arg2 is set to "default"
call default_value_for_args "a" "b" ; # arg1 is set to "a", arg2 is set to "b"
HINTS
SEE ALSO
HTML encoding proc - iRule proc which HTML encodes an input string
Random String Generators - generate a random string of
letters, numbers, or both Tcl lmap emulator - Tcl
lmap emulation Yubikey 2Factor Authentication with BIG-IP
LTM - This iRule provides 2-Factor Authentication with YubiCloud Service
CHANGE LOG
@BIGIP-11.4.0 - first introduced the command
BIG-IP 2022-04-12 iRule(1)