Forum Discussion

David_Windeyer's avatar
David_Windeyer
Icon for Nimbostratus rankNimbostratus
May 25, 2011

help with using class match

I'm trying to write an I rule which will direct traffic to certain pools and nodes based on the host name.

 

 

The line with class match seems to be causing problems - complains about wanting braces. I tried following the example from http://devcentral.f5.com/wiki/defau...class.html

 

 

Does anyone have thoughts?

 

 

Thanks,

 

 

David.

 

 

 

 

when RULE_INIT {

 

Log debug messages to /var/log/ltm? (0=no, 1=yes)

 

set ::silo_access_debug 1

 

if {$::silo_access_debug}{log local0. "Debug set to $::silo_access_debug"}

 

}

 

when HTTP_REQUEST {

 

set app_pool_member [class match –value [HTTP::host] equals silo_access]

 

set app_pool [getfield $app_pool_member " " 1]

 

set app_member [getfield $app_pool_member " " 2]

 

if {$app_pool ne ""} {

 

if { $::silo_access_debug } { log local0. "[IP::client_addr] wants [HTTP::host], sending to pool $app_pool member $app_member" }

 

pool $app_pool member $app_member

 

}

 

}

 

3 Replies

  • Hi David,

     

     

    You have an m-dash (–) instead of a hyphen (-) on the value flag in your class command.

     

     

    Aaron
  • Also, you can change the global variable in RULE_INIT to a static variable to preserve CMP:

    
    when RULE_INIT {
        Log debug messages to /var/log/ltm? (0=no, 1=yes)
       set static::silo_access_debug 1
       if {$static::silo_access_debug}{log local0. "Debug set to $static::silo_access_debug"}
    }
    when HTTP_REQUEST {
      set app_pool_member [class match -value [HTTP::host] equals silo_access]
      set app_pool [getfield $app_pool_member " " 1]
      set app_member [getfield $app_pool_member " " 2]
      if {$app_pool ne ""} {
        if { $static::silo_access_debug } { log local0. "[IP::client_addr] wants [HTTP::host], sending to pool $app_pool member $app_member" }
        pool $app_pool member $app_member
      }
    }
    

    Aaron