Forum Discussion
chungyu_16122
Altostratus
Mar 17, 2011Create 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 }
}
12 Replies
- The_Bhattman
Nimbostratus
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.xwhen HTTP_REQUEST { if { [matchclass [HTTP::uri] contains $Drupal} { pool CCS_Drupal } else { pool CSS_Webnode } }
or
v10when HTTP_REQUEST { if { [class match [HTTP::uri] contains Drupal] } { pool CCS_Drupal } else { pool CSS_Webnode } }
I hope this helps
Bhattman - chungyu_16122
Altostratus
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 - Steve_Brown_882Historic F5 Account
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, - hoolio
Cirrostratus
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 - Michael_Yates
Nimbostratus
Does anyone know or has anyone noticed a performance hit for storing Data Groups in external class files? - Steve_Brown_882Historic F5 AccountI am pretty sure the file is loaded into memory when the config is loaded. Unless I am wrong there shouldn't be.
- Michael_Yates
Nimbostratus
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! - hoolio
Cirrostratus
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 - Michael_Yates
Nimbostratus
Awesome. Thanks hoolio!
One less thing to investigate. Good info! - Hamish
Cirrocumulus
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 :)
H
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects