# Create an External class file

**URL:** <https://community.f5.com/t/create-an-external-class-file/4407>\
**Category:** Technical Forums\
**Tags:** dev, irules, devops, application-delivery\
**Created:** [March 17, 2011, 5:36pm UTC](https://community.f5.com/t/create-an-external-class-file/4407 "2011-03-17T17:36:46Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![chungyu\_16122](https://avatars.discourse-cdn.com/v4/letter/c/f1d935/32.png) [@chungyu\_16122](https://community.f5.com/u/chungyu_16122)\
**Post date:** [March 17, 2011, 5:36pm UTC](https://community.f5.com/t/create-an-external-class-file/4407/1 "2011-03-17T17:36:46Z")

</div>

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 }

}

---

<div class="post-metadata">

**Author:** ![The\_Bhattman](https://d1p9zq3aats0t8.cloudfront.net/user_avatar/community.f5.com/the_bhattman/32/13958_2.png) [@The\_Bhattman](https://community.f5.com/u/The_Bhattman)\
**Post date:** [March 17, 2011, 11:56pm UTC](https://community.f5.com/t/create-an-external-class-file/4407/2 "2011-03-17T23:56:58Z")

</div>

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

```tcl
when HTTP_REQUEST {

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

}

```

or

v10

```tcl
when HTTP_REQUEST {

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

}

```

I hope this helps

Bhattman

---

<div class="post-metadata">

**Author:** ![chungyu\_16122](https://avatars.discourse-cdn.com/v4/letter/c/f1d935/32.png) [@chungyu\_16122](https://community.f5.com/u/chungyu_16122)\
**Post date:** [March 18, 2011, 2:00pm UTC](https://community.f5.com/t/create-an-external-class-file/4407/3 "2011-03-18T14:00:54Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Steve\_Brown\_882](https://avatars.discourse-cdn.com/v4/letter/s/76d3ee/32.png) [@Steve\_Brown\_882](https://community.f5.com/u/Steve_Brown_882)\
**Post date:** [March 18, 2011, 3:02pm UTC](https://community.f5.com/t/create-an-external-class-file/4407/4 "2011-03-18T15:02:17Z")

</div>

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,

---

<div class="post-metadata">

**Author:** ![hoolio](https://avatars.discourse-cdn.com/v4/letter/h/f6c823/32.png) [@hoolio](https://community.f5.com/u/hoolio)\
**Post date:** [March 18, 2011, 3:50pm UTC](https://community.f5.com/t/create-an-external-class-file/4407/5 "2011-03-18T15:50:12Z")

</div>

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](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

---

<div class="post-metadata">

**Author:** ![Michael\_Yates](https://avatars.discourse-cdn.com/v4/letter/m/f08c70/32.png) [@Michael\_Yates](https://community.f5.com/u/Michael_Yates)\
**Post date:** [March 18, 2011, 6:25pm UTC](https://community.f5.com/t/create-an-external-class-file/4407/6 "2011-03-18T18:25:55Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Steve\_Brown\_882](https://avatars.discourse-cdn.com/v4/letter/s/76d3ee/32.png) [@Steve\_Brown\_882](https://community.f5.com/u/Steve_Brown_882)\
**Post date:** [March 18, 2011, 6:58pm UTC](https://community.f5.com/t/create-an-external-class-file/4407/7 "2011-03-18T18:58:13Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Michael\_Yates](https://avatars.discourse-cdn.com/v4/letter/m/f08c70/32.png) [@Michael\_Yates](https://community.f5.com/u/Michael_Yates)\
**Post date:** [March 18, 2011, 7:08pm UTC](https://community.f5.com/t/create-an-external-class-file/4407/8 "2011-03-18T19:08:38Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![hoolio](https://avatars.discourse-cdn.com/v4/letter/h/f6c823/32.png) [@hoolio](https://community.f5.com/u/hoolio)\
**Post date:** [March 18, 2011, 7:16pm UTC](https://community.f5.com/t/create-an-external-class-file/4407/9 "2011-03-18T19:16:56Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Michael\_Yates](https://avatars.discourse-cdn.com/v4/letter/m/f08c70/32.png) [@Michael\_Yates](https://community.f5.com/u/Michael_Yates)\
**Post date:** [March 18, 2011, 8:06pm UTC](https://community.f5.com/t/create-an-external-class-file/4407/10 "2011-03-18T20:06:26Z")

</div>

Awesome. Thanks hoolio!

One less thing to investigate. Good info!

---

<div class="post-metadata">

**Author:** ![Hamish](https://avatars.discourse-cdn.com/v4/letter/h/a5b964/32.png) [@Hamish](https://community.f5.com/u/Hamish)\
**Post date:** [March 18, 2011, 11:10pm UTC](https://community.f5.com/t/create-an-external-class-file/4407/11 "2011-03-18T23:10:44Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![The\_Bhattman](https://d1p9zq3aats0t8.cloudfront.net/user_avatar/community.f5.com/the_bhattman/32/13958_2.png) [@The\_Bhattman](https://community.f5.com/u/The_Bhattman)\
**Post date:** [March 19, 2011, 12:58am UTC](https://community.f5.com/t/create-an-external-class-file/4407/12 "2011-03-19T00:58:46Z")

</div>

Ahhh the power of perl

Bhattman

---

<div class="post-metadata">

**Author:** ![Colin\_Walker\_12](https://avatars.discourse-cdn.com/v4/letter/c/a88e4f/32.png) [@Colin\_Walker\_12](https://community.f5.com/u/Colin_Walker_12)\
**Post date:** [March 23, 2011, 4:33pm UTC](https://community.f5.com/t/create-an-external-class-file/4407/13 "2011-03-23T16:33:11Z")

</div>

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
