Pull global variable from data group list

Gurus

I’m trying to do something that should be rather simple but I’m beginning to wonder whether I’m looking in the wrong place.

I have used 2 data group lists successfully of type string. Both of them simply contain a list of strings with no values and I iterate over them to compare some stuff to live traffic.

However, there is the option of also creating key:value pairs so I thought I could use this as a simple hash.

I created a class called “base” thinking I could add a few key:value pairs there that I can extract later.

Example :

domain := domain.company.com

Now I should be able to extract the value of key “domain” in an iRule and use it for example for redirects from short hostname to fqdn. It’s basically like a global TCL var but aren’t data group lists the way to go ?

It appears you have to run an operator against the key such as “equal” or “starts_with” when all I wanna do is look up its value and return it.

If this is not designed for that then what is the key:value option there for ?

Any help is appreciated

thx

You’re using the [class ..] commands? Not matchclass and findclass right?

Any of [class element|match|search -value] should do what you want.

H

Hamish

Thanks for the confirmation.

Yes I know matchclass and findclass are gone. I figured it out. That was a misunderstanding on my part.

The following does what I want. Suppose I have a class called “global” with 2 key/value pairs in it I can read them out like this :

when HTTP_REQUEST {

set alias [class search -value global equals vip01]

set domain [class search -value global equals domain01]

log local0. “Testing: domain is $domain. Alias is $alias”

}

I assume this is a good way to set global variables right ?

That is a good way to set “global” variables in a data group. You could also use the static namespace if you want to avoid using a data group:

Aaron

Aaron

Just to confirm 2 things

1. Changes to the data group list will be effective immediately without any restarts

2. These data group lists will be replicated to the standby in an active/standby cluster

Correct ?

1. Yes, that’s correct.

2. Yes, data groups are synched with the full configuration when you initiate a config sync.

Aaron

Thank you Aaron !