Forum Discussion
qqdixf5_74186
Nimbostratus
Apr 01, 2010Internal class format
Is this format valid for v10.0.1.
class namevalue {
{
"name1" { "value1" }
"name2" { "value1" }
}
}
I am getting a parsing error on b verify load.
012e0021:3: The requested attribute ({ name1) is invalid for 'class'.
So I tried this and it passed the verify.
class namevalue {
"name1" { "value1" }
"name2" { "value1" }
}
But, after I load and sync, the class changed to
class namevalue {
{
"value1"
"name1"
"value2"
"name2"
}
}
I want to make it easy to lookup values based on names.
Thanks!
6 Replies
- L4L7_53191
Nimbostratus
On 10.1 this is what works for me:class foo { { "www.one.com www.foo.com" "www.two.com www.bar.com" } }
-Matt - qqdixf5_74186
Nimbostratus
This format works in v10.0.1 as well. But does it make the entry as name/value pairs so it it easy to lookup value based on the key?
I just tested it. It doesn't. The whole line is treat as the name of the element. I have to parse it.
It sounds like the below format should be valid for internal calls in v10.0.1, according to the class wiki page. I wonder why it couldn't pass the verify commandclass namevalue { { "name1" { "value" } "name2" { "value" } } }
Any help is appeciated! - Hamish
Cirrocumulus
Well the formatclass keyvalue { { "onekey" { "onevalue" } "twokey" { "twovalue" } } }
is the way that the GUI adds in the key/value pairs when you create the DG via the GUI itself. That verifies on my vLTM. I don't see why it wouldn't validate on yours. Are you sure the error is in the class itself and not before it?
H - qqdixf5_74186
Nimbostratus
I used GUI, created a string datagroup, added these two string entries:"name1" {"value1"} "name2" {"value2"}
After save, open config file and they are saved as:class namevalues{ { "\"name1\" {\"value1\"}" "\"name2\" {\"value2\"}" } }
Each line is treated as the name of element. so [class names namevalues] command returns:{"name1" {"value1"}} {"name2" {"value2"}}
[class match -value "name1" equals namevalues] returns nothing. - L4L7_53191
Nimbostratus
This rule works with the original format I posted above. The idea of the rule is to redirect based on a lookup of the original HTTP::host header value. For example,
with a class like:
class foo {
{
"www.one.com www.foo.com"
"www.two.com www.bar.com"
}
}
The following code:when HTTP_REQUEST { set Host [findclass [HTTP::host] dc-post " "] log local0. "Host var is $Host" if { $Host ne "" } { HTTP::redirect http://$Host[HTTP::uri] } }
...will lookup the k/v pair where www.one.com or www.two.com are the keys, and redirect to the value (www.foo.com or www.bar.com).
It may be of value to have a look at this post: https://devcentral.f5.com/Default.aspx?tabid=53&view=topic&postid=1144951&forumid=5&tpage=1
-Matt - hoolio
Cirrostratus
I think qqdixf5 is using 10.0.x which might handle class -name and class -value differently than 10.1.x. I think in order to use class -name/-value in 10.0.x, you'd need to use the := format in an external datagroup.
Aaron
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