Forum Discussion
Anthony_Gerace_
Nov 15, 2004Historic F5 Account
How to retrieve the rule details with query_all_rules
Hi!
I am attempting to write a script that will display the contents of all rules on a given system. In trying to use the query_all_rules method I'm having difficulty with retrieving the...
Nov 23, 2004
In 9.x the signature for the query_all_rules() method is:
struct RuleDefinition {
string rule_name;
string rule_definition;
};
RuleDefinition[] query_all_rules();
The method now returns an array of RuleDefinition structures.
Here's some code to query all rule names and rule defintions:
sub getRules()
{
$soapResponse = $LocalLBRule->query_all_rules();
if ( $soapResponse->fault )
{
print $soapResponse->faultcode,
"(faultstring) ", $soapResponse->faultstring,"\n";
print $soapResponse->faultcode,
"(faultdetail) ", $soapResponse->faultdetail, "\n";
}
else
{
$i = 0;
@RuleDefinitionList = @{$soapResponse->result};
foreach $RuleDefinition (@RuleDefinitionList)
{
$rule_name = $RuleDefinition->{"rule_name"};
$rule_definition = $RuleDefinition->{"rule_definition"};
print "Rule $i\n";
print "Name: $rule_name\n";
print "Details: $rule_definition\n";
$i++;
}
}
}
As you see, you cast the $soapResponse->result into an array. You then can enumerate that array and access the RuleDefinition members.
-Joe
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