Forum Discussion
sally_calvert_8
Oct 01, 2013Nimbostratus
11.3 tmsh cli for irule
I have the following irule, and I need to get it into one tmsh cli (using the editor or the gui is not an option). I can enter it through the gui just fine. But when I prepend tmsh create on the fron...
Hendry_Chandra_
Jun 11, 2015Historic F5 Account
Hi ALL,
Actually the command can be multiple liner. Only the issue is: read-ability of the codes are terrible. Example iRules with normally written using iRules Editor:
[root@BigIP:Active:Standalone] config tmsh list ltm rule Eval_Command
ltm rule Eval_Command {
when HTTP_REQUEST {
set Command [string map {/ " "} [HTTP::uri]]
if { $Command eq " " } {
HTTP::respond 200 content "Usage: /Command/Argument_1/Argument_2/Argument_3/.../Argument_N/\r\n" noserver "Connection" "Close"
} else {
HTTP::respond 200 content "$Command\r\n\r\n[eval $Command]\r\n\r\n<--- [clock format [clock seconds] -format "%Y-%m-%d %H:%M:%S"] --->\r\n" noserver "Connection" "Close"
}
}
}
[root@BigIP:Active:Standalone] config
with CLI (tmsh), you can write it as below:
[root@BigIP:Active:Standalone] config tmsh create ltm rule Test_iRules_CLI `echo "when HTTP_REQUEST { set Command [string map {/ \" \"} [HTTP::uri]] ; if { \\$Command eq \" \" } { HTTP::respond 200 content \"Usage: /Command/Argument_1/Argument_2/Argument_3/.../Argument_N/\\\r\\\n\" noserver \"Connection\" \"Close\" } else { HTTP::respond 200 content \"\\$Command\\\r\\\n\\\r\\\n[eval \\$Command]\\\r\\\n\\\r\\\n<--- [clock format [clock seconds] -format \"%Y-%m-%d %H:%M:%S\"] --->\\\r\\\n\" noserver \"Connection\" \"Close\" } }"`
[root@BigIP:Active:Standalone] config
the result will be:
[root@BigIP:Active:Standalone] config tmsh list ltm rule Test_iRules_CLI
ltm rule Test_iRules_CLI {
when HTTP_REQUEST { set Command [string map {/ " "} [HTTP::uri]] ; if { $Command eq " " } { HTTP::respond 200 content "Usage: /Command/Argument_1/Argument_2/Argument_3/.../Argument_N/\r\n" noserver "Connection" "Close" } else { HTTP::respond 200 content "$Command\r\n\r\n[eval $Command]\r\n\r\n<--- [clock format [clock seconds] -format "%Y-%m-%d %H:%M:%S"] --->\r\n" noserver "Connection" "Close" } }
}
[root@BigIP:Active:Standalone] config
Hope the above helps.
Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects