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,

when migrating to v11.4+ the existing http-classes will be translated to the new policy rule syntax.

Unfortunately there is no feature parity and you may miss the RegEx support.

Policy rules just allow “starts_with”, “ends_with” and “contains”.

That´s why I used to rewrite to logic to iRules (manually, as I´m not aware of a tool).

Assuming your http-classes follow a single schema we can try to provide a sample iRule reflecting the http-class logic. Would you please post a sample http-class (exerpt from /config/bigip.conf)?

Thanks, Stephan

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!

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, Stephan

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

Thanks! 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. :slight_smile:

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

Yes you are right.

Now one last thing. I need to convert pools form version 9 or 10 to version 11.6 I have more than 500 pools.

A pool in the old bigip looks like this :

pool Test80 { monitor all UptimeTesting and gateway_icmp members 10.160.4.11:http 10.160.4.12:http }

I need it to look like this in the new BIG-IP (ver 11.6.):

ltm pool /Common/pTestPool { members { /Common/10.160.4.11:80 { address 10.160.4.11 } /Common/10.160.4.12:80 { address 10.160.4.12 } } monitor /Common/gateway_icmp and /Common/http }

Can you help me with this ?

Hi mihaic, will it always be an http and gateway_icmp monitor? Thanks, Stephan

No. all will have gateway_icmp monitor. and some http too. But i can add http after. So if i have all pools with gateway_icmp it would be ok.

Thanks !!! a lot for your help.

Will get my v10 running soon, hopefully. Based on it I will put together a one-liner …

thanks!!!

are you doing an in-place upgrade or a migration to new devices? the f5 upgrade process will (to the best of its ability) automatically convert current configuration formats to that of the new code level. i’ve done migrations by both converting current config into new config syntax and moving config to new hardware/VE or by upgrading the entire config in a test environment and importing the new config to the new hardware.

are you stuck with doing a migration of old-code/hardware to new-code/hardware, or do you have other options?