Forum Discussion

Ignat_Vassilev1's avatar
Ignat_Vassilev1
Icon for Nimbostratus rankNimbostratus
Sep 01, 2010

Need a help migrating iRule from v9.4.8 to v 10.2.0

Hi All I need a help to migrate iRule from v9.4.8 to 10.2.0. Current iRule is:

 

 

when RULE_INIT {

 

array set ::ARRAY_100 { }

 

each time Data Group List is updated with new products

 

this irule must be updated to load the new array

 

so change this timestamp below to update array in memory...

 

 

TIMESTAMP: 25/09/2008:10:00am

 

 

foreach item $::hurl_list_100 {

 

set index [findstr $item "" 0 ":"]

 

set data [findstr $item ":" 1 "\n"]

 

set LIST "$index $data"

 

log $LIST

 

set ::ARRAY_100($index) $data

 

}

 

}

 

when HTTP_REQUEST {

 

log "request "

 

set pool $::ARRAY_100([TCP::local_port])

 

log "Pool selected from array: $pool" use pool $pool

 

}

 

}

 

 

 

And is not initiated after upgrade to v10.2.0. I’m not very good it using array so I tried to change it to but still have a problems

 

 

when RULE_INIT {

 

array set ARRAY_100 { }

 

each time Data Group List is updated with new products

 

this irule must be updated to load the new array

 

so change this timestamp below to update array in memory...

 

 

TIMESTAMP: 02/09/2010:10:00am

 

 

foreach item hurl_list_100 {

 

set index [findstr $item "" 0 ":"]

 

set data [findstr $item ":" 1 "\n"]

 

set LIST "$index $data"

 

log $LIST set ARRAY_100($index) $data

 

}

 

}

 

when HTTP_REQUEST {

 

log "request "

 

set pool ARRAY_100([TCP::local_port])

 

log "Pool selected from array: $pool" use pool $pool

 

}

 

}

 

 

 

Any help is much appreciated

 

Thanks

 

3 Replies

  • George_Watkins_'s avatar
    George_Watkins_
    Historic F5 Account
    Hi Ignat,

     

     

    It looks like you have an extra closing curly brace at line 21. Remove that and the rule should load fine. Don't forget to migrate the 'hurl_list_100' data group as well.

     

     

    Best regards,

     

     

    George
  • Thanks George

     

     

     

    "hurl_list_100" data group is:

     

     

    class hurl_list_100 {

     

    "33001:EVOPBBR_100-POOL"

     

    "33002:EVOPUXR_100-POOL"

     

    }

     

     

     

    so I don't see what has to be change in it for v10.2.0

     

     

    Thanks

     

    Ignat

     

  • Hi Guys,

     

     

    I decide to rewrite the iRule using class functionality with Array and it look like a better way to do it. Th eiRule and the data group class are bellow:

     

     

    class hurl_list {

     

    {

     

    "1000" { "chris-pool2" }

     

    "2000" { "chris-pool2" }

     

    "4000" { "chris-pool1" }

     

    "5000" { "chris-pool2" }

     

    }

     

    }

     

     

    rule hurl-test {

     

    when RULE_INIT {

     

     

    each time Data Group List is updated with new products

     

    this irule must be updated to load the new array

     

    so change this timestamp below to update array in memory...

     

     

    TIMESTAMP: 09/09/2010 09:00

     

     

     

    if {[array exists ARRAY_100]}{

     

    array unset ARRAY_100

     

    }

     

    for {set list 0} {$list < [class size hurl_list]} {incr list} {

     

    log local0. "[class element -name $list hurl_list] -> [class element -value $list hurl_list]"

     

    set index [class element -name $list hurl_list]

     

    log local0.debug "Index = $index"

     

    set data [class element -value $list hurl_list]

     

    log local0.debug "Data = $data"

     

    set ARRAY_100($index) $data

     

    log local0.debug "\[array get ARRAY_100\]: [array get ARRAY_100]"

     

    }

     

    }

     

    when HTTP_REQUEST {

     

    log "request "

     

    set pool $::ARRAY_100([TCP::local_port])

     

    log "Pool selected from array: $pool"

     

    pool $pool

     

    }

     

    }

     

     

     

     

    The output of the login:

     

    Sep 9 09:56:58 local/tmm info tmm[5257]: Rule hurl-test2 : 2000 -> chris-pool2

     

    Sep 9 09:56:58 local/tmm debug tmm[5257]: Rule hurl-test2 : Index = 2000

     

    Sep 9 09:56:58 local/tmm debug tmm[5257]: Rule hurl-test2 : Data = chris-pool2

     

    Sep 9 09:56:58 local/tmm debug tmm[5257]: Rule hurl-test2 : [array get ARRAY_100]: 2000 chris-pool2

     

    Sep 9 09:56:58 local/tmm info tmm[5257]: Rule hurl-test2 : 1000 -> chris-pool2

     

    Sep 9 09:56:58 local/tmm debug tmm[5257]: Rule hurl-test2 : Index = 1000

     

    Sep 9 09:56:58 local/tmm debug tmm[5257]: Rule hurl-test2 : Data = chris-pool2

     

    Sep 9 09:56:58 local/tmm debug tmm[5257]: Rule hurl-test2 : [array get ARRAY_100]: 1000 chris-pool2 2000 chris-pool2

     

    Sep 9 09:56:58 local/tmm info tmm[5257]: Rule hurl-test2 : 4000 -> chris-pool1

     

    Sep 9 09:56:58 local/tmm debug tmm[5257]: Rule hurl-test2 : Index = 4000

     

    Sep 9 09:56:58 local/tmm debug tmm[5257]: Rule hurl-test2 : Data = chris-pool1

     

    Sep 9 09:56:58 local/tmm debug tmm[5257]: Rule hurl-test2 : [array get ARRAY_100]: 4000 chris-pool1 1000 chris-pool2 2000 chris-pool2

     

    Sep 9 09:56:58 local/tmm info tmm[5257]: Rule hurl-test2 : 5000 -> chris-pool2

     

    Sep 9 09:56:58 local/tmm debug tmm[5257]: Rule hurl-test2 : Index = 5000

     

    Sep 9 09:56:58 local/tmm debug tmm[5257]: Rule hurl-test2 : Data = chris-pool2

     

    Sep 9 09:56:58 local/tmm debug tmm[5257]: Rule hurl-test2 : [array get ARRAY_100]: 4000 chris-pool1 5000 chris-pool2 1000 chris-pool2 2000 chris-pool2

     

    Sep 9 10:01:55 local/tmm info tmm[5257]: 01220002:6: Rule hurl-test2 : request

     

    Sep 9 10:01:55 local/tmm info tmm[5257]: 01220002:6: Rule hurl-test2 : Pool selected from array: chris-pool2

     

    Sep 9 10:02:18 local/tmm info tmm[5257]: 01220002:6: Rule hurl-test2 : request

     

    Sep 9 10:02:18 local/tmm info tmm[5257]: 01220002:6: Rule hurl-test2 : Pool selected from array: chris-pool1

     

     

    Thanks for your reply

     

    Ignat