Create an External class file

Hi all

I am using an iRule to move traffic to different pools based on data group strings. Initially for testing used the GUI data group interface to create the class file.

But for production, we will have a over a thousand web subdirectories to point at a Drupal pool; so I want to use the external data group file.

But having alot of problems figuring out the syntax on how to list strings.

Inside the GUI

/dev/

/it/

/tmpdev/

works just fine, but when created an external file under /var/class, it would not parse past the first line.

Here is the iRule I am using:

when HTTP_REQUEST

{ if { [matchclass [HTTP::uri] contains ${::Drupal}] } {

pool CCS_Drupal

} else { pool CCS_Webnode }

}

Hi chungyu,

A couple of things.

Is your ADC on v9 or v10?

How are you seperating the external file entries? Are you using := or “;” or “,” etc. If you are then did you make sure you defined that in the datagroup you defined in the GUI?

Have you tried changing your code to the following

v9.x

when HTTP_REQUEST {

      if { [matchclass [HTTP::uri] contains $Drupal} {
            
            pool CCS_Drupal
        
      } else { 
            
             pool CSS_Webnode
        
      }

}

or

v10

when HTTP_REQUEST {

        if { [class match [HTTP::uri] contains Drupal] } {
            
               pool CCS_Drupal
        
        } else { 
            
               pool CSS_Webnode
        
        }

}

I hope this helps

Bhattman

Hi Bhattman

I am running version 10.1, I tried to following the BIGIP manual and having no real succes, a bit cryptic for me. F5 recommneds creating the external file in /var/class directory. using the bigpipe commands I was not even able to create the file, let alone create entries.

When I used the internal data group I used \“dev\” to separate. I see from the document should use ::= to separate arguments.

I am really looking for an example to follow, the ones in the manual are not very good and I have opened a support case with F5 this morning. but if you have an example, it would be great.

Thanks

Chung

Here is an example of a rule I have used. The rule itself looks at a class file called class_file.

when HTTP_REQUEST {

set pool [class match -value [HTTP::uri] starts_with class_file]

if {$pool ne “”} {

pool $pool

} else {

pool default_pool

}

}

}

Class file includes line similar to the list below.

/content := pool1,

/images :=pool2,

/script := pool3,

Steve’s example is a good one. The class wiki page also has examples of the datagroup formats:

http://devcentral.f5.com/wiki/default.aspx/iRules/class

External Class Format:

class namevalue {

“name1” := “value”,

“name2” := “value”,

}

Internal Class Format:

class namevalue {

{

“name1” { “value” }

“name2” { “value” }

}

}

Aaron

Does anyone know or has anyone noticed a performance hit for storing Data Groups in external class files?

I am pretty sure the file is loaded into memory when the config is loaded. Unless I am wrong there shouldn’t be.

I’ll have to try this and run some tests.

I’m curious how the BigIP handles modifications to the class files in a device sync or if you have to modify them manually in an Active/Standby pair.

Anything to help clean out the config files is worth the time in my opinion. Especially since we just automated our configuration files to be automatically exported, versioned and then put into a source control repository.

Thanks!

I agree with Steve. I think the class performance should be the same regardless of whether the class contents are loaded from the bigip.conf or an external class file. Make sure to use the name=value pairing and class commands though for lookups as this combination will be a lot more efficient than using “name value” format and the findclass or matchclass command.

Michael, the datagroup will be saved in a UCS file and synched during a config sync.

Aaron

Awesome. Thanks hoolio!

One less thing to investigate. Good info!

IIRC there’s a small perl program around here (i.e. on my laptop) somewhere that I wrote to populate an external classfile via iControl… I’ll see if I can find it tomorrow.

It detects whether the unit you’re targetting is active or standby. Only updates an active unit, and automatically performs a sync after the upload (It was written for v9.x so has to delete and re-populate the file… v10 can update on the fly, I should re-write it :slight_smile:

H

Ahhh the power of perl

Bhattman

Nice Hamish, I’ll have to re-post that if I can find it so folks can get their hands on it. Also keep in mind that the external class file format changed (for the better) in v10. So an updated version would definitely be worth it.

Colin