Forum Discussion
stucky101_88485
Nimbostratus
Aug 11, 2012Pull 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
6 Replies
- Hamish
Cirrocumulus
You're using the [class ..] commands? Not matchclass and findclass right?
Any of [class element|match|search -value] should do what you want.
H - stucky101_88485
Nimbostratus
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 ? - hoolio
Cirrostratus
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:
https://devcentral.f5.com/wiki/iRules.static.ashx
Aaron - stucky101_88485
Nimbostratus
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 ? - hoolio
Cirrostratus
1. Yes, that's correct.
2. Yes, data groups are synched with the full configuration when you initiate a config sync.
Aaron - stucky101_88485
Nimbostratus
Thank you Aaron !
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
