Forum Discussion
Http class to irule conversion?
Does anyone know how to convert a http class to an irule. Starting with version 11.4 it seems http classes do not exist anymore. I need to convert a lot of http classes to an irule for a new device with version 11.6. Does anyone have a tool/script that does this?
i have the same issue with pools. The config on the 11.6 is not the same as old version (10.x or 9.x) How can i convert the old config(ver 9.x or 10.x) to new config(bigip version 11.6). Is there a tool to do that?
Hi Mihai,
Thanks! fot the quick reply. But my issue is that i can't upgrade. i have a new device that i need to migrate the old config to. This is how all my http classes look like:
profile httpclass cTest80 {
defaults from httpclass
pool pTest80
paths regex "/test"
}
Hi Mihai,
this would be a pool selection based on URI:when HTTP_REQUEST { replace "/test" according to your specific requirements if { [string tolower [HTTP::uri]] starts_with "/test" } { replace pool name by pool for specific application pool pTest80 } }
Thanks, Stephan
I know how to write a http class to an irule. The problem is that i have 300 http classes . How do i convert them to irules? Is there a tool/script for this or do i have to convert them manually?
- Sorry, misunderstood your initial question. I´m not aware of a tool. Instead I´m using plain "search/replace" patterns in an editor or convert the previous configuration output to a single-line format and apply a custom sed-script.
I tried search/replace too. It works only to a point. Right now i don'knoe how to move a line above the other (and do the same for 300 lines)
Thanks anyway!
- Editors like i.e. Notepad++ have a RegEx based search/replace option. Sample search pattern below finds corresponding lines starting with whitespaces and "pool" followed by a line with whitespaces and "paths". Matching strings in parentheses are buffered in \1 and \2 to be used for replacement. This way lines will be exchanged: search: ^([[:blank:]]+pool[[:blank:]]+.*)\r?\n([[:blank:]]+paths[[:blank:]]+.*)\r?\n replace: \2\n\1\n
Hi mihaic,
just copy all classes (section from previous /config/bigip.conf) into a single file on your /shared directory and name it i.e. ./classes, please:cat ./classes | tr -d "\r\n" | sed -r "s/(\})/\1\n/g" | \ sed -r -e 's/^[[:blank:]]+//g' -e 's/\}$/ }/g' | tr -s '[[:blank:]]' | \ sed -r 's/^profile httpclass ([^ ]+) \{ defaults from httpclass pool ([^ ]+) paths regex ([^ ]+) \}/ltm rule rule_\1 {\n if { [string tolower [HTTP::uri]] starts_with \3 } {\n pool \2\n }\n}\n/g'
The one-liner above should convert the existing classes into iRules.
Instead of putting the classes into file and to "cat" you can try as well a tmsh command to list all classes:tmsh list ltm httpclass | tr -d "\r\n" | sed -r "s/(\})/\1\n/g" | \ sed -r -e 's/^[[:blank:]]+//g' -e 's/\}$/ }/g' | tr -s '[[:blank:]]' | \ sed -r 's/^profile httpclass ([^ ]+) \{ defaults from httpclass pool ([^ ]+) paths regex ([^ ]+) \}/ltm rule rule_\1 {\n if { [string tolower [HTTP::uri]] starts_with \3 } {\n pool \2\n }\n}\n/g'
Output can be merged into running configuration.
Thanks, StephanThanks! I already did it with find/replace. The only think that i needed to do manually was to move teh pool line below the elseif line.
- Please see my RegEx example for search & replace above. Learning RegEx syntax is kind of pain but finally saves huge amount of time. :)
I tried your cat command and it works. Thanks next time i'll run it and than do a couple of find/replace so i convert all those irules to one irule.
thanks a lot!!!
Hi mihaic,
in case you want to consolidate the whole thing into a single iRule the "switch" command will be helpful:when HTTP_REQUEST { switch -glob [string tolower [HTTP::path]] { "/path01*" { pool pool_app_01 } "/path02*" { pool pool_app_02 } "/path03*" { pool pool_app_03 } default { pool pool_default } } }
This approach is faster than testing through a long list of if/elseif/elseif/.../else conditions.
Thanks, Stephan
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