Forum Discussion

Maria123's avatar
Maria123
Icon for Altostratus rankAltostratus
Nov 27, 2019

Is assigning virtual server through iRule throws exception if it is offline

If I try to assign a different virtual server based upon some condition, do I need to check the status of the virtual server before assigning, or it will automatically be taken care and in this case it will throw exception.

if {[catch {virtual $<virtualServerName>}]} {

log local0. "Error in assigning virtual server"

}

 

Does checking the virtual server associated pool status (Up/Down) will help in this case.

 

3 Replies

  • Hello,

    I think you should care about exception if your variable don't have a valid virtual server name.

    Once name exists, I can't see it throwing exceptions due to virtual server availability state.

    You are trying to create a rule to only send traffic when destination virtual server is available? Is it?

     

    Regards

     

    • Maria123's avatar
      Maria123
      Icon for Altostratus rankAltostratus

      Thanks for your reply , yes intention was to select the virtual server only when it is available.

      So before selecting the virtual server checking the status of the virtual server associated default pool i.e. if active member is there make sense ? The pool is having only one virtual server.

  • Hi,

    Yes, make sense, but as you have only a default pool to virtual server, you can check it instead of create a pool to a single virtual server as well.

    Something like this:

    when <EVENT_DESIRED> {
        if { <condition is true> } {
            if { [active_members <default_pool_from_virtual_server1>] > 0 } {
                virtual <virtual_server1_name>
            } else {
                virtual <virtual_server2_name>
            }
        }
    }

    I hope it helps